Configuration, Secrets, Storage and RBAC

Inject configuration and secrets into pods, attach persistent storage, and control who can do what in the cluster.

Intermediate · about 8 hours · difficulty 3/5

Learn first: Workloads, Probes and Autoscaling

Twelve-factor apps read config from the environment, and Kubernetes gives you native objects for that, plus storage and access control.

Config and secrets

  • ConfigMaps hold non-sensitive config, mounted as files or env vars.
  • Secrets hold sensitive values but are only base64-encoded, not encrypted, by default. Enable encryption at rest for etcd, restrict access with RBAC, and consider External Secrets Operator or a CSI driver to sync from Vault or a cloud secret manager.
  • Changing a ConfigMap does not restart pods using env vars; use a checksum annotation or a reloader.

Storage

  • PersistentVolumeClaims request storage; StorageClasses provision it dynamically (EBS, Persistent Disk, Azure Disk) via CSI drivers.
  • Access modes (ReadWriteOnce vs ReadWriteMany) and reclaim policies (Delete vs Retain).
  • Running databases in Kubernetes is possible with operators, but managed databases are often simpler.

Access control

  • RBAC: Roles/ClusterRoles define verbs on resources; RoleBindings grant them to users, groups or ServiceAccounts.
  • Give each workload its own ServiceAccount, and map it to cloud IAM (IRSA / EKS Pod Identity, GKE Workload Identity) instead of static keys.
  • Pod Security Standards (restricted, baseline) and admission policies (Kyverno, Gatekeeper) enforce safe defaults.

Good enough to move on: you can run an app with config, a secret from an external store, a persistent volume, and a least-privilege ServiceAccount.

Key concepts

  • ConfigMaps
  • Secrets and their limits
  • External Secrets Operator
  • PV, PVC and StorageClasses
  • CSI drivers
  • RBAC and ServiceAccounts
  • Workload identity to cloud IAM
  • Pod Security Standards
  • Kyverno / Gatekeeper policies

Mini project

Deploy an app that reads a ConfigMap and a Secret, stores uploads on a PVC, and runs with a ServiceAccount that can only read its own ConfigMap; prove with kubectl auth can-i that it cannot list secrets.

Check yourself

If Kubernetes Secrets are only base64-encoded, what actually protects them, and what would you add?

Free resources