6.02 Kubernetes Authentication
1οΈβ£ Overview
A Kubernetes cluster consists of:
- Multiple nodes (physical or virtual)
- Control plane components (API server, etcd, scheduler, controller manager)
- Users and services interacting with the cluster
Who Accesses the Cluster?
| Type | Examples | Managed By |
|---|---|---|
| Humans | Admins, Developers | External Identity System |
| Robots | CI/CD, Controllers, Apps | Service Accounts |
| End Users | Application Users | Application Itself |
Note
Kubernetes authentication focuses on cluster access, not end users of deployed applications.
2οΈβ£ User Types in Kubernetes
π€ Human Users
- Administrators
- Developers
- Platform Engineers
β Kubernetes does NOT manage human users natively.
You cannot:
Kubernetes relies on:
- Certificates
- External identity providers
- Token files (not recommended in production)
π€ Service Accounts (Managed by Kubernetes)
Service accounts are used by:
- Pods
- Controllers
- CI/CD tools
- Automation systems
Success
Service Accounts are first-class Kubernetes objects and are fully managed via the API.
3οΈβ£ Authentication Flow
All requests go through the kube-apiserver:
- Client (
kubectl/ curl / automation tool) - kube-apiserver
- Authentication
- Authorization
- Request processing
Or direct API call:
Note
Authentication happens before authorization (RBAC).
4οΈβ£ Authentication Mechanisms
πΉ 1. Static Token File (Basic & Insecure)
CSV format:
Example:
API server configuration:
Authentication request:
curl -k https://<master-ip>:6443/api/v1/pods --header "Authorization: Bearer KpjCVbI7rCFAHYPkBzRb7gu1cUc4B"
Danger
Static token files store credentials in plain text.
- β Not recommended for production
- β No rotation mechanism
- β Requires API server restart
πΉ 2. Certificate-Based Authentication (Recommended)
Users authenticate using:
- Client certificate
- Private key
- Signed by cluster CA
Success
This is the standard production method for admin access.
πΉ 3. Identity Providers (Production Grade)
Enterprise-ready authentication via:
- LDAP
- Active Directory
- OIDC
- Kerberos
- Cloud IAM providers
Configured via API server flags:
Tip
In production, use OIDC with your corporate identity provider.
5οΈβ£ Production Best Practices
β DO
Success
- Use OIDC or external identity provider
- Use certificate-based authentication for admins
- Use Service Accounts for workloads
- Enable RBAC
- Rotate certificates regularly
- Enable audit logging
- Use short-lived tokens
- Store secrets securely (never in Git)
β DON'T
Danger
- Do NOT use static password/token files in production
- Do NOT store credentials in clear text
- Do NOT share kubeconfig files
- Do NOT grant cluster-admin to everyone
- Do NOT disable TLS verification
- Do NOT use long-lived service account tokens without rotation
π― Key Takeaways
- Kubernetes does not manage human users internally
- All authentication happens at kube-apiserver
- Static token files are for learning only
- Production should use:
- Certificates
- OIDC / Identity provider
- RBAC enforcement
Quote
Secure the API server first. Everything in Kubernetes depends on it.