Skip to the content.

🧠 What is Secrets Management?

Secrets management is the secure storage, distribution, and access control of sensitive data such as:

The goal is to protect secrets from exposure, while still making them available to applications that need them.


🔐 Why Secrets Management is Needed

Without a proper secrets management system, teams often:

Secrets management ensures:


🏗️ Components of a Secrets Management System

Component Description
Secret Store Encrypted database that stores secrets securely
Access Control Defines who or what can access secrets (via roles/policies)
Audit Logs Records all access and usage
Rotation Ability to rotate secrets automatically
Integration Works with apps, CI/CD, and cloud environments

⚙️ Tools for Secrets Management

Two popular tools:

1️⃣ HashiCorp Vault

2️⃣ Kubernetes Secrets


🧱 1️⃣ HashiCorp Vault

🔹 What It Is

Vault is a centralized secrets management system created by HashiCorp. It securely stores and controls access to tokens, passwords, certificates, and encryption keys.

🔹 Key Features

Feature Description
Dynamic Secrets Vault can generate secrets on-demand (e.g., temporary DB credentials)
Encryption as a Service Apps can encrypt/decrypt data without handling keys
Secret Leasing & Revocation Secrets have a TTL (time-to-live) and can be revoked
Audit Logging All access attempts are logged
Fine-Grained Access Policies Uses ACL policies via Vault’s internal authentication

🔹 Example

Step 1: Store a secret

vault kv put secret/db password=MySecurePassword

Step 2: Retrieve a secret

vault kv get secret/db

Step 3: App reads it securely (Java example)

String vaultToken = "s.xxxxx";
VaultConfig config = new VaultConfig()
    .address("https://vault.mycompany.com")
    .token(vaultToken)
    .build();
Vault vault = new Vault(config);

LogicalResponse response = vault.logical().read("secret/db");
String password = response.getData().get("password");

Vault ensures:


🧩 2️⃣ Kubernetes Secrets

🔹 What It Is

In Kubernetes, Secrets are objects used to store small pieces of sensitive data — such as passwords, OAuth tokens, or SSH keys.

Stored in the Kubernetes API and base64-encoded (not encrypted by default).

🔹 Example

apiVersion: v1
kind: Secret
metadata:
  name: db-secret
type: Opaque
data:
  username: bXl1c2Vy   # base64 encoded 'myuser'
  password: TXlQYXNzIQ==  # base64 encoded 'MyPass!'

Use it in a Pod:

env:
  - name: DB_USERNAME
    valueFrom:
      secretKeyRef:
        name: db-secret
        key: username

🔹 Security Enhancements


🔄 Vault + Kubernetes Integration

Vault can be integrated with Kubernetes for dynamic secret injection:

  1. App authenticates using Kubernetes Service Account token
  2. Vault verifies and issues a temporary token
  3. App retrieves secrets dynamically from Vault

🔹 Benefits:


🧰 Example Use Case

Scenario: A microservice needs a DB password.

Without Secrets Management:

With Vault + Kubernetes:


🧠 Summary

Feature HashiCorp Vault Kubernetes Secrets
Encryption Yes (strong AES-256) Base64 by default, can enable encryption
Dynamic Secrets ✅ Yes ❌ No
Secret Rotation ✅ Auto ⚠️ Manual
Authentication Tokens, IAM, AppRole, K8s ServiceAccount
Best For Multi-environment, enterprise setups Simpler K8s apps

🧩 Analogy

Think of Vault as a high-security vault in a bank 🏦 Only authorized users with valid ID (token) can open specific boxes (secrets). Kubernetes Secrets, on the other hand, are like lockers with passcodes — simple but less secure unless you add extra locks (encryption + RBAC).