X.509 Client Certificate Authentication¶
X.509 Client Certificate Authentication is a security mechanism used to verify the identity of a user or service requesting access to a system. In the context of Kubernetes, it is a widely used method for authenticating "normal users" (humans or external processes) accessing the API Server^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md].
Mechanism¶
This method relies on Public Key Infrastructure (PKI). The client must possess a valid certificate that acts as a digital identity card. The server validates this certificate to confirm the client's identity.^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md]
To be accepted by the Kubernetes API Server, the client certificate must meet a critical requirement: it must be signed by the Cluster's Certificate Authority (CA).^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md] This process is conceptually similar to how HTTPS certificates work, with the distinction that the Kubernetes cluster itself acts as the trusted CA rather than an external commercial provider^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md].
User Identification¶
When a user is authenticated via X.509 certificates, Kubernetes determines the username by reading specific fields within the certificate's subject. Specifically, the Common Name (CN) field is used to derive the username, while the Organization (O) field is used to determine group membership^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md].
Implementation Workflow¶
Implementing this authentication typically involves a multi-step process to generate the necessary cryptographic materials:
- Private Key Generation: A private key is generated for the user (e.g., using
openssl genrsa)^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md]. - CSR Creation: A Certificate Signing Request (CSR) is created using the private key. This request includes the subject information (CN and O) that identifies the user^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md].
- CA Signing: The CSR is submitted to the cluster administrator. The administrator uses the cluster's CA certificate and CA private key to sign the request, thereby generating a valid client certificate^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md].
Once the certificate is generated, it is configured in the client's kubeconfig file, associating the certificate and key with a specific user context for future API requests^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md].
Related Concepts¶
- Kubernetes
- [[RBAC]]
- [[Service Account]]
Sources¶
^[400-devops__06-Kubernetes__k8s-ithelp__Day29__README.md]