How to Configure EKS Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up eks least privilege by mapping cloud identities to narrow Kubernetes roles. You then bind those roles to one namespace instead of the whole cluster. Most teams start by giving developers broad admin rights to speed up work. That choice lets one bad command or stolen key break every running app. Scoping permissions down to exact resources and verbs stops this wide blast radius. How eks least privilege works in Kubernetes Kubernetes uses Role-Based Access Control to check every reque

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 least privilege by mapping cloud identities to narrow Kubernetes roles. You then bind those roles to one namespace instead of the whole cluster. Most teams start by giving developers broad admin rights to speed up work. That choice lets one bad command or stolen key break every running app. Scoping permissions down to exact resources and verbs stops this wide blast radius.

How eks least privilege works in Kubernetes

Kubernetes uses Role-Based Access Control to check every request sent to the API server. In this model, all rules are additive, and there are no deny rules. You start with zero permissions and add only the exact actions a user needs. A Role sets permissions inside one single namespace for a specific team. A ClusterRole sets permissions across the whole cluster for nodes or all namespaces.

After you define a Role, you connect it to a user or group. A RoleBinding grants those permissions inside one specific namespace. A RoleBinding can point to a local Role or a shared ClusterRole. When you link a ClusterRole with a RoleBinding, the user only gets local rights. A ClusterRoleBinding gives access across the entire cluster and all namespaces at once.

To keep access tight, teams avoid ClusterRoleBindings for daily developer tasks. Instead, they create separate namespaces for each app or team. They give engineers read rights on pods and logs in their own namespace. They also restrict sensitive subresources like pod exec or pod log paths. In the RBAC API, these subresources use a slash between the resource and action. Granting pod read rights does not allow shell access unless you add the subresource.

Scoping workloads and service accounts

Human users are only half of the access picture in a cluster. Pods also talk to the Kubernetes API and to external cloud services. Each pod runs with a service account that holds its own permissions. If you leave the default service account open, any compromised pod can make changes. You should create a dedicated service account for each workload that needs API rights.

You then bind that service account to a small Role in its own namespace. The Role should list only the exact resources and verbs the app needs. Most apps do not need to talk to the Kubernetes API at all. For those apps, you can give the service account zero RBAC rules. This step stops an attacker who breaks into a container from moving sideways.

Least Privilege Principle + EKS Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Where native cluster roles fall short

Native roles and bindings do a great job of controlling who enters the cluster. They decide which user can read a pod or open a shell session. Still, static RBAC rules only check the initial API call at the door. Once a developer opens an exec session, RBAC stops checking their actions.

Inside that shell, the engineer has full control over the running container process. RBAC cannot see or block the bash commands they type inside the pod. It also cannot mask sensitive data like emails, phone numbers, or card numbers. If a log stream or database query returns private data, the user gets everything. Static roles also stay active all day, even when no ticket is open. Teams must build and maintain complex role files for every small change in access.

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

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding grants permissions inside one single namespace to keep access isolated. A ClusterRoleBinding grants permissions across all namespaces and cluster-wide nodes at once.

Can I write a deny rule in Kubernetes RBAC?

No, Kubernetes RBAC rules are strictly additive and do not support deny rules. You must start with no permissions and grant only the exact verbs needed.

How do I stop developers from running shell commands in pods?

Remove the pod exec subresource from their assigned Role or ClusterRole definition. They can still view pod status without getting interactive shell access to containers.

The query runs. The emails stay hidden.