How to Configure EKS Secrets

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up eks secrets by creating Kubernetes Secret objects and binding them to RBAC roles. Then you mount those keys into specific pods as files or variables. Many teams start by giving broad cluster roles to their engineers and apps. This mistake lets any user or pod read all keys across the cluster. When permissions are too wide, one bad command can expose every database password. How eks secrets and native RBAC work together Kubernetes stores sensitive keys inside objects that live withi

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 eks secrets by creating Kubernetes Secret objects and binding them to RBAC roles. Then you mount those keys into specific pods as files or variables. Many teams start by giving broad cluster roles to their engineers and apps. This mistake lets any user or pod read all keys across the cluster. When permissions are too wide, one bad command can expose every database password.

How eks secrets and native RBAC work together

Kubernetes stores sensitive keys inside objects that live within a single namespace. To protect eks secrets, you must set up role-based access control on the API server. In Kubernetes, a Role holds rules that define a set of permissions. All rules in this system are additive, which means there are no deny rules. You only grant the exact actions a user or app needs to run.

A standard Role always sets permissions inside one specific namespace. In contrast, a ClusterRole works across the whole cluster and covers all namespaces. It can also cover cluster-wide objects like nodes. To give these rules to a user, you create a binding object. A RoleBinding grants permissions inside one namespace and can point to a Role or ClusterRole. A ClusterRoleBinding grants those permissions across the entire cluster at once.

When you set up access for a team, stick to single namespaces first. Create a Role that only allows reading secret objects in the app namespace. Then link that Role to the specific service account or user group with a RoleBinding. This keeps a test pod from reading keys that belong to your billing app.

How subresources affect key safety in pods

Protecting the secret object itself is only half of the job in Kubernetes. Once a pod starts, it loads the secret keys into its own memory or files. Kubernetes RBAC names resources using the same path that appears in the API URL. Some API calls use a subresource, such as reading pod logs or running commands. RBAC writes these subresources with a slash, like pods/log or pods/exec.

If an engineer has permission to run commands in a pod, they can read its mounted keys. They do not need direct read access to the secret object on the API server. They can just open a shell inside the running container and print the variables. Also, the resource name filter in RBAC has limits when creating subresources. You must watch who gets exec permissions just as closely as secret read rules.

K8s Secrets Management + EKS Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native setup solves and where gaps remain

Native RBAC is great for deciding which service account can mount a key. It also stops users from listing secret objects in namespaces they do not own. By splitting roles by namespace, you limit the blast radius of a stolen token. This setup solves basic access control at the cluster API level.

Still, native roles only check who logs in and which API call they make. Once a user opens a pod shell or connects to a database, RBAC steps back. It cannot see what individual commands or queries run inside that open session. It also cannot rewrite sensitive fields like emails, phone numbers, or card numbers in results. Teams still face risks when engineers run live commands or debug production pods directly.

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 sits inline as an open-source proxy, a sidecar for your Kubernetes API, without replacing RBAC. On every production call from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for human approval.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run or hold risky deletes for review. 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

Can I write a deny rule to block access to eks secrets?

No, Kubernetes RBAC rules are only additive and do not support deny rules. To block access, you must remove the RoleBinding or ClusterRoleBinding that grants the permission. Start with zero permissions and only add rules for required namespaces.

What is the difference between a RoleBinding and a ClusterRoleBinding for secrets?

A RoleBinding grants secret permissions inside one single namespace. A ClusterRoleBinding grants permissions across every namespace in the entire cluster. Use a RoleBinding so users cannot read keys outside their own project namespace.

Can users without secret permissions still find keys inside pods?

Yes, if a user has permissions for the pods/exec subresource, they can enter the pod. From inside the container, they can read any secret mounted as a file or variable. You must restrict exec permissions to keep mounted keys safe.

The query runs. The emails stay hidden.