Kubernetes secrets management and encryption at rest

Kubernetes stores Secrets unencrypted in etcd by default. This guide covers the decisions, build sequence, access limits and checks that close that gap in infrastructure you control.

On this page

Why Kubernetes secrets management needs deliberate design

A Kubernetes cluster holds database passwords, API tokens, registry credentials and TLS certificates that workloads depend on, and most of them are stored as Secret objects. The point to settle first is that Secrets are stored unencrypted in etcd by default. Encryption at rest, limits on who can read Secrets and the choice of an external store are three separate decisions. Each one needs an owner, a configuration and a check that proves it is in place. Leaving any of them to the default means the cluster is protected only by the assumption that nobody reaches the etcd data.

The harder part is that etcd is rarely the only place a secret leaks. Copies of etcd snapshot files, which the cluster's backup process creates, contain the same values unless the backup store is protected separately. Anyone with get, list or watch permission on Secrets in a namespace can read them through the API, and broad list or watch grants let a user read every value in that namespace at once. Secret values also reach logs, CI pipelines and shell history when someone runs kubectl get secret -o yaml or passes a value on the command line, and they can be copied into ConfigMaps or environment variables by well-meaning developers.

Plan for these paths together, not one at a time. Ask the platform team to list every place Secret data is written, stored and read, including backup targets, audit log settings and admin kubeconfigs, and to confirm which of those paths is protected and how. The Kubernetes good practices for Secrets page is the natural starting reference for that review. Treat the result as the baseline for the encryption, RBAC and external store work described in the rest of this guide.

Which components hold and expose secret data

Secret data can sit in several places at once: the datastore, the API server, the nodes that mount it, and the backups taken from the datastore. Each component needs its own control, and a gap in any one of them exposes the values stored elsewhere.

The etcd datastore

etcd is where the API server persists Secret objects. By default these values are stored unencrypted, so anyone who can read the etcd data directory or its client port can read every Secret in the cluster. Confirm whether your distribution restricts etcd to control plane peers and client certificates, and who holds host access to the control plane nodes.

Secrets good practices

The kube-apiserver encryption configuration

The API server applies encryption at rest through an encryption configuration file passed with the --encryption-provider-config flag. Check whether that flag is set, which resources are listed, and whether the key provider is a KMS plugin backed by a key management service you control. Confirm how keys rotate and whether existing Secrets were rewritten after the setting changed.

RBAC roles and bindings

Role and ClusterRole objects decide which users, groups and service accounts can read Secrets. The verbs get, list and watch each expose values, and list or watch on a namespace returns full Secret contents. Audit every binding that grants these verbs, including wildcard rules and default service accounts with broad roles.

Secrets Store CSI Driver and provider

The Secrets Store CSI Driver mounts secrets from an external store, such as a cloud secret manager or a vault, into pods as volumes, so values need not be stored as Kubernetes Secret objects. Each provider plugin needs its own identity and permissions on the external store. Confirm which provider you run, how it authenticates to the store, and whether the driver also syncs to a Kubernetes Secret, which would bring the value back into etcd.

The kubelet and mounted Secrets

The kubelet fetches Secrets referenced by a pod and writes them to a tmpfs volume or passes them as environment variables on the node. Anyone with root on a worker node or access to the container runtime can read them. Confirm which pods can run privileged, whether hostPath mounts exist, and how node access is controlled.

etcd snapshots and backups

An etcd snapshot contains the same Secret data as the live datastore, so it inherits every exposure above once it leaves the cluster. Confirm where snapshots are stored, whether they are encrypted, who can restore them, and whether backup copies are covered by the same key and access controls as the live cluster.

etcd operations guide

How a Secret travels from the API to a pod

The path starts when a user or workload sends a request to the kube-apiserver, which first checks RBAC authorization. Before the write reaches etcd, the API server encrypts the value with a key from the key management service, so the etcd disk and its backups hold only ciphertext. When a pod needs the value, the kubelet delivers it to the node, where it appears in a mounted file or environment variable. The external store branch shows how the Secrets Store CSI Driver can fetch values at pod start without storing them in etcd. Check that each boundary has its own access controls.

