Review Kubernetes Secret management

Choose secret management that meets access-control, rotation and audit requirements.

Description

Native Kubernetes Secrets can work with encryption at rest and restricted reads. Consider an external store when several applications or clusters need centralized rotation, expiry tracking and auditing.

Potential impact

Committing real values in manifests exposes them. Base64 is reversible, and syncing an external value into Kubernetes creates another copy to protect.

Remediation

Limit access and audit reads whether you use native Secrets, Vault or a cloud secret store. KMS encrypts stored data. Test rotation separately by checking how files, environment variables and the application receive the new value, including any required restart.

Examples

The credentials are examples. To use app-password from Azure Key Vault, install the Secrets Store CSI Driver and Azure provider, configure the identity and vault permissions, replace the placeholders and mount the CSI volume in the Pod.

Before

yaml
apiVersion: v1
kind: Secret
metadata:
  name: app-secret
stringData:
  password: "my-password"
  apiToken: "my-token"

After

yaml
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: app-secrets
spec:
  provider: azure
  parameters:
    keyvaultName: "<key-vault-name>"
    tenantId: "<tenant-id>"
    objects: |
      array:
        - |
          objectName: app-password
          objectType: secret

The example selects only app-password. Migrate any applications that still read apiToken from app-secret before retiring that Secret.

References