# Cluster access

How a person or a workload gets into a cluster, who they are inside it, and what the four access policies allow.

Getting into a cluster with kubectl takes two things:

1. An IAM allow on `eks:AccessKubernetesApi` for the cluster: who may ask for a token at all.
2. An access entry on the cluster for the IAM user, for a group the user is in, for a role
   assigned to the user, or for the role the caller acts as: what they may do inside it.

Either alone gets nobody in. A token request without an access entry is refused with `403` "You
have no access entry on _my-cluster_. Ask someone with eks:CreateAccessEntry to add one."

## Tokens

kubectl asks the dcloud CLI for a token on every call (`dcloud eks get-token`, which
`dcloud eks update-kubeconfig` writes into the kubeconfig as an exec plugin). A token is valid for
ten minutes and for that cluster only. Nothing secret is written to the kubeconfig. Removing an
access entry stops new tokens at once; a token already issued lasts until it expires.

## Who you are inside the cluster

| Kubernetes | Value                                                                           |
| ---------- | ------------------------------------------------------------------------------- |
| Username   | `ews:<IAM user name>`, or `ews:<username>` when an access entry sets a username |
| Groups     | One per access policy and scope, plus the entry's extra Kubernetes groups       |

The groups of an access policy are `ews:access:<policy>` cluster-wide (for example
`ews:access:edit`) and `ews:access:<policy>:ns:<namespace>` for each namespace it is limited to. The
cluster keeps one RBAC binding per policy and scope that names these groups. For anything finer,
give an entry extra Kubernetes groups and bind them with your own RBAC. Usernames and groups
starting `system:` are refused, and so are extra groups starting `ews:`.

## Access policies

| Policy         | Kubernetes role | Scope                                 |
| -------------- | --------------- | ------------------------------------- |
| `ClusterAdmin` | `cluster-admin` | always the whole cluster              |
| `Admin`        | `admin`         | the whole cluster, or some namespaces |
| `Edit`         | `edit`          | the whole cluster, or some namespaces |
| `View`         | `view`          | the whole cluster, or some namespaces |

An entry can hold several policies. Associating a policy it already has replaces its namespaces.

## The creator

Whoever creates a cluster gets a `ClusterAdmin` access entry on it; when the creator acts through
an IAM role, the entry is for that role. It can be removed like any other.

## Break glass

When Deutsche Cloud sign-in or the cluster's RBAC is broken, someone allowed
`eks:GetClusterAdminCredentials` can take a `cluster-admin` client certificate valid for one hour.
It cannot be revoked. See [Use break-glass credentials](use-break-glass-credentials.md).

## Workloads

Pods do not use access entries to reach Deutsche Cloud: a pod identity association lets the pods of
a service account act as an IAM role. See
[Let pods act as an IAM role](let-pods-act-as-an-iam-role.md).

## Related

- [Give someone access](give-access.md)
- [Connect with kubectl](connect-with-kubectl.md)
- [Security](security.md)