Secret path from the API server through encryption, etcd and the node.

Which secret storage approach fits your cluster

This table compares four ways to store and protect Kubernetes Secrets, from encryption at rest alone to an external store combined with cluster controls. Read each row as a trade-off: the first columns show when the option fits and what it asks of your team, and the last column lists what to confirm with your distribution or cloud key service before you choose.

OptionWhen it fitsOperational costConfirm before choosing
Encryption at rest only, Secrets in etcdSmall clusters with few teams, where the main risk is someone reading etcd backups or disksKey custody sits with you or the KMS provider. Rotating the encryption key and re-encrypting existing Secrets becomes a standing runbook taskWhether your distribution exposes an encryption configuration and a KMS plugin, and how it handles key rotation
Encryption at rest with tight RBACMulti-team clusters where Secrets must stay readable only by named workloads and service accountsLeast-privilege roles need ongoing review as teams and workloads change. Audit logs must cover list and watch access, not only getWhich users and controllers already hold list or watch rights on Secrets through default or third-party roles
External secret store through the Secrets Store CSI DriverOrganizations that already run a central secret manager and need one place for rotation and access policyA second system to operate, with provider dependency, sync and rotation behavior, and its own audit trail to include in evidenceWhich provider plugins your distribution supports and whether your secret manager is reachable from every node
Combined: encryption at rest, tight RBAC and external storeRegulated environments that need layered controls, separate custody of keys and clear audit evidenceHighest operational load: three control planes to monitor, test and document, plus joint restore and rotation drillsOwnership of each layer in writing, and whether auditors accept the split of key custody and access records

How to configure encryption at rest with a key management service

This sequence turns on envelope encryption for Kubernetes Secrets so that new and existing Secret values are stored as ciphertext in etcd, with the key held outside the cluster. Each step ends with a check you can run and record.

  1. Confirm the kube-apiserver configuration and access

    The platform engineer responsible for the control plane records how kube-apiserver is started in each control plane node, whether it runs as a static pod or a managed service unit, and who can change its flags and manifests. Confirm that you can edit the configuration on every control plane node and that you hold a rollback copy of the current manifest. Managed Kubernetes services often do not expose these flags, so confirm with the provider whether encryption at rest with a customer-managed key is a supported setting and where it is configured. Done means you have a written inventory of control plane nodes, the current API server flags and a tested way to revert them.

  2. Provision the key management service and restrict its key

    Your security or cloud team creates a key in the key management service your organization already operates, or in an approved external service, and grants use of that key only to the identity the API server runs under. Decide who may administer the key separately from who may use it, and enable audit logging on key usage. Record the key identifier, its rotation settings and the access policy. Confirm the grant by testing that the API server identity can encrypt and decrypt with the key and that a second, ordinary cluster identity cannot. Done means a documented key with a tested access boundary and logging turned on.

  3. Write the encryption configuration file

    The platform engineer writes an EncryptionConfiguration file that names the provider used for Secrets, the key reference and the resource list containing secrets. Keep the identity provider as the last entry only if you need a fallback for reading unencrypted data during migration, and state that choice in your change record. Store the file on each control plane node at a path readable by the API server and restricted to root. Validate the syntax against the version of Kubernetes you run, since the file format depends on the API version your release supports. Done means the file is on every control plane node with matching content and a reviewed copy in version control.

  4. Point kube-apiserver at the configuration and restart

    Add the encryption configuration path to the kube-apiserver startup flags on one control plane node, and mount the file and any key service client material into the API server container or unit. Schedule the change in a maintenance window, because the API server restarts and a misconfigured key reference can block reads and writes to Secrets. Restart one control plane node at a time, and confirm the API server returns healthy before moving to the next. Done means every kube-apiserver instance is running with the flag set, and the cluster answers API requests normally.

  5. Confirm that new Secrets are written encrypted

    Create a test Secret in a non-production or dedicated test namespace with a known marker string in its value. Read the object back through the API to confirm the value is correct, then read the raw record from etcd using the etcd client with the cluster's etcd certificates. The stored value should begin with the encryption provider prefix named in the configuration file and should not contain the marker in readable form. Delete the test Secret afterward. Done means the raw etcd record is ciphertext for a Secret written after the change, and the result is recorded with the command output.

  6. Re-encrypt existing Secrets

    Secrets written before the change remain in their old form until they are rewritten. Run a rewrite of all Secrets through the API, for example by reading and updating each object without changing its data, and do this in batches with a check of API latency and error rates. Include Secrets in every namespace, including those managed by controllers, and confirm that none are skipped. Expect the rewrite to be reviewed with your change board, since it touches every Secret in the cluster. Done means a count of Secrets reconciled matches the count of Secrets in the cluster.

  7. Verify the raw etcd record for sampled Secrets

    Select a sample of existing Secrets from different namespaces and types, including one created before the change, and read each raw record from etcd. Each should show the provider prefix and no readable plaintext. Keep the list of sampled objects, the check output and the timestamp as evidence for your audit file. Also confirm that etcd snapshots taken after this point contain ciphertext and that your snapshot storage access controls still apply. Done means the sampled records are encrypted and the evidence package is filed with the change record.

  8. Document key rotation and the recovery path

    Write down how the key will be rotated, who approves it, and how the encryption configuration is updated when a new key version is added. Test the recovery path in a staging cluster before relying on it, including what happens if the key service is unavailable and how the API server behaves when it cannot decrypt. Include the step that loses access to the key, since that can make Secrets unreadable and can make etcd backups unrecoverable without the key. Done means a tested runbook exists and is linked from the cluster operations documentation.

