<?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 Kushal Ludhwani on Medium]]></title>
        <description><![CDATA[Stories by Kushal Ludhwani on Medium]]></description>
        <link>https://medium.com/@ksh.ludhwani?source=rss-4dda0c2c2c06------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kua-ecatVy-kgtTV</url>
            <title>Stories by Kushal Ludhwani on Medium</title>
            <link>https://medium.com/@ksh.ludhwani?source=rss-4dda0c2c2c06------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:45:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ksh.ludhwani/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[Managing TLS and Secrets in OpenShift using Vault and External Secret Operator — Part 2]]></title>
            <link>https://medium.com/@ksh.ludhwani/managing-tls-and-secrets-in-openshift-using-vault-and-external-secret-operator-part-2-adf69247005c?source=rss-4dda0c2c2c06------2</link>
            <guid isPermaLink="false">https://medium.com/p/adf69247005c</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[external-secrets-operator]]></category>
            <category><![CDATA[hashicorp-vault]]></category>
            <category><![CDATA[vault]]></category>
            <category><![CDATA[certification]]></category>
            <dc:creator><![CDATA[Kushal Ludhwani]]></dc:creator>
            <pubDate>Thu, 01 May 2025 03:39:14 GMT</pubDate>
            <atom:updated>2025-05-01T03:39:14.406Z</atom:updated>
            <content:encoded><![CDATA[<h3>Managing TLS and Secrets in OpenShift using Vault and External Secret Operator — Part 2</h3><p>In <a href="https://medium.com/@ksh.ludhwani/managing-tls-and-secrets-in-openshift-using-vault-and-external-secret-operator-part-1-7d471c6133cc">Part 1</a>, we successfully set up HashiCorp Vault as our Certificate Authority (CA) and prepared the environment to securely manage TLS certificates and secrets in OpenShift.</p><p>In this Part 2, we will move forward by <strong>deploying the External Secrets Operator (ESO)</strong> in our OpenShift cluster. ESO will act as a bridge, enabling OpenShift to <strong>synchronize secrets from Vault directly into Kubernetes Secrets</strong>. We will use <strong>Helm</strong> to install and configure ESO efficiently.</p><h3>1. Installing External Secrets Operator using Helm</h3><p>We will use the official external-secrets Helm chart to install ESO.</p><p>First, add the Helm repository:</p><pre>helm repo add external-secrets https://charts.external-secrets.io<br>helm repo update</pre><p>Create a namespace for ESO if not already created:</p><pre>oc create namespace external-secrets<br>namespace/external-secrets created</pre><p>Now, install ESO using Helm:</p><pre>helm install external-secrets external-secrets/external-secrets \<br>  --namespace external-secrets \<br>  --set installCRDs=true<br><br>NAME: external-secrets<br>LAST DEPLOYED: Tue Apr 29 00:13:00 2025<br>NAMESPACE: external-secrets<br>STATUS: deployed<br>REVISION: 1<br>TEST SUITE: None<br>NOTES:<br>external-secrets has been deployed successfully in namespace external-secrets!<br><br>In order to begin using ExternalSecrets, you will need to set up a SecretStore<br>or ClusterSecretStore resource (for example, by creating a &#39;vault&#39; SecretStore).<br><br>More information on the different types of SecretStores and how to configure them<br>can be found in our Github: https://github.com/external-secrets/external-secrets</pre><h4>Verifying the ESO Deployment</h4><p>Check if pods are running:</p><pre>oc get pods -n external-secrets<br>NAME                                                READY   STATUS    RESTARTS   AGE<br>external-secrets-84c7946cc7-sv5cs                   1/1     Running   0          3m13s<br>external-secrets-cert-controller-657c475876-kxq74   1/1     Running   0          3m13s<br>external-secrets-webhook-86549fccd8-n2hbl           1/1     Running   0          3m13s</pre><p>Confirm CRDs are installed:</p><pre>oc get crd | grep externalsecret<br>clusterexternalsecrets.external-secrets.io                        2025-04-28T20:13:01Z<br>externalsecrets.external-secrets.io                               2025-04-28T20:13:01Z</pre><h3>2. Understanding Key ESO Concepts</h3><p>Before we proceed with connecting Vault and fetching secrets, it’s important to briefly understand the key concepts behind External Secrets Operator (ESO). This will help us build a clear mental model of how ESO works inside OpenShift.</p><h4>🔹 SecretStore and ClusterSecretStore</h4><ul><li><strong>SecretStore</strong> and <strong>ClusterSecretStore</strong> are custom Kubernetes resources created by ESO.</li><li>They define <strong>where</strong> and <strong>how</strong> to connect to an external secrets management system, such as Vault.</li><li><strong>SecretStore</strong> is <strong>namespace-scoped</strong>:<br> It allows applications inside a specific namespace to fetch secrets.</li><li><strong>ClusterSecretStore</strong> is <strong>cluster-scoped</strong>:<br> It allows applications from <strong>any namespace</strong> to fetch secrets using a central connection configuration.</li></ul><p>In our setup, since multiple applications across different namespaces might need secrets, we will create a <strong>ClusterSecretStore</strong> for Vault.</p><h4>🔹 ExternalSecret</h4><ul><li><strong>ExternalSecret</strong> is another custom resource that defines <strong>what secret</strong> to fetch from the external provider and <strong>how</strong> to store it as a native Kubernetes Secret.</li><li>It references a SecretStore or ClusterSecretStore to know <strong>where</strong> to fetch the secret from.</li><li>It also specifies <strong>which keys</strong> from the external secret store should be fetched and <strong>what Kubernetes Secret</strong> should be created.</li></ul><h4>🔹 How the Pieces Fit Together</h4><p>Here’s a simple flow:</p><pre>+-------------------+<br>|   HashiCorp Vault |<br>| (Secrets Manager) |<br>+---------+---------+<br>          |<br>          v<br>+--------------------------+<br>|    ClusterSecretStore    |<br>| (Connection Configuration)|<br>+---------+----------------+<br>          |<br>          v<br>+--------------------------+<br>|      ExternalSecret      |<br>| (Request Specific Secret) |<br>+---------+----------------+<br>          |<br>          v<br>+--------------------------+<br>|     Kubernetes Secret    |<br>| (Created Automatically)  |<br>+--------------------------+</pre><ul><li>🔵 <strong>Vault</strong>: Source of truth for secrets.</li><li>🟢 <strong>ClusterSecretStore</strong>: Configuration to connect Vault → OpenShift.</li><li>🟡 <strong>ExternalSecret</strong>: What to fetch from Vault.</li><li>🟠 <strong>Kubernetes Secret</strong>: Native object created inside the cluster</li></ul><h3>3. Preparing Vault for External Secrets Operator Access</h3><p>Before we can create the ClusterSecretStore in OpenShift, we need to prepare Vault to allow secure, read-only access for External Secrets Operator (ESO).</p><p>This involves two key steps:</p><ol><li><strong>Creating a Vault Policy</strong> that grants read access to secrets stored in the KV engine.</li><li><strong>Creating an AppRole</strong> that uses this policy for authentication.</li><li>Create a KV to store out secrets.</li></ol><h4>Step 1: Create a Vault Policy for ESO</h4><p>First, let’s define a minimal policy that allows ESO to <strong>read</strong> and <strong>list</strong> secrets under a specific Vault path.</p><p>Create a file called vault-policy-eso-reader.hcl:</p><pre># vault-policy-eso-reader.hcl<br><br>path &quot;ipi/*&quot; {<br>  capabilities = [&quot;read&quot;, &quot;list&quot;]<br>}</pre><p>This policy grants:</p><ul><li>read permission to fetch secret values.</li><li>list permission to enumerate keys under the ipi/ path.</li></ul><p>This follows the principle of least privilege — ESO can only read secrets it needs, and nothing more.</p><pre># vault policy write eso-reader vault-policy-eso-reader.hcl<br>Success! Uploaded policy: eso-reader</pre><p>You should now see a new policy named eso-reader available in Vault.</p><h4>Step 2: Create an AppRole for ESO</h4><p>Next, create a new AppRole that will be used by ESO to authenticate to Vault.</p><p>Run the following command:</p><pre>vault write auth/approle/role/eso-role \<br>    token_policies=&quot;eso-reader&quot; \<br>    token_ttl=24h \<br>    token_max_ttl=72h</pre><ul><li>This AppRole will issue tokens that inherit the eso-reader policy.</li><li>Tokens will have a default lifetime of 24 hours and can be renewed up to 72 hours.</li></ul><h4>Step 3: Retrieve Role ID and Secret ID</h4><p>External Secrets Operator needs two pieces of information to authenticate:</p><ul><li><strong>Role ID</strong>: A static identifier for the AppRole.</li><li><strong>Secret ID</strong>: A one-time or renewable secret to complete login.</li></ul><pre>vault read auth/approle/role/eso-role/role-id</pre><p>Generate a Secret ID:</p><pre>vault write -f auth/approle/role/eso-role/secret-id</pre><p>Save these values carefully — they will be referenced later when configuring the ClusterSecretStore.</p><h3>4. Configuring ClusterSecretStore/External Secret for Vault</h3><p>With External Secrets Operator (ESO) installed, the next step is to create a ClusterSecretStore resource. This object will configure the connection between ESO running in OpenShift and our Vault server.</p><p>In this setup, we will authenticate to Vault using the <strong>AppRole</strong> authentication method — a secure way to allow machine-to-machine access without hardcoding Vault tokens.</p><h4>Storing Vault Secret ID in Kubernetes</h4><p>After retrieving the <strong>Secret ID</strong> from Vault, we need to store it securely inside OpenShift as a Kubernetes Secret.<br> External Secrets Operator (ESO) will use this secret to authenticate against Vault via AppRole.</p><p>You can create the Kubernetes Secret using the following command:</p><pre># oc create secret generic vault-approle-secret --from-literal=secretId=af31b437-11eb-858a-e3aa-9923999a0182 -n external-secrets<br>secret/vault-approle-secret created</pre><h4>Important Points:</h4><ul><li>The key must be named exactly secretId because that’s what we reference later in the ClusterSecretStore configuration.</li><li>Ensure the Secret is created in the <strong>same namespace</strong> where ESO expects to find it (in this case, external-secrets).</li></ul><h4>Creating the Kubernetes Secret for Vault CA</h4><p>Before applying the ClusterSecretStore, you must create a Kubernetes Secret that contains the Vault CA certificate.</p><p>You can create it using the following command:</p><pre># oc create secret generic vault-ca-cert   --from-file=ca.crt=ca.crt   -n external-secrets<br>secret/vault-ca-cert created</pre><h4>Create ClusterSecretStore for Vault</h4><p>Below is the cluster-secret-store.yaml definition:</p><pre>apiVersion: external-secrets.io/v1beta1<br>kind: ClusterSecretStore<br>metadata:<br>  name: vault-cluster-secretstore<br>spec:<br>  provider:<br>    vault:<br>      server: https://vault.test.lan<br>      path: ipi<br>      version: v2<br>      caProvider:<br>        type: Secret<br>        name: vault-ca-cert<br>        key: ca.crt<br>        namespace: external-secrets<br>      auth:<br>        appRole:<br>          path: approle<br>          roleId: f0a2184f-f81a-5bfe-0750-257692ead5a4<br>          secretRef:<br>            name: vault-approle-secret<br>            key: secretId<br>            namespace: external-secrets</pre><p>Apply the yaml:</p><pre># oc  get clustersecretstore<br>NAME                        AGE   STATUS   CAPABILITIES   READY<br>vault-cluster-secretstore   13s   Valid    ReadWrite      True</pre><p><strong>Breaking Down the YAML</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19b9d310d806ea312f65a2c7ddec3623/href">https://medium.com/media/19b9d310d806ea312f65a2c7ddec3623/href</a></iframe><p><strong>Creating a Secret in Vault Before Defining ExternalSecret</strong></p><h4>Create a Secret in Vault</h4><p>Let’s create a secret under the ipi/ path in Vault.</p><p>Example command:</p><pre># vault kv put ipi/myapp/credentials username=admin password=StrongP@ssword123<br>======= Secret Path =======<br>ipi/data/myapp/credentials<br><br>======= Metadata =======<br>Key                Value<br>---                -----<br>created_time       2025-04-29T18:36:00.216152996Z<br>custom_metadata    &lt;nil&gt;<br>deletion_time      n/a<br>destroyed          false<br>version            3</pre><h4>Defining an ExternalSecret in OpenShift</h4><p>Now that the secret exists in Vault, we can create an ExternalSecret that will pull it into OpenShift as a native Secret.</p><p>Here’s a sample ExternalSecret manifest:</p><pre>apiVersion: external-secrets.io/v1beta1<br>kind: ExternalSecret<br>metadata:<br>  name: myapp-secret<br>  namespace: default<br>spec:<br>  refreshInterval: 1h<br>  secretStoreRef:<br>    name: vault-cluster-secretstore<br>    kind: ClusterSecretStore<br>  target:<br>    name: myapp-creds<br>    creationPolicy: Owner<br>  data:<br>    - secretKey: db-username<br>      remoteRef:<br>        key: myapp/credentials<br>        property: username<br>    - secretKey: db-password<br>      remoteRef:<br>        key: myapp/credentials<br>        property: password</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83c7218ad2f4ce24fd1bf8c8bdf1b7ea/href">https://medium.com/media/83c7218ad2f4ce24fd1bf8c8bdf1b7ea/href</a></iframe><p>Validate external Secret and secret</p><pre># oc get externalsecret<br>NAME           STORETYPE            STORE                       REFRESH INTERVAL   STATUS         READY<br>myapp-secret   ClusterSecretStore   vault-cluster-secretstore   1h                SecretSynced   True<br><br># oc get secret<br>NAME          TYPE     DATA   AGE<br>myapp-creds   Opaque   2      3m54s<br><br># oc get secret myapp-creds -o yaml<br>apiVersion: v1<br>data:<br>  db-password: U3Ryb25nUEBzc3dvcmQxMjM=<br>  db-username: YWRtaW4=<br>kind: Secret<br>metadata:<br>  annotations:<br>    kubectl.kubernetes.io/last-applied-configuration: |<br>      {&quot;apiVersion&quot;:&quot;external-secrets.io/v1beta1&quot;,&quot;kind&quot;:&quot;ExternalSecret&quot;,&quot;metadata&quot;:{&quot;annotations&quot;:{},&quot;name&quot;:&quot;myapp-secret&quot;,&quot;namespace&quot;:&quot;default&quot;},&quot;spec&quot;:{&quot;data&quot;:[{&quot;remoteRef&quot;:{&quot;key&quot;:&quot;myapp/credentials&quot;,&quot;property&quot;:&quot;username&quot;},&quot;secretKey&quot;:&quot;db-username&quot;},{&quot;remoteRef&quot;:{&quot;key&quot;:&quot;myapp/credentials&quot;,&quot;property&quot;:&quot;password&quot;},&quot;secretKey&quot;:&quot;db-password&quot;}],&quot;refreshInterval&quot;:&quot;1h&quot;,&quot;secretStoreRef&quot;:{&quot;kind&quot;:&quot;ClusterSecretStore&quot;,&quot;name&quot;:&quot;vault-cluster-secretstore&quot;},&quot;target&quot;:{&quot;creationPolicy&quot;:&quot;Owner&quot;,&quot;name&quot;:&quot;myapp-creds&quot;}}}<br>    reconcile.external-secrets.io/data-hash: a953a924acc8ef1d740a5005e8b05ae5<br>  creationTimestamp: &quot;2025-04-29T18:36:17Z&quot;<br>  labels:<br>    reconcile.external-secrets.io/created-by: 1da4bd740fbc7f92e3a91db384778736<br>    reconcile.external-secrets.io/managed: &quot;true&quot;<br>  name: myapp-creds<br>  namespace: default<br>  ownerReferences:<br>  - apiVersion: external-secrets.io/v1<br>    blockOwnerDeletion: true<br>    controller: true<br>    kind: ExternalSecret<br>    name: myapp-secret<br>    uid: 688165b5-346a-4645-b528-1c481306ae2d<br>  resourceVersion: &quot;395008&quot;<br>  uid: 3ad845a6-0297-486f-9f50-9c57aa11cc60<br>type: Opaque</pre><h3><strong>5. Real-World Example 1: Use ESO Secret in a Pod</strong></h3><p>Now that ESO has created a Kubernetes Secret, let’s mount it into a Pod.</p><p>Sample Pod Manifest:</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: myapp-test<br>  namespace: default<br>spec:<br>  containers:<br>    - name: test-container<br>      image: busybox<br>      command: [ &quot;sleep&quot;, &quot;3600&quot; ]<br>      volumeMounts:<br>        - name: creds<br>          mountPath: /etc/creds<br>          readOnly: true<br>  volumes:<br>    - name: creds<br>      secret:<br>        secretName: myapp-creds</pre><h4>What This Does:</h4><ul><li>Mounts the myapp-creds Secret (created by ESO) to /etc/creds in the container.</li><li>You’ll find:</li><li>/etc/creds/db-username</li><li>/etc/creds/db-password</li></ul><p>Run this Pod and exec into it to test:</p><pre># oc exec -it myapp-test -- cat /etc/creds/db-username<br>admin<br># oc exec -it myapp-test -- cat /etc/creds/db-password<br>StrongP@ssword123</pre><p>Note: If credentials are updated in vault it will automatically updated in kubernetes secret, Because of <strong>refreshInterval: 1h </strong>in externalsecret definition.</p><h3>6. Real-World Example 2: Replacing OpenShift API Server Certificate Using cert-manager and Vault</h3><p>In enterprise environments, it is common to replace the default OpenShift API server certificate with a <strong>custom TLS certificate</strong> issued by your organization’s Certificate Authority.</p><p>In our setup, we will use <strong>cert-manager</strong> (configured with Vault as the backend CA ) to issue a certificate and then configure the OpenShift API server to use it.</p><h4>Step 1: Issue a Certificate from Vault</h4><p>Here’s a sample Certificate resource from cert-manager that gets a cert from Vault using vault Issuer.</p><pre>apiVersion: cert-manager.io/v1<br>kind: Certificate<br>metadata:<br>  name: api-tls-certs<br>  namespace: openshift-config<br>spec:<br>  secretName: api-tls<br>  issuerRef:<br>    name: vault-issuer<br>    kind: ClusterIssuer<br>  commonName: api.ipi.test.lan<br>  dnsNames:<br>  - api.ipi.test.lan</pre><p>Apply Yaml and validate certificate:</p><pre># oc apply -f api-cert.yaml<br>certificate.cert-manager.io/api-tls-certs created<br><br># oc get cert -n openshift-config<br>NAME            READY   SECRET    AGE<br>api-tls-certs   True    api-tls   11s</pre><p>Step 2: Patch OpenShift API to Use the New Certificate</p><p>use the following oc patch command:</p><pre># oc patch apiserver cluster --type=merge -p &#39;{&quot;spec&quot;:{&quot;servingCerts&quot;:{&quot;namedCertificates&quot;:[{&quot;names&quot;:[&quot;api.ipi.test.lan&quot;],&quot;servingCertificate&quot;:{&quot;name&quot;:&quot;api-tls&quot;}}]}}}&#39;<br>apiserver.config.openshift.io/cluster patched</pre><h3>Conclusion</h3><p>In this two-part series, we built a <strong>secure and automated secret management solution</strong> for OpenShift by combining the strengths of:</p><ul><li><strong>Vault</strong> as a robust Certificate Authority (CA) and Secrets Manager.</li><li><strong>cert-manager</strong> to automate certificate issuance and renewal.</li><li><strong>External Secrets Operator (ESO)</strong> to synchronize secrets from Vault directly into Kubernetes.</li></ul><p><strong>By integrating these components, we achieved:</strong></p><p><strong>Centralized Secret Management</strong>:<br>Secrets and certificates are no longer manually handled inside OpenShift — everything comes dynamically from Vault.</p><p><strong>Automated Certificate Lifecycle</strong>:<br>Using cert-manager and Vault, certificates such as the OpenShift API server certificate can be automatically issued, rotated, and renewed without manual intervention.</p><p><strong>Enhanced Security</strong>:<br>Credentials like Vault AppRole Secret IDs are securely stored in Kubernetes Secrets, and ESO ensures that secrets are refreshed at defined intervals.</p><p><strong>GitOps-Friendly</strong>:<br>All configurations — from Vault policies to ExternalSecret resources — can be managed through version-controlled manifests, enabling secure, auditable deployments</p><h3>🙌 Thank You!</h3><p>If you found this guide helpful, feel free to share it, leave a comment, or connect for more real-world OpenShift, Vault, and Kubernetes security tips.</p><h3>✍️ About Me</h3><p>I’m Kushal Ludhwani, a Senior DevOps Engineer who’s passionate about cloud-native technologies, Kubernetes, and OpenShift.<br> I love building secure, scalable platforms and making complex workflows around Vault, cert-manager, and External Secrets Operator simpler and more practical.<br> Through writing, I try to share real-world experiences and solutions that others can easily apply in their environments.<br> When I’m not working on infrastructure, I enjoy learning new tools, improving automation, and helping the community with hands-on technical guides.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adf69247005c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing TLS and Secrets in OpenShift using Vault and External Secret Operator Part 1]]></title>
            <link>https://medium.com/@ksh.ludhwani/managing-tls-and-secrets-in-openshift-using-vault-and-external-secret-operator-part-1-7d471c6133cc?source=rss-4dda0c2c2c06------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d471c6133cc</guid>
            <dc:creator><![CDATA[Kushal Ludhwani]]></dc:creator>
            <pubDate>Thu, 24 Apr 2025 18:50:11 GMT</pubDate>
            <atom:updated>2025-04-24T18:50:11.318Z</atom:updated>
            <content:encoded><![CDATA[<p>In my previous article, we set up a secure HashiCorp Vault server using Docker and Docker Compose. Now that our Vault is running with HTTPS and Raft storage, it’s time to unlock its real power.</p><p>In this article, we’ll take a hands-on approach to enabling the <strong>PKI secrets engine</strong> for certificate management, configuring <strong>AppRole authentication</strong> for secure and automated access, and finally integrating Vault with <strong>External Secrets Operator (ESO)</strong> to sync secrets directly into OpenShift workloads — securely and automatically.</p><p>By the end, you’ll have a fully integrated, GitOps-friendly secrets management pipeline that works seamlessly within your Kubernetes or OpenShift environment.</p><h3>1. Prerequisites</h3><ul><li>A running <a href="https://medium.com/@ksh.ludhwani/setup-hashicorp-vault-using-docker-825b3e11ad2b">Vault server</a></li><li>Vault initialized and unsealed</li><li>TLS configured for Vault</li><li>OpenShift or Kubernetes cluster access</li><li>vault CLI installed and access to the Vault container</li></ul><h3>2. <strong>Enable and Configure the PKI Secrets Engine</strong></h3><p>With Vault up and running, we can now enable the <strong>PKI secrets engine</strong> to issue TLS certificates internally — ideal for securing services within your Kubernetes/OpenShift cluster.</p><p>We’ll enable the engine at a custom path, configure it with a self-signed root CA, and define roles to manage certificate issuance.</p><h4>Set Vault Environment Variables</h4><p>Before interacting with Vault via CLI, export the environment variables so that vault commands know where to connect and how to authenticate.</p><pre># export VAULT_ADDR=https://vault.test.lan<br># export VAULT_TOKEN=hvs.V4i9iN3XOldc89F4wRC8WITM<br># vault status<br>Key                     Value<br>---                     -----<br>Seal Type               shamir<br>Initialized             true<br>Sealed                  false<br>Total Shares            5<br>Threshold               3<br>Version                 1.19.1<br>Build Date              2025-04-02T15:43:01Z<br>Storage Type            raft<br>Cluster Name            vault-cluster-89ad1d37<br>Cluster ID              f3c74392-343f-aa01-08d2-136f2a2d493d<br>Removed From Cluster    false<br>HA Enabled              true<br>HA Cluster              https://vault.test.lan:8201<br>HA Mode                 active<br>Active Since            2025-04-15T19:05:48.022388126Z<br>Raft Committed Index    13005<br>Raft Applied Index      13005</pre><h4>Enable and Configure the PKI Secrets Engine</h4><p>To manage internal certificates securely, we’ll configure Vault as a <strong>Certificate Authority (CA)</strong> by enabling its PKI secrets engine. This allows Vault to issue, sign, and manage TLS certificates.</p><h4>Step 1: Enable the PKI Secrets Engine</h4><p>We’ll mount the PKI secrets engine at a custom path pki_cert to avoid conflicts with default paths and to keep it scoped.</p><pre>vault secrets enable -path=pki_cert pki</pre><p>This command enables the PKI engine and mounts it at /pki_cert</p><h4>Step 2: Tune the TTL for Certificates</h4><p>Set the maximum time-to-live (TTL) for certificates issued from this secrets engine. In this case, we’re setting it to 10 years (87600h) for root certificates.</p><pre>vault secrets tune -max-lease-ttl=87600h pki_cert</pre><p>This ensures that any certificate issued by this mount can be valid for up to 10 years.</p><h4>Step 3: Generate the Root CA Certificate</h4><p>Now, generate a self-signed root certificate from Vault itself. This will serve as the root of trust for your internal certificate hierarchy.</p><pre>vault write pki_cert/root/generate/internal \<br>  common_name=&quot;vault-ca.test.lan&quot; \<br>  ttl=87600h \<br>  key_type=rsa \<br>  key_bits=4096</pre><ul><li>common_name: The CN for your root certificate.</li><li>ttl: Time the certificate will be valid for.</li><li>key_type and key_bits: Define the cryptographic key — RSA 4096 bits in this case for strong security.</li></ul><p><strong>Important</strong>: The output will include the generated certificate. Store it securely if you plan to distribute or trust it on other systems</p><h4>Step 4: Configure Issuing and CRL URLs</h4><p>Now that we have a root CA, let’s configure the URLs Vault will embed into the certificates it issues. These URLs help systems validate the certificates by pointing them to the issuing certificate and Certificate Revocation List (CRL).</p><pre># vault write pki_cert/config/urls \<br>  issuing_certificates=&quot;https://vault.test.lan/v1/pki_cert/ca&quot; \<br>  crl_distribution_points=&quot;https://vault.test.lan/v1/pki_cert/crl&quot;<br>Key                        Value<br>---                        -----<br>crl_distribution_points    [https://vault.test.lan/v1/pki_cert/crl]<br>enable_templating          false<br>issuing_certificates       [https://vault.test.lan/v1/pki_cert/ca]<br>ocsp_servers               []</pre><ul><li>issuing_certificates: This URL is where clients can retrieve the CA certificate that signed the leaf certificate.</li><li>crl_distribution_points: This URL points to the CRL where revoked certificates will be listed.</li></ul><p><strong>Note</strong>: These URLs must be reachable by any system that consumes certificates issued by Vault, especially for validation and revocation checking.</p><h4>Step 5: Create a Role for Certificate Issuance</h4><p>Roles in Vault’s PKI engine define the rules and constraints for issuing certificates. We’ll now create a role named cert-issuer that allows issuing certificates for the test.lan domain and its subdomains.</p><pre>vault write pki_cert/roles/cert-issuer \<br>  allowed_domains=&quot;test.lan&quot; \<br>  allow_subdomains=true \<br>  max_ttl=16800h \<br>  key_bits=2048 \<br>  require_cn=true</pre><p><strong>Explanation of Parameters</strong>:</p><ul><li>allowed_domains: Specifies the base domain the certificates can be issued for.</li><li>allow_subdomains=true: Allows issuing certificates for subdomains like app.test.lan or db.test.lan.</li><li>max_ttl: Maximum validity of issued certificates (here, ~2 years).</li><li>key_bits=2048: Sets the key size for issued certificates.</li><li>require_cn=true: Ensures that the Common Name (CN) must be explicitly provided when requesting a certificate.</li></ul><p>This role acts like a policy template — every certificate issued must match these criteria.</p><h4>Step 6: Issue a Certificate Using the Role</h4><p>Now that the role cert-issuer is configured, we can request a TLS certificate for a domain under test.lan. This example issues a certificate for web.test.lan.</p><pre>vault write -format=json pki_cert/issue/cert-issuer \<br>  common_name=&quot;web.test.lan&quot; \<br>  ttl=&quot;720h&quot; &gt; web.test.lan.json</pre><p>Then extract the components using jq:</p><pre>jq -r &#39;.data.certificate&#39; web.test.lan.json &gt; web.test.lan.crt<br>jq -r &#39;.data.private_key&#39; web.test.lan.json &gt; web.test.lan.key<br>jq -r &#39;.data.issuing_ca&#39; web.test.lan.json &gt; vault-ca.crt</pre><p>You’ll now have:</p><ul><li>web.test.lan.crt – the signed certificate</li><li>web.test.lan.key – the private key</li><li>vault-ca.crt – the CA certificate that signed it</li></ul><p>These files can be used in your web or internal services that require TLS.</p><h3>Integrate Vault with Cert Manager</h3><p>Managing TLS certificates manually in Kubernetes can be error-prone, time-consuming, and difficult to scale. Integrating <strong>HashiCorp Vault</strong> with <strong>cert-manager</strong> brings the best of both worlds — Vault’s strong security and cert-manager’s Kubernetes-native automation.</p><p>Here’s what you gain with this integration:</p><ul><li><strong>Centralized Certificate Authority</strong>: Vault acts as a single source of truth for issuing and revoking certificates.</li><li><strong>Automated Certificate Lifecycle</strong>: cert-manager renews certificates before they expire — zero downtime for apps.</li><li><strong>Kubernetes-Native Experience</strong>: Developers use CRDs like Certificate and Issuer—no need to touch Vault directly.</li><li><strong>Improved Security Posture</strong>: Short-lived, auto-rotating certificates with audit logging from Vault.</li><li><strong>Multi-Platform Compatibility</strong>: Works seamlessly across OpenShift, EKS, GKE, and other cloud-native platforms.</li></ul><p>With Vault as the backend and cert-manager handling the automation, you get an end-to-end TLS solution that is secure, scalable, and fully integrated into your OpenShift environment.</p><h4>Installing cert-manager on OpenShift using Helm</h4><h4>Prerequisites</h4><ul><li>Helm installed (helm version)</li><li>Access to OpenShift cluster (oc or kubectl)</li><li>OpenShift user with cluster-admin rights</li></ul><h4>Create the cert-manager namespace</h4><pre>oc create ns cert-manager<br>namespace/cert-manager created</pre><h4>Label the namespace to disable OpenShift’s default security policy</h4><p>This allows cert-manager’s web hooks to run properly:</p><pre>oc label namespace cert-manager cert-manager.io/disable-validation=true</pre><p>Note: Above step not required in case of other kubernetes environment. It is possible to store cert-manager using operatorHub with openShift</p><p><strong>Install cert-manager</strong></p><pre>helm install   cert-manager jetstack/cert-manager   --namespace cert-manager   --create-namespace   --version v1.17.2   --set crds.enabled=true<br>NAME: cert-manager<br>LAST DEPLOYED: Thu Apr 24 21:45:51 2025<br>NAMESPACE: cert-manager<br>STATUS: deployed<br>REVISION: 1<br>TEST SUITE: None<br>NOTES:<br>cert-manager v1.17.2 has been deployed successfully!<br><br>In order to begin issuing certificates, you will need to set up a ClusterIssuer<br>or Issuer resource (for example, by creating a &#39;letsencrypt-staging&#39; issuer).<br><br>More information on the different types of issuers and how to configure them<br>can be found in our documentation:<br><br>https://cert-manager.io/docs/configuration/<br><br>For information on how to configure cert-manager to automatically provision<br>Certificates for Ingress resources, take a look at the `ingress-shim`<br>documentation:<br><br>https://cert-manager.io/docs/usage/ingress/</pre><p><strong>Verify installation</strong></p><pre>oc get pods -n cert-manager<br>NAME                                      READY   STATUS    RESTARTS   AGE<br>cert-manager-7d94968567-5k9tm             1/1     Running   0          2m46s<br>cert-manager-cainjector-d476f4bcd-tjvzj   1/1     Running   0          2m46s<br>cert-manager-webhook-87964448f-gb5ld      1/1     Running   0          2m46s</pre><p><strong>Enabling AppRole Authentication for cert-manager in Vault</strong></p><p>To allow cert-manager to securely request TLS certificates from Vault, we’ll configure Vault to use <strong>AppRole authentication</strong>. AppRole provides a flexible way to authenticate applications without needing human interaction or static tokens.</p><h4>Enable AppRole auth method</h4><pre>vault auth enable approle</pre><h4>Define the policy for cert-manager</h4><p>Create a policy that allows cert-manager to sign certificates, issue them, and read the CA chain.</p><p>cert-manager-policy.hcl:</p><pre># Allow cert-manager to issue certificates using this role<br>path &quot;pki_cert/sign/cert-manager&quot; {<br>  capabilities = [&quot;create&quot;, &quot;update&quot;, &quot;read&quot;]<br>}<br><br># Also allow issuing via /issue endpoint<br>path &quot;pki_cert/issue/cert-manager&quot; {<br>  capabilities = [&quot;create&quot;, &quot;update&quot;, &quot;read&quot;]<br>}<br><br># Allow reading the CA certificate<br>path &quot;pki_cert/ca/pem&quot; {<br>  capabilities = [&quot;read&quot;]<br>}</pre><p>Apply the policy:</p><pre>vault policy write cert-manager cert-manager-policy.hcl<br>Success! Uploaded policy: cert-manager</pre><p><strong>Create AppRole for cert-manager</strong></p><pre>vault write auth/approle/role/cert-manager secret_id_ttl=60m token_ttl=20m token_max_ttl=60m policies=cert-manager<br>Success! Data written to: auth/approle/role/cert-manager</pre><p><strong>Retrieve AppRole credentials</strong></p><p>Get the Role ID:</p><pre>vault read auth/approle/role/cert-manager/role-id<br>Key        Value<br>---        -----<br>role_id    0c0c63a5-7351-1ce6-a442-001d8340df22</pre><p>Generate a Secret ID:</p><pre>vault write -f auth/approle/role/cert-manager/secret-id<br>Key                   Value<br>---                   -----<br>secret_id             25351c12-4959-d960-16ca-0a5a8b7e100c<br>secret_id_accessor    abab3a1b-eaf7-9c27-b4b1-8c147cb802ca<br>secret_id_num_uses    0<br>secret_id_ttl         1h</pre><p><strong>ClusterIssuer for Vault with AppRole</strong></p><p>Before applying, make sure you create a Kubernetes Secret to store your role_id and secret_id.</p><pre>oc create secret generic vault-approle-secret --from-literal secretId=25351c12-4959-d960-16ca-0a5a8b7e100c -n cert-manager</pre><p>Create ClusterIssuer YAML</p><pre># cat cluster-issuer.yaml<br>apiVersion: cert-manager.io/v1<br>kind: ClusterIssuer<br>metadata:<br>  name: vault-issuer<br>spec:<br>  vault:<br>    server: https://vault.test.lan<br>    path: pki_int/sign/cert-manager<br>    caBundle: LS0tLS1CRUdJTiBDREJUSUZJQ0FURS0tLS0tCk1JSUQ3akNDQXRhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREIwTVFzd0NRWURWUVFHRXdKVlV6RU8KTUF3R0ExVUVDQXdGVkdWNFlYTXhEekFOQmdOVkJBY01Ca0YxYzNScGJqRVBNQTBHQTFVRUNnd0dUWGtnVDNKbgpNUjB3R3dZSktvWklodmNOQVFrQkZnNWhaRzFwYmtCMFpYTjBMbXhoYmpFVU1CSUdBMVVFQXd3TGRHVnpkQzFzCllXNHRZMkV3SGhjTk1qVXdOREUxTVRnd05qQXdXaGNOTXpVd05ERXpNVGd3TmpBd1dqQjBNUXN3Q1FZRFZRUUcKRXdKVlV6RU9NQXdHQTFVRUNBd0ZWR1Y0WVhNeER6QU5CZ05WQkFjTUJrRjFjM1JwYmpFUE1BMEdBMVVFQ2d3RwpUWGtnVDNKbk1SMHdHd1lKS29aSWh2Y05BUWtCRmc1aFpHMXBia0IwWlhOMExteGhiakVVTUJJR0ExVUVBd3dMCmRHVnpkQzFzWVc0dFkyRXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCRHdBd2dnRUtBb0lCQVFDczJsTFQKSVJUQ3k4VVFFTlRRdjVzVG01bXozVWN5ajBmL3ptYitEL0R3dEVqUE52UkJGU0Y4ekpqUStRNU96ZVp5ZXFYLwpIU3BHSTJjUVpORlhadUVUUkxJZ2pJOXFEOE5pZHZlVW5tQlQ1S0g3emlqaG5sMEt0L2w0TnNMYkY2SjBIeEVwClNnNjkxT3hxZGwrR3lOaGlTLytRRHUxZkxrMVFqSG9kSldDZnJHVnN6eWtiT0VSY0pHZk5SbXpjNVhYcDArcVAKSDhiZkpBa2xLVDZmdGQwRkhtMGV0bENlbmFBU0tYaHB6Q1VOdXAyckZybjhjK2p2ZEQrWTZDbDZZU2FrQmdURwppV01NVDNvc0lOeUpUcmtRNWRZUjI3eUtJWEVvMEZPT05VeldkL3RTT1ltTjhOZ1o4aEM2L0hibDBSYWtSSVp2CjdEY1NhbW9uSXlqVXIrb0pBZ01CQUFHamdZb3dnWWN3TndZSllJWklBWWI0UWdFTkJDb1dLRTlRVG5ObGJuTmwKSUVkbGJtVnlZWFJsWkNCRFpYSjBhV1pwWTJGMFpTQkJkWFJvYjNKcGRIa3dIUVlEVlIwT0JCWUVGS2x5dHg2LwpJZHR2UnZWQ0JpNmhVRHNvMHp0dk1COEdBMVVkSXdRWU1CYUFGS2x5dHg2L0lkdHZSdlZDQmk2aFVEc28wenR2Ck1Bd0dBMVVkRXdRRk1BTUJBZjh3RFFZSktvWklodmNOQVFFTEJRQURnZ0VCQUlJR0pGeUI5eCtEdThHNTBCVTcKWjR6cFN3MGEzVjF2Ym5DV3JaSU5WMHZ0L1RnQ2QwMlI4emU3TG51NU5IQmtOTTl2cU9ucHNFM1ZQT3l3d29wWQo4M3JKUWxCd2V4L0hNOU1NMWVuNGVIL3JFYmh4MUhJM25JR1NwcDk3OElWekx3SVQyQ2lyMk54bm91N0VyVGpGCmJXSnA2SjBtbjg0TzAyaXZIUHZIY09URHhkK1RTc1lmeWRoOWxFNUR6OWNsVGZMZ2tMYVRUZThCY0Y5VmZqRWYKekIwOXNWcDI2dlZ1dG5HRjFEWU43Vis3ODQxZFZIK01GY2RmMnVKeUd6MGVybitJZnNlenVwS05vanFnR00rZwpEb2doYTZQQ21NclJ6Q2FIM0FON3lwd2VPYzg3Q1dUVmtuNW94WUR5OHowWU5taGNqQW1CRkJBeHZsbWI5RHlMCldJWT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=<br>    auth:<br>      appRole:<br>        path: approle<br>        roleId: 0c0c63a5-7351-1ce6-a442-001d8340df22<br>        secretRef:<br>          name: vault-approle-secret<br>          key: secretId<br>          namespace: cert-manager</pre><h4>Explanation:</h4><ul><li>server: Vault address, must be HTTPS.</li><li>path: Vault endpoint for signing, here it&#39;s pki_cert/sign/cert-manager.</li><li>caBundle: Vault’s CA certificate in PEM format.</li><li>auth.appRole.path: Keep as approle unless you mounted AppRole somewhere else.</li><li>roleIdSecretRef / secretRef: Reference the Kubernetes Secret you created earlier.</li></ul><p><strong>Validation:</strong></p><pre>oc  get clusterissuer vault-issuer<br>NAME           READY   AGE<br>vault-issuer   True    28s</pre><p><strong>Create Certificate:</strong></p><p>cert.yaml</p><pre>apiVersion: cert-manager.io/v1<br>kind: Certificate<br>metadata:<br>  name: example-com<br>  namespace: default<br>spec:<br>  secretName: example-com-tls<br>  issuerRef:<br>    name: vault-issuer<br>    kind: ClusterIssuer<br>  commonName: first.test.lan<br>  dnsNames:<br>  - first.test.lan</pre><p>Apply cert.yaml and validate certificate</p><pre># oc apply -f cert.yaml<br>certificate.cert-manager.io/example-com created<br># oc get cert<br>NAME          READY   SECRET            AGE<br>example-com   True    example-com-tls   5s<br># oc get secret example-com-tls<br>NAME              TYPE                DATA   AGE<br>example-com-tls   kubernetes.io/tls   3      7d22h<br># oc describe secret example-com-tls<br>Name:         example-com-tls<br>Namespace:    default<br>Labels:       controller.cert-manager.io/fao=true<br>Annotations:  cert-manager.io/alt-names: first.test.lan<br>              cert-manager.io/certificate-name: example-com<br>              cert-manager.io/common-name: first.test.lan<br>              cert-manager.io/ip-sans:<br>              cert-manager.io/issuer-group:<br>              cert-manager.io/issuer-kind: ClusterIssuer<br>              cert-manager.io/issuer-name: vault-issuer<br>              cert-manager.io/uri-sans:<br><br>Type:  kubernetes.io/tls<br><br>Data<br>====<br>tls.key:  1675 bytes<br>ca.crt:   1285 bytes<br>tls.crt:  2672 bytes</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d471c6133cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup Hashicorp Vault using docker]]></title>
            <link>https://medium.com/@ksh.ludhwani/setup-hashicorp-vault-using-docker-825b3e11ad2b?source=rss-4dda0c2c2c06------2</link>
            <guid isPermaLink="false">https://medium.com/p/825b3e11ad2b</guid>
            <dc:creator><![CDATA[Kushal Ludhwani]]></dc:creator>
            <pubDate>Sun, 20 Apr 2025 12:38:53 GMT</pubDate>
            <atom:updated>2025-04-20T12:38:53.244Z</atom:updated>
            <content:encoded><![CDATA[<p>HashiCorp Vault is a powerful tool for securely storing and accessing secrets such as API keys, tokens, passwords, and certificates. Whether you’re developing locally or building a production-grade system, Vault helps you enforce strong access policies and encrypt sensitive data with ease.</p><p>In this guide, we’ll walk through how to run a Vault server using Docker. By the end of this article, you’ll have a working Vault server accessible via a web UI, ready for local development or integration testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*4y7t0lDCpX9nLQ98Ght6ug.png" /></figure><h3>Prerequisites</h3><p>Before we begin, ensure you have the following installed:</p><ul><li><strong>Docker</strong>: To run the Vault container.</li><li><strong>Docker Compose</strong>: To manage the Vault service configuration.</li><li><strong>Vault CLI</strong>: To interact with Vault from the command line.</li><li>A text editor (e.g., VS Code) to create configuration files.</li><li>TLS certificate and key forHTTPS</li></ul><h3>Setup Vault using docker compose</h3><p>Before we deploy Vault, we need to create the necessary folders on the host machine to persist configuration, logs, data, and certificates. This ensures all important Vault files are stored outside the container, making the setup more portable and manageable.</p><p>Run the following command to create the required directory structure:</p><pre>sudo mkdir -p /var/services/vault/{audit,config,data,file,logs,userconfig/tls,plugins}</pre><p>This command will create the following folders:</p><pre>/var/services/vault/<br>├── audit<br>├── config<br>├── data<br>├── file<br>├── logs<br>├── plugins<br>└── userconfig/<br>    └── tls</pre><p>Each folder serves a specific purpose:</p><ul><li>audit/: Stores Vault audit logs</li><li>config/: Contains the Vault configuration file (vault.hcl)</li><li>data/: Persists Vault storage data</li><li>file/: Used if file-based storage is configured</li><li>logs/: Captures general logs</li><li>plugins/: Optional plugins directory</li><li>userconfig/tls/: Holds TLS certificates and private keys</li></ul><h4>Set the appropriate ownership:</h4><p>To allow Vault to access and write to these directories, set the ownership to Vault’s internal user (UID 100):</p><pre>sudo chown -R 100:100 /var/services/vault/</pre><p>📌 Note: The UID 100 is the default Vault user inside the official Vault Docker image. Adjust if you&#39;re using a custom image or user.</p><h4>Creating the docker-compose.yml File</h4><p>With our directory structure in place, let’s create a docker-compose.yml file to define and run the Vault container. I’ve created this file under /var/services for simplicity.</p><p>Here’s the complete docker-compose.yml:</p><pre>version: &#39;3.6&#39;<br>services:<br>  vault:<br>    privileged: true<br>    image: &quot;hashicorp/vault:latest&quot;<br>    restart: unless-stopped<br>    container_name: vault<br>    ports:<br>    - &quot;8201:8201&quot;<br>    - &quot;443:8200&quot;<br>    environment:<br>      VAULT_API_ADDR: &quot;https://vault.test.lan&quot;<br>      VAULT_CACERT: /vault/userconfig/tls/ca.crt<br>    cap_add:<br>    - IPC_LOCK<br>    volumes:<br>    - /var/services/vault/audit:/vault/audit<br>    - /var/services/vault/config:/vault/config<br>    - /var/services/vault/data:/vault/data<br>    - /var/services/vault/file:/vault/file<br>    - /var/services/vault/logs:/vault/logs<br>    - /var/services/vault/userconfig:/vault/userconfig<br>    - /var/services/vault/plugins:/vault/plugins<br>    - /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt<br>    command: vault server -config=/vault/config/vault-config.hcl<br>    networks:<br>    - services_net<br><br>networks:<br>  services_net:<br>    driver: bridge</pre><h4>Breakdown of Key Elements:</h4><ul><li>privileged: true: Grants the container extra capabilities, necessary for Vault’s use of IPC_LOCK to prevent memory from being swapped to disk.</li><li>image: &quot;hashicorp/vault:latest&quot;: Pulls the latest stable Vault image from Docker Hub.</li><li>ports: Maps HTTPS (443) on the host to Vault’s default API/UI port (8200) and optionally exposes 8201 for internal Vault cluster communication.</li><li>VAULT_API_ADDR: Defines the external URL clients will use to talk to Vault.</li><li>VAULT_CACERT: Points Vault to the CA certificate inside the container for TLS.</li><li>cap_add: IPC_LOCK: Prevents secrets from being written to swap by allowing Vault to lock memory.</li><li>volumes: Maps various host directories into the container for configuration, data, logs, TLS certificates, and plugins.</li><li>command: Starts the Vault server using your custom configuration file.</li><li>networks: Isolates Vault into a named Docker bridge network (services_net)</li></ul><h4>Configuring Vault (vault-config.hcl)</h4><p>Vault uses a configuration file to define how it should behave on startup — including networking, storage backend, security options, and more.</p><p>Create a new file named vault-config.hcl under:</p><pre>#cat /var/services/vault/config/vault-config.hcl<br><br>disable_cache       = true<br>disable_mlock       = true<br>ui                  = true<br>max_lease_ttl       = &quot;2h&quot;<br>default_lease_ttl   = &quot;20m&quot;<br>raw_storage_endpoint = &quot;true&quot;<br>disable_printable_check = &quot;true&quot;<br>cluster_addr        = &quot;https://vault.test.lan:8201&quot;<br>api_addr            = &quot;https://vault.test.lan&quot;<br><br>listener &quot;tcp&quot; {<br>  address                   = &quot;0.0.0.0:8200&quot;<br>  tls_disable               = false<br>  tls_client_ca_file        = &quot;/vault/userconfig/tls/ca.crt&quot;<br>  tls_cert_file             = &quot;/vault/userconfig/tls/vault.crt&quot;<br>  tls_key_file              = &quot;/vault/userconfig/tls/vault.key&quot;<br>  tls_disable_client_certs  = &quot;true&quot;<br>}<br><br>storage &quot;raft&quot; {<br>  node_id  = &quot;vault-1&quot;<br>  path     = &quot;/vault/data&quot;<br>}</pre><h4>Key Highlights:</h4><ul><li><strong>General Settings:</strong></li><li>disable_cache: Disables caching to minimize secret leakage in memory.</li><li>disable_mlock: Skips locking memory for this setup (suitable for Docker).</li><li>ui: Enables the Vault Web UI.</li><li>max_lease_ttl, default_lease_ttl: Sets time-to-live for leases on secrets.</li><li><strong>Listener (HTTPS):</strong></li><li>Binds Vault API to 0.0.0.0:8200.</li><li>Enables TLS using the provided certificate and key.</li><li>Points to the CA certificate for client validation.</li><li>Disables client cert authentication (tls_disable_client_certs = true).</li><li><strong>Storage (Raft):</strong></li><li>Uses Vault’s built-in Raft storage.</li><li>Sets node_id to vault-1 and stores data in /vault/data</li></ul><p>Make sure to copy the following files to your Vault TLS directory:</p><pre>/vault/userconfig/tls/ca.crt<br>/vault/userconfig/tls/vault.crt<br>/vault/userconfig/tls/vault.key</pre><p><strong>Important:</strong> The certificate must have a valid Subject Alternative Name (SAN) that includes:</p><ul><li>vault.test.lan</li><li>127.0.0.1 (if accessing locally)</li></ul><p>This ensures the certificate can be validated both inside the container and from external clients.</p><h4>Starting the Vault Server</h4><p>Once everything is in place — directories created, configuration file ready, and TLS certificates copied — it’s time to start the Vault container.</p><p>Navigate to the directory where your docker-compose.yml is located (in our case, /var/services), and run:</p><pre>docker compose up -d</pre><p>This will:</p><ul><li>Pull the official HashiCorp Vault image (if not already downloaded)</li><li>Start the Vault container in detached mode</li><li>Bind ports 443 and 8201 for HTTPS access and cluster communication</li><li>Mount all your volumes (data, config, TLS, etc.)</li></ul><p>To verify that the container is running, you can check the logs:</p><pre>docker logs -f vault</pre><h4>Initializing and Testing Vault</h4><p>With the Vault container up and running, the next step is to test its status and initialize the server for the first time.</p><h4>Step 1: Check Vault Status</h4><p>Before initializing, verify that Vault is running and reachable by executing:</p><pre>docker exec vault vault status -format=json</pre><p>This will return a JSON output showing Vault’s current status. Look for the following fields:</p><ul><li>&quot;initialized&quot;: false — Vault has not been initialized yet.</li><li>&quot;sealed&quot;: true — Vault is sealed by default.</li><li>&quot;version&quot; — Confirms the Vault version is active.</li><li>&quot;cluster_name&quot; — Your Vault cluster name.</li></ul><h4>Step 2: Initialize Vault</h4><p>Run the following command to initialize Vault:</p><pre>docker exec vault vault operator init -key-shares=5 -key-threshold=3 -format=json &gt; /var/services/vault/init-keys.json</pre><p><strong>Explanation:</strong></p><ul><li>-key-shares=5: Generates 5 unseal keys.</li><li>-key-threshold=3: Any 3 of the 5 keys are required to unseal Vault.</li></ul><p>The command will output a JSON object containing:</p><ul><li>unseal_keys_b64: An array of the 5 base64-encoded unseal keys.</li><li>root_token: The initial root token for administrative access.</li></ul><p><strong><em>Important:</em></strong><em> Store these keys and the root token securely (e.g., in a password manager or encrypted vault). If lost, you won’t be able to unseal or administer Vault.</em></p><h4>Unsealing Vault</h4><p>After initializing Vault, it starts in a sealed state. You must unseal it using at least the number of keys specified in the threshold (3 out of 5 in our case).</p><h4>Step 1: Use the Unseal Keys</h4><p>You’ll need to provide <strong>3 unseal keys</strong> (from the output of the init command) to unseal Vault:</p><pre>docker exec vault vault operator unseal &lt;unseal_key_1&gt;<br>docker exec vault vault operator unseal &lt;unseal_key_2&gt;<br>docker exec vault vault operator unseal &lt;unseal_key_3&gt;</pre><p>Replace &lt;unseal_key_X&gt; with the actual unseal keys provided during initialization.</p><p>You should see a response after each command. Once the threshold is met, Vault becomes unsealed and ready to use.</p><h4>Step 2: Check Vault Status Again</h4><p>To confirm Vault is now unsealed and initialized:</p><pre>docker exec vault vault status</pre><p>You should see:</p><ul><li>Initialized: true</li><li>Sealed: false</li></ul><h4>Accessing the Vault Web UI</h4><p>With Vault now unsealed and ready, you can access its <strong>Web UI</strong> for easier management and interaction.</p><p>Open your browser and visit:</p><pre>https://vault.test.lan</pre><p><strong>Log in Using the Root Token</strong></p><p>During initialization, Vault generated a root_token. Use this token to log in via the Web UI:</p><ol><li>Visit <a href="https://vault.test.lan/">https://vault.test.lan</a></li><li>Select <strong>Token</strong> as the authentication method.</li><li>Paste the root token you received after initialization.</li><li>Click <strong>Sign In</strong>.</li></ol><p><strong>Important:</strong> The root token is extremely powerful. Use it sparingly and rotate it out after setting up admin policies and users.</p><h3>Conclusion</h3><p>You’ve now successfully:</p><ul><li>Set up a secure Vault server using Docker and Docker Compose.</li><li>Configured it with TLS and Raft storage.</li><li>Initialized and unsealed it.</li><li>Accessed the Web UI using your root token.</li></ul><p>From here, you can continue by:</p><ul><li>Enabling secret engines (KV, PKI, etc.)</li><li>Creating policies and user authentication methods</li><li>Integrating Vault into your apps and automation workflows</li></ul><h4>Final Note: Vault Will Require Unsealing After Restart</h4><p>By default, Vault operates in a <strong>sealed</strong> state for security. This means that <strong>if the Vault container restarts</strong> — whether due to a host reboot, Docker restart, or configuration change — Vault will return to a sealed state.</p><p>You’ll need to manually unseal Vault again using <strong>at least 3 of the unseal keys</strong> generated during initialization:</p><pre>docker exec vault vault operator unseal &lt;unseal_key_1&gt;<br>docker exec vault vault operator unseal &lt;unseal_key_2&gt;<br>docker exec vault vault operator unseal &lt;unseal_key_3&gt;</pre><h3>What’s Next?</h3><p>In the next part of this Vault series, I’ll walk you through configuring:</p><ul><li>🔐 <strong>PKI Secrets Engine</strong> — to generate and manage internal TLS certificates</li><li>🧾 <strong>AppRole Authentication</strong> — to securely authenticate applications and automation</li><li>🔁 <strong>External Secrets Operator Integration (ESO)</strong> — to sync secrets from Vault to OpenShift or Kubernetes workloads</li></ul><p>This will complete a production-ready Vault integration with your container workloads — stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=825b3e11ad2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install OpenShift with IPI method on VMware: A Step-by-Step Guide for Beginners]]></title>
            <link>https://medium.com/@ksh.ludhwani/install-openshift-with-ipi-menthod-on-vmware-a-step-by-step-guide-for-beginners-c0f4a15d380e?source=rss-4dda0c2c2c06------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0f4a15d380e</guid>
            <dc:creator><![CDATA[Kushal Ludhwani]]></dc:creator>
            <pubDate>Thu, 17 Apr 2025 17:49:07 GMT</pubDate>
            <atom:updated>2025-04-18T10:27:03.525Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Author’s note</strong>: If you’re new to OpenShift or setting it up on your on-prem VMware environment, this guide is for you. We’ll walk through the prerequisites, environment setup, and installation steps — with helpful tips along the way.</p><h3>🌟 Why Choose OpenShift with VMware?</h3><p>Red Hat OpenShift stands out as a leading Kubernetes platform for enterprise needs. Running it on VMware vSphere delivers a reliable, scalable, and secure foundation that countless organizations rely on for virtualization.</p><p>Whether you’re exploring OpenShift for development, testing, or production, integrating it with VMware maximizes your existing infrastructure’s potential.</p><h3>🔧 Prerequisites</h3><p>Before getting started, ensure you have:</p><ul><li>A functional vSphere setup (vCenter, ESXi hosts)</li><li>A bastion host or jump server (to execute installer commands)</li><li>A Red Hat account with the pull secret</li><li>OpenShift installer and CLI downloaded from Red Hat’s site</li></ul><p>Optional but helpful:</p><ul><li>A private registry (for air-gapped installations)</li><li>Internet connectivity (for online installations)</li></ul><h3>📋 Environment Planning</h3><p>Before proceeding, ensure your environment is ready with the necessary configurations and resources. Openshift require following VMs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bb055723c6a33f4c755ed7d8945bedd/href">https://medium.com/media/6bb055723c6a33f4c755ed7d8945bedd/href</a></iframe><h3>Different Installation Methods:</h3><h3>🌍 UPI vs IPI: What’s the Difference?</h3><p>When deploying OpenShift, you can choose between User-Provisioned Infrastructure (UPI) and Installer-Provisioned Infrastructure (IPI). Your choice determines the level of automation versus manual control.</p><p><strong>🛠️ User-Provisioned Infrastructure (UPI)</strong><br> You handle the setup.</p><p>With UPI, the OpenShift installer generates configuration files and ignition configs, but you’re responsible for:</p><ul><li>Provisioning all VMs (bootstrap, master, worker)</li><li>Configuring networking and DNS</li><li>Attaching ignition files to nodes</li><li>Managing load balancer and storage</li></ul><p>✅ Pros:</p><ul><li>Complete control over your setup</li><li>Perfect for tailored or complex infrastructure</li><li>Supports air-gapped/disconnected environments</li></ul><p>❌ Cons:</p><ul><li>Time-intensive and manual</li><li>Greater chance of errors</li></ul><p>🎯 Use case:<br> Common in on-prem setups like VMware vSphere, where organizations need precise control over VM specifications, networking, and security policie</p><h4>🌟 Installer-Provisioned Infrastructure (IPI)</h4><p>The installer takes the lead.</p><p>With IPI, the OpenShift installer automatically:</p><ul><li>Connects to your cloud or virtualization platform (e.g., AWS, Azure, vSphere)</li><li>Provisions VMs</li><li>Configures networking, load balancers, storage, and more</li></ul><p>✅ Pros:</p><ul><li>Quick and straightforward setup</li><li>Perfect for evaluations, PoCs, or cloud-native deployments</li></ul><p>❌ Cons:</p><ul><li>Limited control over infrastructure specifics</li><li>Requires specific permissions or APIs (e.g., vSphere credentials)</li></ul><p>🎯 Use case:<br> Best for cloud environments or smaller teams looking to deploy OpenShift rapidly with minimal configuration effort.</p><h3>🧭 Our Focus: IPI Installation on vSphere</h3><p>In this article, we’ll be focusing on the <strong>Installer-Provisioned Infrastructure (IPI)</strong> method. With IPI, OpenShift handles much of the heavy lifting — from provisioning virtual machines on vSphere to setting up networking and storage. This approach is ideal for teams looking to streamline installation with minimal manual steps.</p><p>The goal is to get you from <strong>zero to a fully functional OpenShift cluster</strong> running on your existing VMware environment — quickly and cleanly.</p><p>We’ll walk through:</p><ul><li>Preparing your vSphere environment for IPI</li><li>Setting up DNS and load balancer for automated deployment</li><li>Running the OpenShift installer and letting it do the rest</li></ul><blockquote><em>🛠️ If you’re looking for </em><strong><em>manual provisioning or air-gapped environments</em></strong><em>, don’t worry — a dedicated guide for </em><strong><em>UPI installation</em></strong><em> is coming up next.</em></blockquote><p>Let’s dive into the IPI setup process.</p><h3>⚙️ Preparing for IPI Installation on vSphere</h3><p>Before running the installer, there are a few <strong>one-time setup tasks</strong> you’ll need to complete. These help the OpenShift installer interact with your vSphere environment securely and successfully.</p><p>Make sure you have the following vSphere details ready:</p><ul><li>vCenter Server FQDN (e.g., vcenter.example.com)</li><li>vCenter username and password (with permissions to create VMs and templates)</li><li>vSphere datacenter and cluster names</li><li>Folder to deploy VMs (can be created manually)</li><li>Resource pool (optional)</li><li>Network name (VM Network used by the cluster)</li><li>Datastore name (for persistent storage)</li></ul><p>You’ll also need:</p><ul><li>A <strong>DNS zone</strong> and the ability to create forward and reverse records</li><li>A <strong>static IP range or DHCP</strong> for your nodes</li><li>A <strong>load balancer</strong> (for API and Ingress endpoints)</li></ul><h3>Additional Link For Requirement:</h3><p><a href="https://docs.redhat.com/en/documentation/openshift_container_platform/4.16/html/installing_on_vsphere/installer-provisioned-infrastructure#ipi-vsphere-installation-reqs">Chapter 2. Installer-provisioned infrastructure</a></p><h3>📦 2. Download OpenShift Installer and CLI</h3><p>I am using a ubuntu based VM for my OpenShift installation.</p><p>Get the latest OpenShift Installer and CLI for your platform from Red Hat’s official portal.</p><p>On your installation host (e.g., a Linux VM or Bastion):</p><pre># Download the installer and CLI<br>curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-install-linux.tar.gz<br>curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz<br><br># Extract them<br>tar -xzf openshift-install-linux.tar.gz<br>tar -xzf openshift-client-linux.tar.gz<br><br># Move to path if desired<br>sudo mv openshift-install oc kubectl /usr/local/bin/</pre><h3>🗂️ 3. Generate Install Config for IPI</h3><p>Create a new directory to hold your install assets:</p><pre>#mkdir ~/ocp-ipi &amp;&amp; cd ~/ocp-ipi<br>#openshift-install create install-config<br><br>? Platform vsphere<br>? vCenter Server vcenter.example.com<br>? vCenter Username administrator@vsphere.local<br>? vCenter Password [? for help] **************<br>? Datacenter dc1<br>? Default Datastore datastore1<br>? Cluster compute-cluster<br>? Network VM Network<br>? Virtual IP Address for API 192.168.1.100<br>? Virtual IP Address for Ingress 192.168.1.101<br>? Base Domain test.lan<br>? Cluster Name ipi<br>? Pull Secret [? for help] {&quot;auths&quot;:{&quot;cloud.openshift.com&quot;:{...}}}</pre><p>Note: To get pull secret Login to <a href="https://console.redhat.com/openshift/overview">https://console.redhat.com/openshift/overview</a> click on Red Hat OpenShift Container Platform -&gt; Create Cluster -&gt; Local -&gt; Copy pull secret</p><p>Once complete, the installer creates an install-config.yaml file in the directory. Edit install-config.yaml for any customization for Ex. Adding ssh key.</p><pre>apiVersion: v1<br>baseDomain: test.lan<br>metadata:<br>  name: ipi<br>compute:<br>- name: worker<br>  replicas: 2<br>controlPlane:<br>  name: master<br>  replicas: 3<br>networking:<br>  clusterNetwork:<br>  - cidr: 10.132.0.0/14<br>    hostPrefix: 23<br>  machineNetwork:<br>  - cidr: 10.100.11.0/24<br>  networkType: OVNKubernetes<br>  serviceNetwork:<br>  - 172.30.0.0/16<br>platform:<br>  vsphere:<br>    vcenter: vcenter.example.com<br>    username: administrator@vsphere.local<br>    password: &lt;REDACTED&gt;<br>    datacenter: dc1<br>    defaultDatastore: datastore1<br>    cluster: compute-cluster<br>    network: VM Network<br>    apiVIP: 192.168.1.100<br>    ingressVIP: 192.168.1.101<br>pullSecret: &#39;{&quot;auths&quot;:{&quot;cloud.openshift.com&quot;:{...}}}&#39;<br>sshKey: &#39;ssh-rsa AAAAB3...&#39;</pre><h3>🚀 5. Start the Installation</h3><p>Once your config is ready, kick off the IPI installation:</p><pre>#openshift-install create cluster --dir=~/ocp-ipi --log-level=info</pre><p>The installer will:</p><ul><li>Connect to vCenter</li><li>Upload a VM template (RHCOS)</li><li>Provision bootstrap, master, and worker nodes</li><li>Configure load balancers, storage, and networking</li></ul><p>This step takes around 30–45 minutes depending on your network speed.</p><p>Note: Make sure your VM can connect to vcenter and ESXi server on port 443.</p><p>Once installation is completed, You will see similar output as below.</p><pre>INFO To access the cluster as the system:admin user when using &#39;oc&#39;, run<br>INFO     export KUBECONFIG=/root/ocp-ipi/auth/kubeconfig<br>INFO Access the OpenShift web-console here: https://console-openshift-console.apps.ipi.test.lan<br>INFO Login to the console with user: &quot;kubeadmin&quot;, and password: &quot;UTLvF-wxvHV-UynoR-uwxbK&quot;</pre><p>Add DNS entry for api.ipi.test.lan and map it with 192.168.1.100(apiVIP).</p><p>Add another dns entry for *.apps.ipi.test.lan and map it with 192.168.1.101(ingress VIP).</p><p>Once done run below command to access the cluster.</p><pre># export KUBECONFIG=/root/ipi/auth/kubeconfig<br># oc get nodes<br>NAME                       STATUS   ROLES                  AGE   VERSION<br>ipi-pvrz7-master-0         Ready    control-plane,master   20h   v1.31.6<br>ipi-pvrz7-master-1         Ready    control-plane,master   20h   v1.31.6<br>ipi-pvrz7-master-2         Ready    control-plane,master   20h   v1.31.6<br>ipi-pvrz7-worker-0-krf6j   Ready    worker                 20h   v1.31.6<br>ipi-pvrz7-worker-0-qsv5w   Ready    worker                 20h   v1.31.6<br>ipi-pvrz7-worker-0-smnbk   Ready    worker                 20h   v1.31.6</pre><p>Access the OpenShift UI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WEW7kGjgp_VJPHLbdoeMXQ.png" /><figcaption>Login with kubeadmin user</figcaption></figure><h3>Time to deploy first nginx deployment</h3><p>To deploy first pod, It is required to create deployment,svc and route.</p><p>Nginx deployment</p><pre># cat nginx-deploy.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx-oc<br>  namespace: default<br>  labels:<br>    app: nginx<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: nginx<br>  template:<br>    metadata:<br>      labels:<br>        app: nginx<br>    spec:<br>      containers:<br>      - name: nginx<br>        image: nginx:latest<br>        ports:<br>        - containerPort: 80<br>        resources:<br>          limits:<br>            cpu: &quot;0.5&quot;<br>            memory: &quot;512Mi&quot;<br>          requests:<br>            cpu: &quot;0.2&quot;<br>            memory: &quot;256Mi&quot;<br>        livenessProbe:<br>          httpGet:<br>            path: /<br>            port: 80<br>          initialDelaySeconds: 30<br>          periodSeconds: 10<br>        readinessProbe:<br>          httpGet:<br>            path: /<br>            port: 80<br>          initialDelaySeconds: 5<br>          periodSeconds: 10<br><br># oc apply -f nginx-deploy.yaml<br>deployment.apps/nginx-oc created<br># oc get pods<br>NAME                        READY   STATUS              RESTARTS   AGE<br>nginx-oc-7b7986645f-rgxjf   0/1     ContainerCreating   0          6s<br># oc get pods<br>NAME                        READY   STATUS    RESTARTS   AGE<br>nginx-oc-7b7986645f-rgxjf   1/1     Running   0          66s<br><br># cat nginx-svc.yaml<br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: nginx<br>  namespace: default<br>  labels:<br>    app: nginx<br>spec:<br>  ports:<br>  - port: 80<br>    targetPort: 80<br>    protocol: TCP<br>  selector:<br>    app: nginx<br>  type: ClusterIP<br><br># oc apply -f nginx-svc.yaml<br>service/nginx created<br>root@kl-console:~/openshift# oc get svc<br>NAME         TYPE           CLUSTER-IP       EXTERNAL-IP                            PORT(S)   AGE<br>kubernetes   ClusterIP      172.30.0.1       &lt;none&gt;                                 443/TCP   45h<br>nginx        ClusterIP      172.30.187.251   &lt;none&gt;                                 80/TCP    4s<br>openshift    ExternalName   &lt;none&gt;           kubernetes.default.svc.cluster.local   &lt;none&gt;    45h<br><br># cat nginx-route.yaml<br>apiVersion: route.openshift.io/v1<br>kind: Route<br>metadata:<br>  name: nginx<br>  namespace: default<br>  labels:<br>    app: nginx<br>spec:<br>  to:<br>    kind: Service<br>    name: nginx<br>    weight: 100<br>  port:<br>    targetPort: 80<br>  wildcardPolicy: None<br><br># oc apply -f nginx-route.yaml<br>route.route.openshift.io/nginx created<br><br># oc get route<br>NAME    HOST/PORT                         PATH   SERVICES   PORT   TERMINATION   WILDCARD<br>nginx   nginx-default.apps.ipi.test.lan          nginx      80                   None</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*crMJyQfng3EQmLip9KU0kQ.png" /><figcaption>Nginx Welcome page</figcaption></figure><h3>TroubleShooting</h3><p>While creating install-config.yaml you may come across the error for certificate if VM doesn’t have valid certificate on VM being used for the installation.</p><pre>FATAL failed to fetch Install Config: failed to fetch dependency of &quot;Install Config&quot;: failed to fetch dependency of &quot;Base Domain&quot;: failed to generate asset &quot;Platform&quot;: unable to connect to vCenter vcenter.example.com. Ensure provided information is correct and client certs have been added to system trust: Post &quot;https://vcenter.example.com/sdk&quot;: tls: failed to verify certificate: x509: certificate is valid for vcenter.example.com, not vcenter.example.com</pre><p>Add valid certificate to your system keychain and try again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0f4a15d380e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>