<?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 kcansiz on Medium]]></title>
        <description><![CDATA[Stories by kcansiz on Medium]]></description>
        <link>https://medium.com/@mustafakagancansiz?source=rss-64945ef5c510------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TviQviLCcJAAXkkL0rUMyg.jpeg</url>
            <title>Stories by kcansiz on Medium</title>
            <link>https://medium.com/@mustafakagancansiz?source=rss-64945ef5c510------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 21:08:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mustafakagancansiz/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[Hashicorp Vault in HA Raft Mode with GCPCKMS on GKE]]></title>
            <link>https://blog.devops.dev/hashicorp-vault-in-ha-raft-mode-with-gcpckms-on-gke-a448c109d7e5?source=rss-64945ef5c510------2</link>
            <guid isPermaLink="false">https://medium.com/p/a448c109d7e5</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud-kms]]></category>
            <category><![CDATA[hashicorp-vault]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[hashicorp]]></category>
            <dc:creator><![CDATA[kcansiz]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 10:02:13 GMT</pubDate>
            <atom:updated>2024-03-26T06:33:54.093Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Vault?</h3><p>HashiCorp Vault is an identity-based secrets and encryption management system. A <em>secret</em> is anything that you want to tightly control access to, such as API encryption keys, passwords, and certificates. Vault provides encryption services that are gated by authentication and authorization methods. Using Vault’s UI, CLI, or HTTP API, access to secrets and other sensitive data can be securely stored and managed, tightly controlled (restricted), and auditable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zMpJszmdEC4b_5E7Y8E-1g.png" /></figure><h3>Seal/Unseal</h3><p>When a Vault server is started, it starts in a <em>sealed</em> state. In this state, Vault is configured to know where and how to access the physical storage, but doesn’t know how to decrypt any of it.</p><p><em>Unsealing</em> is the process of obtaining the plaintext root key necessary to read the decryption key to decrypt the data, allowing access to the Vault.</p><p>Prior to unsealing, almost no operations are possible with Vault. For example authentication, managing the mount tables, etc. are all not possible. The only possible operations are to unseal the Vault and check the status of the seal.</p><h3>Integrated storage (Raft) backend</h3><p>The Integrated Storage backend is used to persist Vault’s data. Unlike other storage backends, Integrated Storage does not operate from a single source of data. Instead all the nodes in a Vault cluster will have a replicated copy of Vault’s data. Data gets replicated across all the nodes via the <a href="https://raft.github.io/">Raft Consensus Algorithm</a>.</p><p>These definitions are from hashicorp’s website <a href="https://developer.hashicorp.com/vault/docs/what-is-vault">https://developer.hashicorp.com/vault/docs</a>. You might check it if you decided to use Hashicorp Vault.</p><p>In this article I will setup vault in HA Raft Mode and then show how to activate GCPCKMS (in most cloud platforms it is available) using helm step by step.</p><p>CKMS is a method that auto-unseal Vault servers when it turns to be seal.</p><h3>Steps</h3><p>1- Creating a SA in GCP and Give Correct Permissions to SA</p><p>2- Investigate Helm Files</p><p>3- Deploy Helm to GKE Cluster</p><p>4- Discussion</p><h3>1- Creating a SA in GCP and Give Correct Permissions to SA</h3><p>Firstly we need to go to Google Cloud Console and hit to IAM&amp;Admin &gt; Service Accounts and create a Service Account. Give it a name like kms-vault-sa.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*hBcri2D-N2rG_kEp5X641w.png" /></figure><p>Then give it Cloud KMS Crypto Operator permission to manage unseal keys. It will automatically manage keys and never give keys to anyone including you. :)</p><p>Therefore, after these operations your KMS SA is ready. However, we need to create a key to access to KMS SA. Go to Console and click your SA. Then click ‘keys’ tab, create its key to interact it with our GKE Cluster. We will insert it as Kubernetes Secret in vault namespace.</p><pre>$ kubectl create ns vault<br>$ kubectl create secret generic kms-sa --from-file your-sa-key.json -n vault</pre><p>Then turn back to Google Cloud and create kms. Navigate to Security &gt; Key Management &gt; Create Key Ring. Create your key ring and then create a crypto key using it.</p><p>Congrats! You are now ready to deploy vault server.</p><h3>2- Investigate Helm Files</h3><p>Firstly, we need to clone Hashicorp Vault’s helm files. Just because Hashicorp does not enable us to clone its files using ‘helm pull’, we will clone its repository from its github website.</p><pre>git clone https://github.com/hashicorp/vault-helm.git</pre><p>After runnning this command, it will clone repo to terminal’s destination. Here we can see it as a zip. Unzip it:</p><pre>unzip vault-helm-0.27.0.zip</pre><p>Then when you ‘ls’ you will see vault-helm-0.27.0 unzipped folder.</p><pre>cd vault-helm-0.27.0 &amp;&amp; code .</pre><p>I opened it my favorite tool Visual Studio Code. You can open it whatever you feel comfy.</p><p>Here we will go and look to ‘values.yaml’ of this helm chart. There are three options to deploy a vault server ‘dev’, ‘HA’ and ‘HA Raft’. If you wish to try dev and HA feel free to try. However, this article will deploy HA Raft because Raft offers us to create backups, does not need any storage like Consul and allows us to use one pod leads to other pods. Other pods will not serve as vault server. Because there is a leader and followers in this mode.</p><p>In order to not ruin cloned helm chart or use it with different specifications, we will use another ‘values.yaml’ which you might name it like ‘values.raft.yaml’. It will override ‘values.yaml’ but will still use its default values. Let’s create values.raft.yaml and then investigate.</p><pre>global:<br>  enabled: true<br><br>server:<br>  extraEnvironmentVars:<br>    GOOGLE_REGION: YOUR_REGION<br>    GOOGLE_PROJECT: YOUR_PROJECT_ID<br>    GOOGLE_APPLICATION_CREDENTIALS: /vault/userconfig/kms-sa/your-sa-key.json  <br><br>  extraVolumes:<br>    - type: &#39;secret&#39;<br>      name: &#39;kms-sa&#39; <br><br>  image:<br>    repository: &quot;hashicorp/vault&quot;<br>    tag: &quot;1.11&quot;<br>    pullPolicy: IfNotPresent      <br><br>  ha:<br>    enabled: true<br>    <br>    raft:  <br>      enabled: true  <br>      config: |<br>        ui = true<br>  <br>        listener &quot;tcp&quot; {<br>          tls_disable = 1<br>          address = &quot;[::]:8200&quot;<br>          cluster_address = &quot;[::]:8201&quot;<br>        }<br>  <br>        seal &quot;gcpckms&quot; {<br>          project     = &quot;YOUR_PROJECT_ID&quot;<br>          region      = &quot;YOUR_REGION&quot;<br>          key_ring    = &quot;YOUR_KEY_RING&quot;<br>          crypto_key  = &quot;YOUR_CRYPTO_KEY&quot;<br>        }<br>  <br>        storage &quot;raft&quot; {<br>          path = &quot;/vault/data&quot;<br>        }  </pre><p>This yaml overrides:</p><ul><li>extraEnvVariables and extraVolumes to give helm chart to use Cloud Credentials.</li><li>image to use server image which is properly works with KMS. (might ask why ‘proper’. You need to check Discussion section :) )</li><li>seal to use ‘Key Ring’ and ‘Crypto Key’.</li><li>storage ‘raft’ enables us to use vault’s storage.</li><li>Others are defaults.</li></ul><p>Running Successfully!</p><h3>3- Deploy Helm to GKE Cluster</h3><p>There are plenty of way to deploy helm charts to Kubernetes Clusters. You might use Helm CLI, Rancher UI, ArgoCD etc. Actually I use ArgoCD to deploy helm charts to Kubernetes Clusters. However, just because this is for Vault but not GitOps, I will show how to deploy it using Helm CLI.</p><p>I guess that your computer has kube config to your cluster and able to run kubectl and helm commands. Let’s deploy your helm chart. You need to cd to your helm chart and values.yaml’s directory. You run:</p><pre>helm install . --values values.raft.yaml -n vault</pre><p>It will successfully deploy hashicorp vault in vault namespace to your GKE Cluster. Then you need to wait for vault pods to be ready. While it turns to be ready let’s interact with vault-server pod using:</p><pre>kubectl exec -it vault-server-0 -n vault -- bash</pre><p>Then inside pod only one thing you will do is:</p><pre>vault operator init</pre><p>It will successfully init your raft server. You will see it is healthy and running. Then login using Initial Root Token:</p><pre>vault login YOUR_TOKEN_HERE</pre><p>After login check the server status and list joined nodes. (we have not deployed other nodes yet.)</p><pre>vault operator raft list-peers</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMmpS1JIRUku1Ca7BFBqlw.png" /></figure><p>Then need to join other nodes to our leader. Let’s interact with other pods and join to leader. Execute shell and run commands for each follower:</p><pre>vault operator raft join http://vault-dev-0.vault-dev-internal:8200</pre><p>You should see that all your nodes (pods) are healthy and running. Let’s check the current situation by:</p><pre>vault operator raft list-peers</pre><p>and see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JZrt2IHRslV3359ILjZpGg.png" /></figure><p>Finally we successfully deployed Vault Server in HA Raft. You might check using an ingress to see ui.</p><h3>4- Discussion</h3><p>I want to discuss the pros and cons in this section.</p><p>Pros:</p><ul><li>Raft enables us to have snapshots. (see: <a href="https://developer.hashicorp.com/vault/docs/commands/operator/raft">https://developer.hashicorp.com/vault/docs/commands/operator/raft</a>)</li><li>GCPCKMS or Cloud KMS allows us to automatize our unseal progress. Best example for this is if there is a problem and vault turns to unsealt in shamir mode you need to go and unseal all nodes you have using recovery keys. However, Cloud KMS handles it automatically.</li></ul><p>Cons:</p><ul><li>Hashicorp does not have stable helm charts for Vault. I want to go deeper.</li></ul><p>When you pull helm chart and see values.yaml it shows that you can see under server.ha.config (there is nothing for raft). There is seal configs by default. However, if you try to activate it from here it will never works because default vault server image does not work properly. That is why I used older image to make it work. Check my open issue in github: <a href="https://github.com/hashicorp/vault-helm/issues/1000">https://github.com/hashicorp/vault-helm/issues/1000</a></p><ul><li>Cannot use latest developments in server image because cannot use latest image with GCPCKMS.</li></ul><p>Mustafa Kağan Cansız - DevOps Engineer</p><p><a href="https://www.linkedin.com/in/mkcansiz/">https://www.linkedin.com/in/mkcansiz/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a448c109d7e5" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/hashicorp-vault-in-ha-raft-mode-with-gcpckms-on-gke-a448c109d7e5">Hashicorp Vault in HA Raft Mode with GCPCKMS on GKE</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>