How the approach changes by environment

In a managed Kubernetes service, the provider runs the control plane, including the API server and etcd, so you do not set the API server encryption flags yourself. Many providers offer their own option to encrypt Secrets with a key you manage in their key service, and some expose a setting for this on cluster creation or as an update. Your team still controls the Secrets objects, RBAC bindings, namespaces and the external secret integration running on your worker nodes. Confirm what the provider exposes before you design around it.

  • Key integration: Check whether the provider supports customer-managed keys for Secrets and whether that setting can be enabled on an existing cluster or only at creation.
  • Key ownership and rotation: Confirm who can rotate or disable the key, and whether rotation re-encrypts existing Secrets.
  • Provider limits: Ask what the provider logs and what it will not expose, such as etcd snapshots and control plane logs.
  • RBAC and namespaces: These remain fully in your hands, so limit list and watch access to Secrets in every namespace.
  • External stores: The Secrets Store CSI Driver runs on your nodes, so check that the cluster can reach the external store.

Before sign-off, check the provider's documentation for the exact key settings, the audit log sources it makes available and the owner of each key policy.

Limiting who can read Secrets

Encryption at rest protects Secrets in etcd, but anyone who can read them through the API, a node or a backup can still see the values. The controls below work together: they narrow who can read Secrets, where they live, which identities can reach them and how values avoid leaking into logs, manifests and host-level access.

Avoid broad list and watch on Secrets

Grant get on named Secrets only where a workload or person needs one. The list and watch verbs return full Secret values in bulk, so a role that includes them lets its holder read every Secret in the namespace. Audit existing ClusterRoles and RoleBindings for wildcards and for these verbs on the secrets resource, and confirm that cluster-wide read access is held only by a small set of administrators.

Secrets good practices

Limit the namespaces that hold Secrets

Keep Secrets for each application in its own namespace and avoid placing unrelated credentials side by side. A role bound in one namespace cannot read Secrets elsewhere, but a ClusterRoleBinding reaches every namespace. Review which teams have rights in shared namespaces such as kube-system and any platform namespace where add-on credentials live, and confirm who can create Pods in those namespaces, since a Pod can mount a Secret it is allowed to use.

Scope service account tokens

