# PKI certificates and requirements

PKI certificates and requirementsKubernetes requires PKI certificates for authentication over TLS. If you install Kubernetes with kubeadm, the certificates that your cluster requires are automatically generated. You can also generate your own certificates -- for example, to keep your private keys more secure by not storing them on the API server. This page explains the certificates that your cluster requires.How certificates are used by your clusterKubernetes requires PKI for the following operations:Server certificatesServer certificate for the API server endpointServer certificate for the etcd serverServer certificates for each kubelet (every node runs a kubelet)Optional server certificate for the front-proxyClient certificatesClient certificates for each kubelet, used to authenticate to the API server as a client of the Kubernetes APIClient certificate for each API server, used to authenticate to etcdClient certificate for the controller manager to securely communicate with the API serverClient certificate for the scheduler to securely communicate with the API serverClient certificates, one for each node, for kube-proxy to authenticate to the API serverOptional client certificates for administrators of the cluster to authenticate to the API serverOptional client certificate for the front-proxyKubelet's server and client certificatesTo establish a secure connection and authenticate itself to the kubelet, the API Server requires a client certificate and key pair.In this scenario, there are two approaches for certificate usage:Shared Certificates: The kube-apiserver can utilize the same certificate and key pair it uses to authenticate its clients. This means that the existing certificates, such as apiserver.crt and apiserver.key, can be used for communicating with the kubelet servers.Separate Certificates: Alternatively, the kube-apiserver can generate a new client certificate and key pair to authenticate its communication with the kubelet servers. In this case, a distinct certificate named kubelet-client.crt and its corresponding private key, kubelet-client.key are created.Note:front-proxy certificates are required only if you run kube-proxy to support an extension API server.etcd also implements mutual TLS to authenticate clients and peers.Where certificates are storedIf you install Kubernetes with kubeadm, most certificates are stored in /etc/kubernetes/pki. All paths in this documentation are relative to that directory, with the exception of user account certificates which kubeadm places in /etc/kubernetes.Configure certificates manuallyIf you don't want kubeadm to generate the required certificates, you can create them using a single root CA or by providing all certificates. See Certificates for details on creating your own certificate authority. See Certificate Management with kubeadm for more on managing certificates.Single root CAYou can create a single root CA, controlled by an administrator. This root CA can then create multiple intermediate CAs, and delegate all further creation to Kubernetes itself.Required CAs:PathDefault CNDescriptionca.crt,keykubernetes-caKubernetes general CAetcd/ca.crt,keyetcd-caFor all etcd-related functionsfront-proxy-ca.crt,keykubernetes-front-proxy-caFor the front-end proxyOn top of the above CAs, it is also necessary to get a public/private key pair for service account management, sa.key and sa.pub. The following example illustrates the CA key and certificate files shown in the previous table:/etc/kubernetes/pki/ca.crt /etc/kubernetes/pki/ca.key /etc/kubernetes/pki/etcd/ca.crt /etc/kubernetes/pki/etcd/ca.key /etc/kubernetes/pki/front-proxy-ca.crt /etc/kubernetes/pki/front-proxy-ca.key All certificatesIf you don't wish to copy the CA private keys to your cluster, you can generate all certificates yourself.Required certificates:Default CNParent CAO (in Subject)kindhosts (SAN)kube-etcdetcd-caserver, client<hostname>, <Host_IP>, localhost, 127.0.0.1kube-etcd-peeretcd-caserver, client<hostname>, <Host_IP>, localhost, 127.0.0.1kube-etcd-healthcheck-clientetcd-caclientkube-apiserver-etcd-clientetcd-caclientkube-apiserverkubernetes-caserver<hostname>, <Host_IP>, <advertise_IP>1kube-apiserver-kubelet-clientkubernetes-casystem:mastersclientfront-proxy-clientkubernetes-front-proxy-caclientNote:Instead of using the super-user group system:masters for kube-apiserver-kubelet-client a less privileged group can be used. kubeadm uses the kubeadm:cluster-admins group for that purpose.where kind maps to one or more of the x509 key usage, which is also documented in the .spec.usages of a CertificateSigningRequest type:kindKey usageserverdigital signature, key encipherment, server authclientdigital signature, key encipherment, client authNote:Hosts/SAN listed above are the recommended ones for getting a working cluster; if required by a specific setup, it is possible to add additional SANs on all the server certificates.Note:For kubeadm users only:The scenario where you are copying to your cluster CA certificates without private keys is referred as external CA in the kubeadm documentation.If you are comparing the above list with a kubeadm generated PKI, please be aware that kube-etcd, kube-etcd-peer and kube-etcd-healthcheck-client certificates are not generated in case of external etcd.Certificate pathsCertificates should be placed in a recommended path (as used by kubeadm). Paths should be specified using the given argument regardless of location.DefaultCNrecommendedkeypathrecommendedcertpathcommandkeyargumentcertargumentetcd-caetcd/ca.keyetcd/ca.crtkube-apiserver--etcd-cafilekube-apiserver-etcd-clientapiserver-etcd-client.keyapiserver-etcd-client.crtkube-apiserver--etcd-keyfile--etcd-certfilekubernetes-caca.keyca.crtkube-apiserver--client-ca-filekubernetes-caca.keyca.crtkube-controller-manager--cluster-signing-key-file--client-ca-file,--root-ca-file,--cluster-signing-cert-filekube-apiserverapiserver.keyapiserver.crtkube-apiserver--tls-private-key-file--tls-cert-filekube-apiserver-kubelet-clientapiserver-kubelet-client.keyapiserver-kubelet-client.crtkube-apiserver--kubelet-client-key--kubelet-client-certificatefront-proxy-cafront-proxy-ca.keyfront-proxy-ca.crtkube-apiserver--requestheader-client-ca-filefront-proxy-cafront-proxy-ca.keyfront-proxy-ca.crtkube-controller-manager--requestheader-client-ca-filefront-proxy-clientfront-proxy-client.keyfront-proxy-client.crtkube-apiserver--proxy-client-key-file--proxy-client-cert-fileetcd-caetcd/ca.keyetcd/ca.crtetcd--trusted-ca-file,--peer-trusted-ca-filekube-etcdetcd/server.keyetcd/server.crtetcd--key-file--cert-filekube-etcd-peeretcd/peer.keyetcd/peer.crtetcd--peer-key-file--peer-cert-fileetcd-caetcd/ca.crtetcdctl--cacertkube-etcd-healthcheck-clientetcd/healthcheck-client.keyetcd/healthcheck-client.crtetcdctl--key--certSame considerations apply for the service account key pair:private key pathpublic key pathcommandargumentsa.keykube-controller-manager--service-account-private-key-filesa.pubkube-apiserver--service-account-key-fileThe following example illustrates the file paths from the previous tables you need to provide if you are generating all of your own keys and certificates:/etc/kubernetes/pki/etcd/ca.key /etc/kubernetes/pki/etcd/ca.crt /etc/kubernetes/pki/apiserver-etcd-client.key /etc/kubernetes/pki/apiserver-etcd-client.crt /etc/kubernetes/pki/ca.key /etc/kubernetes/pki/ca.crt /etc/kubernetes/pki/apiserver.key /etc/kubernetes/pki/apiserver.crt /etc/kubernetes/pki/apiserver-kubelet-client.key /etc/kubernetes/pki/apiserver-kubelet-client.crt /etc/kubernetes/pki/front-proxy-ca.key /etc/kubernetes/pki/front-proxy-ca.crt /etc/kubernetes/pki/front-proxy-client.key /etc/kubernetes/pki/front-proxy-client.crt /etc/kubernetes/pki/etcd/server.key /etc/kubernetes/pki/etcd/server.crt /etc/kubernetes/pki/etcd/peer.key /etc/kubernetes/pki/etcd/peer.crt /etc/kubernetes/pki/etcd/healthcheck-client.key /etc/kubernetes/pki/etcd/healthcheck-client.crt /etc/kubernetes/pki/sa.key /etc/kubernetes/pki/sa.pub Configure certificates for user accountsYou must manually configure these administrator accounts and service accounts:FilenameCredential nameDefault CNO (in Subject)admin.confdefault-adminkubernetes-admin<admin-group>super-admin.confdefault-super-adminkubernetes-super-adminsystem:masterskubelet.confdefault-authsystem:node:<nodeName> (see note)system:nodescontroller-manager.confdefault-controller-managersystem:kube-controller-managerscheduler.confdefault-schedulersystem:kube-schedulerNote:The value of <nodeName> for kubelet.conf must match precisely the value of the node name provided by the kubelet as it registers with the apiserver. For further details, read the Node Authorization.Note:In the above example <admin-group> is implementation specific. Some tools sign the certificate in the default admin.conf to be part of the system:masters group. system:masters is a break-glass, super user group can bypass the authorization layer of Kubernetes, such as RBAC. Also some tools do not generate a separate super-admin.conf with a certificate bound to this super user group.kubeadm generates two separate administrator certificates in kubeconfig files. One is in admin.conf and has Subject: O = kubeadm:cluster-admins, CN = kubernetes-admin. kubeadm:cluster-admins is a custom group bound to the cluster-admin ClusterRole. This file is generated on all kubeadm managed control plane machines.Another is in super-admin.conf that has Subject: O = system:masters, CN = kubernetes-super-admin. This file is generated only on the node where kubeadm init was called.For each configuration, generate an x509 certificate/key pair with the given Common Name (CN) and Organization (O).Run kubectl as follows for each configuration:KUBECONFIG=<filename> kubectl config set-cluster default-cluster --server=https://<host ip>:6443 --certificate-authority <path-to-kubernetes-ca> --embed-certs KUBECONFIG=<filename> kubectl config set-credentials <credential-name> --client-key <path-to-key>.pem --client-certificate <path-to-cert>.pem --embed-certs KUBECONFIG=<filename> kubectl config set-context default-system --cluster default-cluster --user <credential-name> KUBECONFIG=<filename> kubectl config use-context default-system These files are used as follows:FilenameCommandCommentadmin.confkubectlConfigures administrator user for the clustersuper-admin.confkubectlConfigures super administrator user for the clusterkubelet.confkubeletOne required for each node in the cluster.controller-manager.confkube-controller-managerMust be added to manifest in manifests/kube-controller-manager.yamlscheduler.confkube-schedulerMust be added to manifest in manifests/kube-scheduler.yamlThe following files illustrate full paths to the files listed in the previous table:/etc/kubernetes/admin.conf /etc/kubernetes/super-admin.conf /etc/kubernetes/kubelet.conf /etc/kubernetes/controller-manager.conf /etc/kubernetes/scheduler.conf any other IP or DNS name you contact your cluster on (as used by kubeadm the load balancer stable IP and/or DNS name, kubernetes, kubernetes.default, kubernetes.default.svc, kubernetes.default.svc.cluster, kubernetes.default.svc.cluster.local) ↩︎