πŸ”Kubernetes Secrets with HashiCorp Vault Labs

🚧 Under Construction!!

🎯 Objective

Use an existing, externally managed HashiCorp Vault instance to inject secrets securely into Kubernetes pods.


🧰 Prerequisites

  • A running Vault server outside Kubernetes

  • Kubernetes cluster access

  • Vault CLI (vault) installed

  • Kubernetes kubectl configured


πŸ”Ή Lab 1: Prepare Vault for Kubernetes Authentication

Step 1: Enable Kubernetes auth in Vault

vault auth enable kubernetes

Step 2: Configure Kubernetes auth with your cluster details

Replace <KUBERNETES_API_ENDPOINT> with your cluster's API server address.


πŸ”Ή Lab 2: Create Vault Policies and Roles

Step 1: Create a policy

Step 2: Create a role for the Kubernetes service account


πŸ”Ή Lab 3: Store a Secret in Vault


πŸ”Ή Lab 4: Deploy Vault Agent Injector (if needed)

If using Vault Agent Injector:

βœ… Connects to external Vault instead of in-cluster Vault.


πŸ”Ή Lab 5: Create Kubernetes ServiceAccount


πŸ”Ή Lab 6: Annotate Pod to Use External Vault

βœ… Secret from external Vault is injected as a file inside the pod.


πŸ”Ή Lab 7: Verify Secret Injection

βœ… Should print Vault secret contents from /vault/secrets/config.txt.


βœ… Wrap-Up

  • βœ… Integrated Kubernetes with an external Vault server

  • βœ… Used Kubernetes auth method for secure authentication

  • βœ… Injected secrets into pods using Vault Agent

  • βœ… No in-cluster Vault server needed


Last updated