Each Pod runs under a service account, and the token mounted into it can be used against the API. Give workloads dedicated service accounts with only the roles they need, and set automountServiceAccountToken: false on Pods that never call the API. Automation identities such as CI pipelines should use short-lived, narrowly bound credentials rather than long-lived tokens stored as Secrets. Confirm which service accounts hold any read access to Secrets.

Protect etcd access and snapshots

Encryption at rest does not help if someone reads etcd directly or copies a snapshot. Restrict client certificates and network access to etcd to the API server and the operators who run it, and treat etcd snapshots as sensitive material: store them encrypted, limit who can retrieve them and log restores. Ask your team who holds etcd client credentials and where snapshots are kept off-cluster.

Keep values out of logs and manifests

Secret values leak most often through kubectl get -o yaml output, debug logs, CI job output, shell history and manifests committed to version control. Reference Secrets by name from Pods instead of inlining values in Deployment specs, and keep base64-encoded values out of Git. Check that application logs and error messages do not print environment variables, and that support bundles and cluster dumps are handled as confidential.

Restrict what a compromised Pod can reach

A Pod that is compromised on a node can read Secrets mounted into it and, with privileged settings, can reach host files that hold credentials. Enforce the Restricted Pod Security Standard on namespaces that run application workloads, and keep the Privileged level away from anything that handles Secrets. Test the setting by confirming that a deliberately privileged Pod is rejected in a namespace labeled for Restricted enforcement.

Pod Security Standards

How to prove Secrets are encrypted and access is limited

Treat encryption at rest and RBAC limits as claims that need a test, not a configuration file. The first check is the raw etcd read: create a test Secret in a non-production namespace, then read its key directly from etcd with etcdctl using the cluster's client certificates. The stored value should begin with the encryption provider prefix you configured in the EncryptionConfiguration file, not readable base64 plaintext. Repeat the check for an existing Secret after you add the new provider, and confirm it was rewritten by reading it again after running a no-op update or a re-encryption pass. Older Secrets stay in plaintext until they are rewritten, so the test must cover them too. Record the API server flags, the file hash and the etcd read output as evidence.

Next, test access limits with a service account that has no Secret rights. Use kubectl auth can-i with --as for list, watch and get across every namespace, and then make the real calls with that account's token, since a passing RBAC check does not prove a workload cannot read Secrets through a mounted token. Confirm that a ClusterRoleBinding granting broad Secret access does not exist for groups such as all authenticated users. Also verify that a wildcard verb or resource in a shared role does not grant list or watch by accident.

Finally, test failure modes on purpose in a staging cluster. Stop or remove access to the key management service, then confirm that creating or updating a Secret fails with an error rather than storing plaintext. Check the API server logs and the encryption status metrics that your Kubernetes version exposes, and confirm which version you run before relying on a specific metric name. For external stores, stop the provider and confirm how pods behave on restart: the Secrets Store CSI Driver should keep failing mounts visible, and running pods should keep their last mounted values according to the driver documentation you confirm for your version. Keep dated test records, the commands used, tester names and fixes with retest results, so an auditor can match each control to a repeatable check.

What to run, back up and document after go-live

Encryption at rest is only as good as the processes around it. The cards below cover the recurring work that keeps Secrets protected after go-live: key lifecycle, backup handling, monitoring, restore testing, upgrade coordination and evidence. Each one should have a named owner in your platform team.

Rotate keys and re-encrypt Secrets

Encryption at rest depends on a key that must be rotated on a schedule your team sets and documents. Rotation means adding a new key to the encryption configuration, restarting kube-apiserver so it encrypts with the new key, and then rewriting existing Secrets so they are stored under it. Check that old keys are retired only after every Secret has been rewritten, and confirm with your key management provider how key versions and deletion are handled.

Secrets good practices

Treat etcd snapshots as sensitive

An etcd snapshot contains the same Secret data that etcd holds, so a plain snapshot file can expose credentials even when the live cluster is encrypted. Store snapshots encrypted, restrict who can read or copy them, and keep them off the cluster nodes. Confirm that your backup tooling, object storage and off-site copies all follow the same access rules as the control plane.

