How the kubelogin system test works
masterThe system test automates the end-to-end OIDC authentication flow. It prepares a local environment by:
- Generating CA and TLS server certificates for Dex.
- Running Dex in a container.
- Creating a Kubernetes cluster via Kind.
- Mutating
/etc/hostsin both the host machine and the Kind container to ensure Dex is resolvable by both the browser and thekube-apiserver.
The Authentication Flow:
kubectlis executed, which triggerskubelogin.kubelogininvokeschromeloginto open a browser.- The user enters credentials at
http://localhost:8000. kubelogincaptures the authorization code and exchanges it for a token.kubectluses the token to access the API.kube-apiserververifies the token against Dex.- The test succeeds if
kubectlexits with code 0.