K3s Secrets Encryption
You set up k3s secrets encryption by turning on the built-in server encryption setting. This step tells the cluster to lock secret values before saving them to disk. Many teams stop after turning on storage locks and sharing admin roles across engineers. Broad cluster roles still let any logged-in user read secret values in plain text. How k3s secrets encryption works By default, a new cluster stores secret objects as base64 text in its database. Base64 is just an encoding format, not a real
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up k3s secrets encryption by turning on the built-in server encryption setting. This step tells the cluster to lock secret values before saving them to disk. Many teams stop after turning on storage locks and sharing admin roles across engineers. Broad cluster roles still let any logged-in user read secret values in plain text.
How k3s secrets encryption works
By default, a new cluster stores secret objects as base64 text in its database. Base64 is just an encoding format, not a real lock for your sensitive keys. Anyone who reads the raw database file on the server can decode those values.
When you turn on k3s secrets encryption, the server generates an encryption key file. The control plane uses this key to scramble secret data before writing to storage. If an attacker steals a disk backup, the stored secrets stay locked and unreadable. When an app or user asks the API for a secret, the server unlocks it. The API then sends the plain value back to the caller with the right role.
Teams also rotate these storage keys on a regular schedule to keep backups safe. Key rotation follows a four-step process: prepare, rotate, reencrypt, and clean up old keys. During this flow, the server writes new secrets with the fresh key right away. Then it rewrites old records in the background until every secret uses the new key.
What storage encryption solves and what keeps the session active
At-rest encryption solves one specific threat: someone reading the raw cluster datastore on disk. It protects your team when a physical drive or a cloud snapshot gets stolen. Every compliance rule for container platforms expects you to turn on this disk protection.
Still, storage encryption does nothing once a user or script talks to the API. Role bindings in the cluster decide who can log in and call the server. They do not inspect what individual commands do during an active user session.
K8s Secrets Management + Encryption at Rest: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
During a rush to fix a broken app, engineers often share broad admin roles. With those roles, a single command can dump every secret across a whole namespace. Storage locks cannot tell the difference between a normal app read and a dump. Native cluster logs also struggle to link shared role actions to a real person.
Managing key rotation and live cluster sessions
Good cluster security needs both disk encryption and tight control over live API commands. First, turn on at-rest encryption when you create the cluster or during maintenance. Store the master encryption key file on a safe disk with strict file rules. Test your key rotation steps in a staging cluster before running them in production.
Next, look at how engineers and tools run commands against the cluster API. Remove static kubeconfig files from engineer laptops so long-lived keys do not leak. Shrink cluster role permissions so users cannot list all secrets across every namespace. Pair your at-rest storage locks with controls that check every command in flight. Also make sure your team logs which person ran each command and when.
Govern kubectl and API calls in flight
Identity providers and Kubernetes RBAC decide who logs into a cluster. They cannot redact keys inside returned JSON objects or hold a risky delete call for review. By design, hoop.dev runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.
First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. Next, hoop.dev data masking rewrites sensitive keys in returned Secret, ConfigMap, and log responses in memory, and writes each decision to the audit trail. Explore the repo on GitHub.
Frequently asked questions
Does k3s encrypt secrets on disk by default?
No, a standard install stores secret values as base64 text in the cluster datastore. You must turn on the encryption setting on the server to lock stored secrets.
Does k3s secrets encryption hide values from cluster admins?
No, the API server unlocks secret data for any role with read permissions. Anyone with admin permissions can still fetch and read plain secret values through the API.
How often should teams rotate cluster encryption keys?
Most security teams rotate their storage keys every ninety days or after staff changes. You should always take a full datastore snapshot before starting a key rotation run.
Related guides
In this post