etcd operations guide

Monitor RBAC changes and Secret access

Least-privilege RBAC limits who can read Secrets, but permissions drift over time. Enable audit logging for Secret reads, writes and RBAC object changes, and alert on unexpected role bindings or on list and watch calls from service accounts that should not have them. Review these logs on a set cadence so that access anomalies are caught by people, not discovered during an incident.

Rehearse restore with encryption in place

A restore that works without the encryption configuration can fail once the cluster depends on it. Rehearse restoring an etcd snapshot into a test environment where the same encryption configuration and key access are present, and confirm that Secrets decrypt correctly. Record how long the drill takes and which steps needed a person, so the runbook reflects what actually happens.

Align key ownership with the upgrade plan

Upgrades can change how encryption providers are loaded, and kube-apiserver upgrades must happen one minor version at a time. Assign an owner for the key management integration, the encryption configuration and any KMS plugin, and include them in each upgrade rehearsal in staging. Confirm with your distribution and key management vendor which versions their plugins support before scheduling an upgrade.

Version skew policy

Document the encryption model as evidence

Assessors and internal reviewers will ask how Secrets are protected, who holds the keys, and who can read Secrets. Keep a current record of the encryption configuration, key custody and rotation history, the access model and the audit logs that prove it works. Store this record with the platform documentation so it is reviewed whenever the cluster changes.

What drives effort and cost in secrets work

This table lists the factors that change the effort of securing Secrets in a Kubernetes platform, how each one raises work, and what keeps it contained. Use it to scope internal work or to check that a partner's quote accounts for each driver. Most of the cost comes from people and their time, with licensed services as a smaller, recurring component in some designs.

DriverWhy it changes effort or costHow to keep it down
Number of clusters and environmentsEach cluster needs its own encryption configuration, key references, RBAC and verification. Work multiplies across development, staging and production.Use one standard encryption configuration pattern applied to every cluster, and keep environment differences in version-controlled settings.
Number of Secrets and consuming workloadsEvery workload that reads Secrets must be mapped to a service account and least-privilege role, and each mapping needs review.Adopt standard namespace patterns and group workloads by sensitivity so roles are reused instead of written per application.
Migration from existing manifestsSecret values committed in manifests, Helm values or CI variables must be found, rotated and removed from history. This is often the largest one-time task.Inventory sources first, rotate exposed values, and move each secret once into the chosen store rather than copying it between tools.
Values sourced from external storesEach external store needs authentication from the cluster, a provider configuration, sync rules and failure handling for store outages.Limit the number of providers, and document one access pattern per provider that all teams follow.
Number of external store providersEach provider adds its own identity setup, audit trail, rotation mechanics and ongoing support, so total effort rises with every additional provider.Standardize on one primary store where possible and confirm each provider's support model before adding it.
Key custody model and approvalsDeciding who owns key material, who can use it and how key changes are approved adds design work and review cycles with security and legal teams.Agree a written custody model and approval path early, and reuse it for each environment instead of redesigning per cluster.
Air-gapped or restricted networksKey management and external store connections may need private endpoints, local key services or offline procedures for rotation and recovery.Confirm which key service and store options work inside the network before design begins, and test restore paths offline.
Compliance evidence scopeAssessors may ask for configuration proof, access reviews, key rotation logs and restore tests. Each item must be collected and kept current.Define the evidence list in advance and automate exports from configuration, audit logs and access reviews.
Rotation and recovery runbooksWithout documented procedures, every rotation or key recovery event becomes a custom project, and staff turnover adds retraining cost.Write one rotation runbook per secret type and rehearse it, so routine changes follow a known procedure.

Questions teams ask before encrypting Kubernetes Secrets

Are Kubernetes Secrets encrypted by default?

