Skip to content

Lesson 1 of 13 · 12m

The API Server Decides Everything

Every cluster action is one HTTPS request through authentication, RBAC authorization, and admission — and a kubeconfig is a credential bundle, not a config file.

Every action is one HTTPS request

There is no "cluster shell." There is no daemon you log into that then decides things. Every change to a Kubernetes cluster is an HTTPS request to kube-apiserver on port 6443, carrying an identity and a verb on a resource. kubectl get pods is GET /api/v1/namespaces/default/pods. A controller scaling a Deployment is PATCH to the same API. Even the kubelet — the agent on each node — reports pod status by calling the API server like any other client.

The request walks a fixed pipeline. Authentication comes first: the API server resolves who sent the request — a client certificate's subject, a bearer token verified through the TokenReview API, OIDC claims from --oidc-issuer-url, or a webhook token authenticator. Authorization comes next: for each request the API server asks "may this identity do this verb on this resource in this namespace?" The answer comes from --authorization-mode, which on every sane cluster is RBAC,Node — Node mode handles what kubelets may write, and it's deliberately narrow: a kubelet credential can update its own Node object and the pods scheduled to it, nothing else. A stolen kubelet cert cannot read your secrets. RBAC handles everything else — including nonResourceURLs like /healthz, /version, and /metrics, which is why kubectl get --raw /metrics is itself an RBAC-checked call.

Kubernetes has no users

The mental model to attack first: the cluster does not have a user list. There is no kubectl create user. Identity arrives with each request — a certificate's CN= and O= fields, a service account JWT's claims, an OIDC sub. This is why a kubeconfig file is not "a config." It is a bundle of bearer credentials. Whoever copies it is that identity. The standard kubeconfig planted by kubeadm authenticates with a client certificate in O=system:masters, and the cluster-admin ClusterRoleBinding grants that group * verbs on * resources — unrestricted control of the cluster, no password, no expiry, no MFA. Treat kubeconfig files like private keys, because they are.

RBAC itself is four objects. Role and ClusterRole are lists of rules: {apiGroups, resources, verbs, resourceNames}. RoleBinding and ClusterRoleBinding attach those rules to subjects — a User, Group, or ServiceAccount. A RoleBinding in namespace payments can reference a ClusterRole and grant it only inside payments; a ClusterRoleBinding applies cluster-wide, including to cluster-scoped resources like nodes.

Check before you grant

The tool nobody uses enough is kubectl auth can-i. It answers the question the API server will answer:

kubectl auth can-i create deployments -n payments --as=deploy-bot
kubectl auth can-i --list -n payments --as=system:serviceaccount:payments:ci
kubectl auth can-i get secrets --as=intern --all-namespaces

--as impersonates any user or service account — itself gated by the impersonate verb, covered next lesson. can-i --list shows the full effective permission set for an identity, which is the fastest way to audit what a service account actually gained from its three RoleBindings.

To see who holds real power, read the bindings, not the roles:

kubectl get clusterrolebindings -o wide | grep cluster-admin
kubectl get rolebindings -A

Default installs ship useful aggregated ClusterRoles — admin, edit, view — which merge labeled sub-roles. view reads most things but notably excludes secrets; that exclusion is deliberate and is the difference between "can see the deployment" and "can read every credential in the namespace."

One more pattern worth knowing: a RoleBinding referencing a ClusterRole grants that cluster-defined role within the binding's namespace only. It's how you hand a tenant "admin in their box" — full power inside team-a, nothing anywhere else — without writing a Role that duplicates the ClusterRole's rules.

What to actually do

  • Grant admin/edit/view or purpose-built Roles; never bind cluster-admin outside bootstrap break-glass.
  • Audit bindings quarterly: who has cluster-admin, who has * wildcards, who can impersonate.
  • Prefer OIDC or service accounts over client certificates, so identity has an issuer you can revoke.

The API server decides everything. Your job is to make sure it decides against the right list.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.