<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Igor Kanshyn on Medium]]></title>
        <description><![CDATA[Stories by Igor Kanshyn on Medium]]></description>
        <link>https://medium.com/@igorkanshyn?source=rss-b8e00ce4fbed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Bixq_h7CWCOJmVvdmaUpmw.jpeg</url>
            <title>Stories by Igor Kanshyn on Medium</title>
            <link>https://medium.com/@igorkanshyn?source=rss-b8e00ce4fbed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 10:19:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@igorkanshyn/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[External Vault to Kubernetes clusters integration]]></title>
            <link>https://medium.com/@igorkanshyn/external-vault-to-kubernetes-clusters-integration-5b74a67b85e?source=rss-b8e00ce4fbed------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b74a67b85e</guid>
            <category><![CDATA[vault]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[secrets]]></category>
            <dc:creator><![CDATA[Igor Kanshyn]]></dc:creator>
            <pubDate>Thu, 22 Jun 2023 15:22:24 GMT</pubDate>
            <atom:updated>2023-06-22T15:22:24.505Z</atom:updated>
            <content:encoded><![CDATA[<p>This article describes how to enable <strong>Vault</strong> to <strong>Kubernetes cluster</strong> integration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jii24qnlVpnfmWEZnN08VA.png" /></figure><p>Such integration gives the ability to inject <em>secrets</em> into Kubernetes PODs. The <em>secret</em> values will be injected into a file available to PODs. The file format is customizable and it’s possible to create a <em>shell script</em> file that defines <em>secret</em> values as <em>environment variables</em> on Kubernetes POD.</p><h3>Prerequisites</h3><ul><li>We will utilize <em>Vault Agent</em> containers here. We assume that <em>Vault</em> is installed on <em>Kubernetes</em>, but on a different <em>Kubernetes cluster</em>, not the one we are targeting to integrate here.</li><li>We need to have a working unsealed <em>Vault</em> cluster</li><li>We need a <em>Kubernetes</em> cluster or several ones that we will integrate</li><li>Kubectl, git, and helm tools are needed to be installed.</li><li>Linux or Mac computer is used to access the tools</li></ul><h3>Set up Kubernetes alias</h3><p>Execute the following command:</p><pre>alias k=kubectl</pre><h3>Getting access to Vault</h3><p>We assume that <em>Vault</em> is installed on its own <em>Kubernetes</em> cluster and it is a high availability (HA) installation.</p><p><strong>Checking Vault deployment</strong></p><p>Let’s connect to your <em>Vault</em> K<em>ubernetes</em> cluster and check what pods we have:</p><pre>k get po</pre><p>We assume here that <em>Vault</em> is running on the default namespace.</p><p>You should get something like this in the result:</p><pre><strong>NAME                       READY    STATUS         RESTARTS   AGE</strong><br>vault-0                     1/1     Running            0      24h<br>vault-1                     1/1     Running            0      24h<br>vault-2                     1/1     Running            0      24h<br>vault-agent-injector-7d866  1/1     Running            0      24h<br>vkjapp-7f8f975d-r59r9       2/2     Running            0      23h</pre><p>As you can see we have HA Vault installation with three vault instances and an agent POD. They all should be running.</p><p>This Vault was installed with the help of the following instruction: <a href="https://learn.hashicorp.com/tutorials/vault/kubernetes-google-cloud-gke?in=vault/kubernetes">https://learn.hashicorp.com/tutorials/vault/kubernetes-google-cloud-gke?in=vault/kubernetes</a></p><p><strong>Checking vault status</strong></p><pre>k exec -it vault-0 -- vault status</pre><p>It’s essential to make sure that your Vault is initiated and NOT sealed (Sealed: false)</p><pre>Key                     Value<br>---                     -----<br>Seal Type               shamir<br>Initialized             true<br>Sealed                  <strong>false</strong><br>...</pre><h3>Insert test secrets into Vault</h3><p>Let’s add a test secret to validate the connectivity later.</p><p>Exec into Vault pod:</p><pre>k exec --stdin=true --tty=true vault-0 -- /bin/sh</pre><p>While still in the vault shell session, let’s enable kv-v2 secrets at the path secret. Execute the following:</p><pre>vault secrets enable -path=secret kv-v2</pre><p>Next, create a secret at path secret/devwebapp/config with a username and password:</p><pre>vault kv put secret/devwebapp/config username=&#39;giraffe&#39; password=&#39;salsa&#39;</pre><p>Finally, verify that the secret is defined at the path secret/data/devwebapp/config.</p><pre>vault kv get secret/devwebapp/config</pre><p>You should get the following output:</p><pre>====== Metadata ======<br>Key              Value<br>---              -----<br>created_time     2020-12-11T19:14:05.170436863Z<br>deletion_time    n/a<br>destroyed        false<br>version          1</pre><pre>====== Data ======<br>Key         Value<br>---         -----<br>password    salsa<br>username    giraffe</pre><h3>Optional. Make public access to Vault UI and API.</h3><p>The vault I installed did not have an external IP or domain configured to access it.</p><p>At this step, we will create a LoadBalance service to get an external IP address to access Vault from other Kubernetes clusters or the internet. Note, that this access URL is not-HTTPS and should not be used with real applications.</p><p>We will utilize a helper repository from GitHub here.</p><p>Clone the vault-kubernetes-java repository:</p><pre>git clone https://github.com/grenader/vault-kubernetes-java.git cd vault-kubernetes-java/vault</pre><p>Create a LoadBalancer to access Vault externally:</p><pre>k apply -f vault-load-balancer.yml</pre><p>Wait until the Load balancer has got an external IP and print it:</p><pre>k get svc vault-lb<br>k get svc vault-lb -o jsonpath=&quot;{.status.loadBalancer.ingress[0].ip}&quot;</pre><p>And store this IP and access URL into environment variables:</p><pre>EXTERNAL_VAULT_ADDR=$(k get svc  vault-lb -o jsonpath=&quot;{.status.loadBalancer.ingress[0].ip}&quot;)<br>VAULT_ADDR=<a href="http://$external_vault_addr:8200/">http://$EXTERNAL_VAULT_ADDR:8200</a></pre><p>Since we will need to work on several clusters, we will store this Vault Kubernetes cluster config in a different file for future use.</p><pre>cp ~/.kube/config ~/.kube/config-vault-ha</pre><p>We have stored our config in config-vault-ha file.</p><h3>Preparing another Kubernetes cluster to integrate with Vault</h3><p>The following steps were partially derived from <a href="https://learn.hashicorp.com/tutorials/vault/kubernetes-external-vault#deploy-service-and-endpoints-to-address-an-external-vault">https://learn.hashicorp.com/tutorials/vault/kubernetes-external-vault#deploy-service-and-endpoints-to-address-an-external-vault</a> instruction.</p><p>At this point, we will switch to another <em>Kubernetes</em> (k8s) cluster. Let’s call it “client cluster”. This <em>Kubernetes cluster</em> will use our <em>Vault</em> cluster.</p><p>Since I using Google Cloud Platform (GCP) to run K8s cluster, I will use something like this:</p><pre>gcloud container clusters get-credentials &lt;cluster-name&gt; ...</pre><p>On <strong>Tanzu Kubernetes Grid Integrated Edition</strong> (TKGI) cluster we need to use</p><pre>tkgi get-credentials &lt;cluster-name&gt;</pre><p>These commands will replace ~/.kube/config file with a new cluster connection info.</p><p>Check that you are on the right cluster, for instance:</p><pre>k cluster-info</pre><p>And observe the results.</p><p>Create a <em>Kubernetes service</em> account named internal-app. We will use it later.</p><pre>k create sa internal-app</pre><h3>Optional. Test direct connective to Vault</h3><p>This is an optional step. We will call an application that will connect to Vault directly and we need to supply the Vault token.</p><p><strong>Set your <em>Vault</em> Access Token into the environment variable:</strong></p><pre>VAULT_ACCESS_TOKEN=&lt;your vault access token&gt;</pre><p><strong>Make sure that EXTERNAL_VAULT_ADDR is set correctly. If not, look at the previous steps.</strong></p><pre>echo $EXTERNAL_VAULT_ADDR</pre><p><strong>Create a testing application pod</strong></p><pre>kubectl apply -f - &lt;&lt;EOF<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: direct-vault<br>  labels:<br>    app: direct-vault<br>spec:<br>  serviceAccountName: internal-app<br>  containers:<br>    - name: app<br>      image: burtlo/devwebapp-ruby:k8s<br>      env:<br>        - name: VAULT_ADDR<br>          value: &quot;<a href="http://$external_vault_addr:8200/">http://$EXTERNAL_VAULT_ADDR:8200</a>&quot;<br>        - name: VAULT_TOKEN<br>          value: &quot;$VAULT_ACCESS_TOKEN&quot;<br>EOF</pre><p><strong>Call the application to see the secret from Vault</strong></p><pre>k exec direct-vault -- curl -s localhost:8080 ; echo</pre><p>The results should be:</p><blockquote><em>{“password”=&gt;”salsa”, “username”=&gt;”giraffe”}</em></blockquote><p>Note, this application expects a secret at “secret/devwebapp/config” only.</p><p>We have validated that the Vault secret can be correctly accessed externally.</p><p>Note, that this “direct connection” does not work for <em>Vault</em> servers running on HTTPS.</p><h3>Installing Vault client:</h3><p><strong>Install Vault Agent via helm</strong></p><pre>helm repo add hashicorp <a href="https://helm.releases.hashicorp.com/">https://helm.releases.hashicorp.com</a><br>helm repo update<br>helm install vault hashicorp/vault --set &quot;injector.externalVaultAddr=<a href="http://$external_vault_addr:8200/">http://$EXTERNAL_VAULT_ADDR:8200</a>&quot;</pre><p><strong>Check status the helm installation status</strong></p><pre>helm status vault</pre><p><strong>See a new vault agent deployment</strong></p><pre>k get deploy</pre><p>The output should be:</p><pre>&gt; NAME                   READY   UP-TO-DATE   AVAILABLE   AGE<br>&gt; vault-agent-injector   1/1     1            1           87s</pre><h3>Prepare environment variables with the client cluster details</h3><p>Execute the command listed below to collect info about our current (client cluster) <em>Kubernetes cluster</em>:</p><pre>VAULT_HELM_SECRET_NAME=$(kubectl get secrets --output=json | jq -r &#39;.items[].metadata | select(.name|startswith(&quot;vault-token-&quot;)).name&#39;)</pre><pre>TOKEN_REVIEW_JWT=$(kubectl get secret $VAULT_HELM_SECRET_NAME --output=&#39;go-template={{ .data.token }}&#39; | base64 --decode)</pre><pre>KUBE_CA_CERT=$(kubectl config view --raw --minify --flatten --output=&#39;jsonpath={.clusters[].cluster.certificate-authority-data}&#39; | base64 --decode)</pre><pre>KUBE_HOST=$(kubectl config view --raw --minify --flatten --output=&#39;jsonpath={.clusters[].cluster.server}&#39;</pre><p>Check whether we have got the values in those environment variables:</p><pre>echo $TOKEN_REVIEW_JWT ; echo $KUBE_CA_CERT ; echo $KUBE_HOST</pre><h3>Set up Kubernetes Authentication in Vault</h3><p>At this step, we will connect to our <em>Vault</em> that runs on another Kubernetes cluster, and utilize environment variables that we set above.</p><p>Connect to Vault POD:</p><pre>kubectl --kubeconfig ~/.kube/config-vault-ha exec -it vault-0 -- /bin/sh</pre><p>While still in the vault shell session, enable Vault-Kubernetes authentication:</p><pre>vault auth enable kubernetes</pre><p>Note, that if you have already enabled Kubernetes authentication on your Vault, this command will fail with <strong>“* path is already in use at kubernetes/”</strong> This is Ok. Note, that if you did not login into this Vault for a while, you might see “… * missing client token” error message. In this case, use “vault login” to login first and then repeat the command.</p><p><strong>Configure Kubernetes-Vault authentication</strong></p><p>Exit “vault-0” exec command and execute:</p><pre>kubectl --kubeconfig ~/.kube/config-vault-ha exec -it vault-0 -- vault write auth/kubernetes/config token_reviewer_jwt=&quot;$TOKEN_REVIEW_JWT&quot; kubernetes_host=&quot;$KUBE_HOST&quot; kubernetes_ca_cert=&quot;$KUBE_CA_CERT&quot; issuer=&quot;<a href="https://kubernetes.default.svc.cluster.local/">https://kubernetes.default.svc.cluster.local</a>&quot;</pre><p>Create a <em>Vault policy</em> to allow read access to secret/data/devwebapp/config path.</p><p>This is where we keep our test secret:</p><pre>kubectl --kubeconfig ~/.kube/config-vault-ha exec -it vault-0 -- vault policy write devwebapp - &lt;&lt;EOF<br>path &quot;secret/data/devwebapp/config&quot; {<br>capabilities = [&quot;read&quot;]<br>}<br>EOF</pre><p>Apply this <em>policy</em> to <em>Vault</em>:</p><pre>kubectl --kubeconfig ~/.kube/config-vault-ha exec -it vault-0 -- vault write auth/kubernetes/role/devweb-app \ bound_service_account_names=internal-app \ bound_service_account_namespaces=default \ policies=devwebapp \ ttl=24h</pre><h3>Check Kubernetes-Vault integration</h3><p><strong>Deploy a testing application and its service to</strong></p><p>If you have not done this earlier, fetch the testing git repo:</p><pre>git clone <a href="https://github.com/grenader/vault-kubernetes-java.git">https://github.com/grenader/vault-kubernetes-java.git</a><br>cd vault-kubernetes-java/vault</pre><p>Create a deployment and a service</p><pre>k apply -f show-secret-app-ha.yml</pre><p>Wait until the Load Balancer has got an external IP and print it:</p><pre>k get svc vkjservice<br>k get svc vkjservice -o jsonpath=&quot;{.status.loadBalancer.ingress[0].ip}&quot;</pre><p><strong>Get an External IP address</strong></p><pre>SHOW_SECRET_SERVICE_IP=$(k get svc vkjservice -o jsonpath=&quot;{.status.loadBalancer.ingress[0].ip}&quot;)</pre><p><strong>This command will open a new browser with a page that presents a value</strong></p><pre>open <a href="http://$show_secret_service_ip/secret">http://$SHOW_SECRET_SERVICE_IP/secret</a></pre><p><strong>Alternatively, you can access the testing service in curl</strong></p><pre>curl <a href="http://$show_secret_service_ip/secret">http://$SHOW_SECRET_SERVICE_IP/secret</a></pre><p>The expected result:</p><pre>username=giraffe;password=salsa</pre><h3>Configuration review</h3><p>Please, quickly review show-secret-app-ha.yml file to understand the required configuration.</p><pre>cat show-secret-app-ha.yml</pre><p><strong>spec.template.metadata.annotations</strong> section defined that:</p><ul><li>Kubernetes “devweb-app” role is used,</li><li>“secret/data/devwebapp/config” is set a secrets path in Vault,</li><li>database-config.txt file will be created with secrets data,</li><li>“username=$$$;password=$$$” is used a template to format secreted data before storing it into database-config.txt file</li><li>“/vault/secrets/” is a default location where the <em>Vault</em> agent creates secret files.</li></ul><p>At this point, we should have an established integration between the external Vault and the Kubernetes cluster.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b74a67b85e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tips and tricks about CKDA certification exam]]></title>
            <link>https://medium.com/@igorkanshyn/tips-and-tricks-about-ckda-certification-exam-1e31ccce7416?source=rss-b8e00ce4fbed------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e31ccce7416</guid>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[certification]]></category>
            <dc:creator><![CDATA[Igor Kanshyn]]></dc:creator>
            <pubDate>Wed, 26 Aug 2020 23:57:25 GMT</pubDate>
            <atom:updated>2020-08-26T23:57:25.904Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Tips and tricks of CKDA certification</strong></h3><figure><img alt="Certified Kubernetes Application Developer (CKAD)" src="https://cdn-images-1.medium.com/max/1024/1*SAm8bL78n0uQl8DCbKipmA.png" /></figure><h3>Q: How to prepare?</h3><p>A: It’s easy. Take the “<a href="https://www.udemy.com/course/certified-kubernetes-application-developer/">Kubernetes Certified Application Developer (CKAD) with Tests</a>” course. It comes with an amazing testing platform.</p><h3>My notes, suggestions, tips and tricks for taking the exam</h3><ol><li>The exam time countdown will start right after you are done with sharing your screens and showing your room to your proctor. Be ready to start answering the questions right away.</li><li>It will be a help/tips mode at the very beginning of the exam. It explains how to use the exam interface. Do not spend a lot of time there, go to the questions right away, your time is already ticking.</li><li>Exact time tracking is on you. Use a provided notepad to write down when did you start. Expect a proctor ending your exam exactly 2 hours after that.</li><li>Some questions have lengthy descriptions. I have found that it’s important to separate some general information from action items and work on action items. It’s not enough time to understand all considerations about what should be built, but rather important to start building what is required. I would suggest to skip lengthy questions with low rank and come back to them later.</li><li>Some questions have multiple steps, I suggest to quickly read them all before taking any actions. In some cases. I have found it beneficial to see the full picture before going ahead and building objects.</li><li>The exam is running on Kubernetes v 1.18. One of the major differences is that “kubectl run nginx — image=nginx” creates a POD, not a Deployment as before. Use “kubectl create deployment nginx — image=nginx” instead, but make sure that you are aware of command line parameters available for “create deployment” command. Here are the details: <a href="https://github.com/kubernetes/kubernetes/pull/87077">https://github.com/kubernetes/kubernetes/pull/87077</a>. Note, that this tip was written some time ago and version of Kubernetes used in the testing environment might be different.</li><li>Create an alias for ‘k’ to use instead of ‘kubectl’. Then enable autocomplete on it. Here are the commands: “alias k=kubectl; source &lt;(kubectl completion bash); source &lt;(k completion bash | sed s/kubectl/k/g)”</li><li>During the exam, we are allowed to use <a href="http://discuss.kubernetes.io/">discuss.kubernetes.io</a>. You can find a lot of stuff there, but more importantly, you can upload yours. For instance, you can create a post with your favorite vi configuration, e.g. <a href="https://discuss.kubernetes.io/t/kubectl-tips-and-tricks/192/58">https://discuss.kubernetes.io/t/kubectl-tips-and-tricks/192/58</a></li><li>Learn how to test NetworkPolicy changes and services you have built. ‘curl &lt;ip&gt;:&lt;port&gt; works’.</li><li>Create your bookmarks and make sure you know what is behind them. Sometimes, copying YAML is faster than building objects via imperative commands.</li><li>Make sure that you went through all <a href="https://github.com/dgkanatsios/CKAD-exercises">https://github.com/dgkanatsios/CKAD-exercises</a> exercises and remember all required commands or have respective bookmarks.</li><li>Mark what questions and done and, more importantly, what did you skip and unfinished. I have a long list of questions with my notes for everyone. I found it would be better to separate what I have not finished into a different list. That would give better visibility.</li><li>Every question has a weight, it is a percentage of the total 100%. The average question is 5%. I suggest skipping questions with 2–3% percent and make sure that “&gt;10%” questions are done.</li><li>As everybody says, do not get stuck, skip, and get back to the question from the very begging.</li></ol><p><em>I have taken the exam on May 1, 2020</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e31ccce7416" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>