No. Secrets are stored unencrypted in etcd by default, according to the Kubernetes good practices documentation for Secrets. Anyone who can read the etcd data directory or take an etcd snapshot can read the values, so encryption at rest has to be configured on the API server. The configuration covers which resources are encrypted and which key provider is used. Encryption also does not replace access control: anyone with permission to read Secrets through the API still sees them, so RBAC limits and audit logging remain part of the same change. Confirm the exact encryption provider options for your Kubernetes version and distribution before planning the change.

What does encrypting Secrets cost, and what drives the price?

The cost has three parts: the engineering work to configure the API server and key provider, the key management service itself, and the ongoing operation of rotation and backups. Most of the one-time cost is in planning and testing, not in the configuration change. Costs rise with the number of clusters, the number of key providers you must support, how many teams need to change their applications, and whether the key service already exists in your environment. Recurring costs include key service fees under your cloud or vendor contract and the time your platform team spends on key rotation and restore checks. Ask for the quote to separate one-time work from recurring operations, and to name who pays for the key service.

How long does it take, and what depends on cluster size?

Duration depends on how many clusters are in scope, how many Secrets exist, how many workloads read them, and when your change windows fall. A single lab cluster with few Secrets is a short exercise. Production estates need staging rehearsals, a rollout plan per cluster, and a rotation of existing Secrets after encryption is enabled, because data written before the change stays unencrypted until it is rewritten. Change freezes and approval cycles often set the pace more than the technical work. Ask the provider for a written schedule that lists rehearsal, change windows and verification steps, and state which clusters must be changed first.

What must our team provide before the work starts?

The team needs to provide four things: access to the target clusters with rights to change API server configuration, access to the key management service with permission to create and use keys, named owners for each application that reads Secrets, and a change window for each environment. Without application owners, the rotation of workload Secrets and the test of restarts cannot be planned. You should also provide the audit logging destination, the backup location for etcd snapshots and a decision on who approves key rotation. Confirm with your platform team whether the API server runs as a managed control plane, because that changes what you can configure yourself.

Can our own engineers do this without a partner?

Yes, if they have hands-on experience with the Kubernetes API server, etcd and your key management service, and if they can test the change in staging before production. The risky parts are a wrong key configuration that makes the API server unable to read Secrets, and a missing backup of the key or etcd data before the change. Teams with a small platform group often use a partner for the first rollout and then keep the runbook in house. Ask a partner to show how the work is scoped in writing, what it leaves in your hands, and how it is handed over.

When is an external secret store worth the added dependency?

An external secret store is worth considering when secrets must be managed by a central team, rotated on a schedule across several platforms, or kept outside the cluster entirely. The Secrets Store CSI Driver lets pods mount secrets from an external store, so values need not be stored as Kubernetes Secrets at all. The trade-off is another system to run, another availability dependency for pod startup and another permission model to review. For a single cluster with a modest number of secrets, encryption at rest with strict RBAC may be enough. Ask for a written comparison of both options that names the dependencies each adds.

How DeployOpen scopes and hands over secrets work

DeployOpen plans and builds Kubernetes secrets protection inside your own infrastructure, starting from a written scope that covers encryption at rest, access limits and any external secret store. Each step ends with documented evidence your security and compliance teams can review.

How we scope

  • Inventory which workloads store credentials in Secrets and which namespaces and service accounts read them today.
  • Confirm the key management service your organization uses and who owns key rotation and access approval.
  • Agree in writing whether external stores through the Secrets Store CSI Driver are in or out of the engagement.

How we build

  • Configure encryption at rest for Secrets in etcd using a KMS provider, then verify existing Secrets are re-encrypted.
  • Restrict list and watch access on Secrets with least-privilege RBAC roles reviewed against each team's actual needs.
  • Test that application workloads still start, read Secrets and rotate keys without exposing values in logs or manifests.

How we hand over

  • Deliver configuration files, RBAC manifests and a runbook for key rotation and encryption provider recovery.
  • Document which control evidence exists for each decision so your auditors can trace it to a configuration.
  • Walk your platform and security teams through the setup and record the handover in the agreed deliverables list.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Ask any provider to confirm how key loss, provider outages and Kubernetes version upgrades are covered in the quote.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.