Give someone access
Give an IAM user, group or role an access entry on a cluster with an access policy, change it, or remove it.
Replace my-cluster with your cluster's name or id, jane with the IAM user's name, and
payments with a namespace. The person also needs eks:AccessKubernetesApi on the cluster in IAM
to get a token; see Cluster access.
Prerequisites
- Permission for
eks:CreateAccessEntryon the cluster, andeks:AssociateAccessPolicyto give policies with it. The console always gives one policy, so it needs both. - To remove an entry,
eks:DeleteAccessEntry; to add or remove a policy later,eks:AssociateAccessPolicyoreks:DisassociateAccessPolicy; to change the username or extra groups,eks:UpdateAccessEntry. The console enables Remove, Associate and a policy's Remove only with these on every cluster (eks:*). - In the console, also
eks:DescribeClusterto open the cluster andeks:ListAccessEntriesto see the entries.
Give access
- Open Kubernetes, open the cluster, then choose Access.
- Under Give access, choose the principal type (IAM user, group or role) and enter its name.
- Choose the access policy, and (except for
ClusterAdmin) enter namespaces to limit it to, or leave them empty for the whole cluster. - Choose Give access.
The entry appears under Access entries.
dcloud eks access-entries create my-cluster --principal-type user --principal jane \
--policies '{"policy":"Edit","namespaces":["payments"]}'POST /eks/api/clusters/my-cluster/access-entries
{
"principalType": "user",
"principal": "jane",
"policies": [{ "policy": "Edit", "namespaces": ["payments"] }]
}resource "dcloud_eks_access_entry" "jane" {
cluster_id = dcloud_eks_cluster.main.id
principal_type = "user"
principal = "jane"
}
resource "dcloud_eks_access_policy_association" "jane_edit" {
cluster_id = dcloud_eks_cluster.main.id
access_entry_id = dcloud_eks_access_entry.jane.id
policy = "Edit"
namespaces = ["payments"]
}Optional fields: username (the Kubernetes username its tokens carry, seen as ews:<username>)
and kubernetesGroups (up to 20 extra groups for your own RBAC). Change them later with
dcloud eks access-entries update; tokens issued before keep the old name and groups until they
expire.
Add or remove a policy
- On the Access tab, choose Policies on the entry's row.
- To add one, choose the policy, enter namespaces or leave them empty, and choose Associate. Associating a policy the entry already has replaces its namespaces.
- To remove one, choose Remove beside it.
- Choose Done.
dcloud eks access-entries associate-policy my-cluster entry-id --policy View
dcloud eks access-entries disassociate-policy my-cluster entry-id EditReplace entry-id with the entry's id from dcloud eks access-entries list.
POST /eks/api/clusters/my-cluster/access-entries/{id}/policies
{ "policy": "View" }Add or remove a dcloud_eks_access_policy_association and apply.
Remove access
On the Access tab, choose Remove on the entry's row and confirm "Remove jane's access to
my-cluster?", or run
dcloud eks access-entries delete my-cluster entry-id. No new token is issued on
the entry from then on; tokens already issued last until they expire (ten minutes).
Refusals
404"No IAM user named "jane"" (or group, or role), "Access entry not found", or "Access policy not found" when removing a policy the entry does not have.409"The user "jane" already has an access entry on this cluster", or the access-entries quota is full.
Related
Related
- POST /eks/api/clusters/{cluster}/access-entries
- PATCH /eks/api/clusters/{cluster}/access-entries/{id}
- DELETE /eks/api/clusters/{cluster}/access-entries/{id}
- POST /eks/api/clusters/{cluster}/access-entries/{id}/policies
- DELETE /eks/api/clusters/{cluster}/access-entries/{id}/policies/{policy}