Free tech learning for everyone, from basics to pro

Kubernetes SecurityCloud SecurityAdvanced

Kubernetes Secrets and etcd encryption: risks and better options

In short: A Kubernetes Secret is base64-encoded, not encrypted, and is stored in etcd. Protect it by restricting RBAC, enabling encryption at rest with a KMS provider, isolating etcd and encrypting backups. For important credentials, keep the source of truth in an external secret store.

What a Secret really is

A Kubernetes Secret is an object for small sensitive values such as passwords, tokens and TLS keys. The values are base64-encoded, which is just a way to represent bytes as text, not protection. Anyone who can read the object can decode it instantly; try it with the Base64 tool.

kubectl create secret generic db-cred -n shop --from-literal=password='<your-password>'
kubectl get secret db-cred -n shop -o yaml

Secrets are stored in etcd, the cluster database. Unless you configure encryption at rest, they sit there in plain form. So a Secret is exposed to anyone with RBAC read access to it, anyone who can create pods that mount it, anyone with access to etcd or its disk, and anyone who obtains an etcd backup.

Layers of protection for a SecretRBAC on secretsfew can readEncryption at restKMS provideretcd accessAPI server only, mTLSBackupsencrypted, restrictedExternal storesource of truth
Figure 1. A Kubernetes Secret needs protecting at every layer where it can be read or copied.

Restricting access

  • Grant get, list and watch on secrets only to the identities that need them, and scope by namespace. Note that list returns secret values too.
  • Remember that permission to create pods or workloads in a namespace effectively grants access to its Secrets, because a pod can mount them.
  • Mount secrets as files rather than environment variables where possible.
  • Consider marking Secrets immutable: true when they should not change, which also protects against accidental edits.

Encryption at rest

Envelope encryption with KMSSecret writtenvia API serverEncrypt with DEKdata keyDEK wrappedby KMS keyStored in etcdciphertext only
Figure 2. With a KMS provider, the key that protects data keys never leaves the external key service.

The API server can encrypt resources before writing them to etcd, configured with an EncryptionConfiguration file. Options include local keys (aescbc, aesgcm, secretbox) and the KMS v2 provider. Local keys sit in a file on the control plane node, so anyone with access to that node has both the data and the key. The KMS provider uses envelope encryption: each value is encrypted with a data encryption key (DEK), and DEKs are wrapped by a key held in an external key management service, such as AWS KMS, Azure Key Vault or a hardware security module.

apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
  - resources: ["secrets"]
    providers:
      - kms:
          apiVersion: v2
          name: cloud-kms
          endpoint: unix:///var/run/kms-plugin/socket.sock
      - identity: {}

The identity provider at the end allows existing unencrypted data to be read during migration. After enabling encryption, rewrite existing Secrets so they are stored encrypted. Managed services make this simpler: EKS, AKS and GKE all offer envelope encryption of Secrets with your own cloud KMS key.

etcd, backups and better options

ControlWhy
Only the API server can reach etcdDirect etcd access bypasses RBAC and audit entirely
Mutual TLS between API server and etcdPrevents eavesdropping and impersonation
Encrypted disks on etcd nodesProtects against stolen volumes or snapshots
Encrypted, access-controlled backupsAn etcd backup contains every Secret in the cluster

For important credentials, many teams treat Kubernetes Secrets as a delivery mechanism only, and keep the source of truth in an external store such as HashiCorp Vault, AWS Secrets Manager or Azure Key Vault. The Secrets Store CSI Driver can mount values straight into pods without creating Secret objects at all, while the External Secrets Operator syncs them into Secrets. See container secrets for the wider picture.

Tip: never commit Secret manifests to git, even base64-encoded. If you use GitOps, store encrypted forms (for example Sealed Secrets or SOPS) or references to an external store.

Practice

A colleague says Kubernetes Secrets are safe because they are base64-encoded. What do you tell them?
Base64 is encoding, not encryption. Anyone who can read the Secret, or etcd, can decode it immediately.
Why is the KMS provider stronger than a local aescbc key?
With a local key, the key sits on the control plane node beside the data. With KMS, the key that wraps data keys stays in an external key service with its own access control and audit.
Why must etcd backups be protected as carefully as the cluster?
They contain every object, including all Secrets, so a stolen backup exposes the whole cluster.

Key takeaways

  • Secrets are base64-encoded, not encrypted, by default.
  • Limit get, list and watch on secrets, and pod creation.
  • Enable encryption at rest, ideally with a KMS provider.
  • Isolate etcd and encrypt and restrict its backups.
  • Use an external secret store as the source of truth for key credentials.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.