Sub topic 6
Who Can Talk to the Cluster
This chapter assumes you know IAM roles and policies, and Kubernetes RBAC (Roles, ClusterRoles and bindings). It also assumes you have the demo cluster from the earlier chapter.
Two Steps: Authentication and Authorization
Every request to the EKS API server passes two checks.
- Authentication answers "who are you?" EKS uses your IAM identity. The AWS CLI signs a token, and EKS validates it with IAM.
- Authorization answers "what may you do?" Kubernetes RBAC decides this. IAM policies such as
eks:DescribeClusteronly control the AWS API, not what you can do inside the cluster.
Access Entries
An access entry links an IAM principal (a user or role) to Kubernetes permissions. It replaced the older aws-auth ConfigMap, which was easy to break with a single YAML typo.
A cluster has one of three authentication modes:
| Mode | Source of access |
|---|---|
| `CONFIG_MAP` | Only the `aws-auth` ConfigMap |
| `API_AND_CONFIG_MAP` | Access entries and the ConfigMap |
| `API` | Only access entries |
New clusters should use API. If you inherit an older cluster, switch it to API_AND_CONFIG_MAP first. The change cannot be reversed to CONFIG_MAP.
aws eks update-cluster-config \
--name demo \
--access-config authenticationMode=API_AND_CONFIG_MAPGranting Access
You can give a role read-only access to one namespace in two commands. The first creates the entry. The second attaches an AWS-managed access policy limited to the default namespace.
aws eks create-access-entry \
--cluster-name demo \
--principal-arn arn:aws:iam::111122223333:role/dev-team
aws eks associate-access-policy \
--cluster-name demo \
--principal-arn arn:aws:iam::111122223333:role/dev-team \
--policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSViewPolicy \
--access-scope type=namespace,namespaces=defaultThe managed access policies cover common needs:
AmazonEKSClusterAdminPolicy: full control of the cluster.AmazonEKSAdminPolicy: administer most resources in the chosen scope.AmazonEKSEditPolicy: create and change resources.AmazonEKSViewPolicy: read-only.
For finer rules, give the entry a Kubernetes group with --kubernetes-groups and bind that group to your own Role or ClusterRole.
The principal then runs aws eks update-kubeconfig --name demo --region us-east-1. Kubeconfig stores no password. It calls aws eks get-token for each session.
Common Errors
You must be logged in to the server (Unauthorized): no access entry exists for this principal, or you are using a different IAM identity than you think. Runaws sts get-caller-identityto check.forbidden: User ... cannot list resource: authentication worked but RBAC denies the action. Add an access policy or group binding.- A role works in the console but not in kubectl: console AWS permissions and cluster permissions are separate.
- Entries ignored: the cluster is still in
CONFIG_MAPmode.
Exercise
A developer's role has an access entry with AmazonEKSViewPolicy scoped to namespace default. They can run kubectl get pods but get "forbidden" on kubectl delete pod web-1. Is this a bug, and how would you allow deletion?
Show answer
It is not a bug. Authentication succeeded, but the view policy is read-only, so RBAC denies the delete. Associate AmazonEKSEditPolicy (scoped to the same namespace) with the principal, or map it to a Kubernetes group bound to a custom Role that allows delete on pods.