Kubernetes CLI authentication flow
The following diagram illustrates the Kubernetes CLI authentication flow.
First, the Kubernetes API server obtains the Keycloak public key. Then, the CLI obtains JSON Web Tokens (JWTs) from Keycloak and uses them to access the Kubernetes API:
The Kubernetes API server requests the OpenID public key of Keycloak.
Keycloak sends its public key to the Kubernetes API server.
kubectlsends an authentication request tokubelogin.kubeloginrequests JWTs from Keycloak.Keycloak returns JWTs signed by its private key.
kubectlsends a request to the Kubernetes API with the JWT.The Kubernetes API server verifies the JWT signature using the Keycloak public key.
The Kubernetes API server verifies the JWT expiration date.
The Kubernetes API server verifies the Role-Based Access Control (RBAC) permissions of the user.
The Kubernetes API server returns the response to
kubectl.
Note
Steps 1 and 2 take place on the Kubernetes API server startup and are not
part of the kubectl request authentication. During these steps, the
Kubernetes API server obtains the Keycloak public key that it later uses
to verify JWTs.
The authentication flow for Helm and other Kubernetes-oriented CLI utilities is identical to the Kubernetes CLI flow, but JWTs must be pre-provisioned.