Home / Platform management / Certificates / Kubernetes certificate

Kubernetes certificate

Kubernetes certificates are used to verify the identity of Kubernetes components when they communicate with each other over the network in a cluster.

View Certificate

When monitoring components are deployed and running properly in the cluster, you can view information about the Kubernetes certificate for the cluster on the Platform Certificate Management page.

Tip: When a certificate is about to expire or has expired, an alert will be triggered and the default notification policy of the platform (cpaas-admin-notification, manually created during platform deployment) will be used to send alert messages to the notification objects. You can also view detailed alert information on the Operations Center > Firing page of the platform.

Kubernetes Certificate Description
Issuance Method Generated by kubeadm during cluster deployment or manually generated.
Expiration Impact An expired certificate will cause Kubernetes functionality to be unavailable, such as the inability to communicate with the API server of the cluster through the kubectl command or API. Common error messages include:
Unable to connect to the server: x509: certificate has expired or is not yet valid.
Upcoming Expiration When the validity period of a certificate is less than 30 days, a notification will be sent that the certificate is about to expire.
Automatic Rotation Mechanism When the validity period of a certificate is less than 30 days, the platform will attempt to rotate the Kubernetes certificate at a frequency of 5 minutes per attempt. The alert policy for an expiring certificate will remain in the Firing state until the certificate rotation is successful. If the alert does not return to normal for an extended period of time, please contact our operations engineers for support.
Path and Name Validity Renewal Method
/etc/kubernetes/pki/apiserver.crt 10 years Automatic rotation
/etc/kubernetes/pki/apiserver-kubelet-client.crt 10 years Automatic rotation
/etc/kubernetes/pki/apiserver-etcd-client.crt 10 years Automatic rotation
/etc/kubernetes/pki/front-proxy-client.crt 10 years Automatic rotation
/etc/kubernetes/pki/etcd/healthcheck-client.crt 10 years Automatic rotation
/etc/kubernetes/pki/etcd/peer.crt 10 years Automatic rotation
/etc/kubernetes/pki/etcd/server.crt 10 years Automatic rotation
/etc/kubernetes/admin.conf 10 years Automatic rotation
/etc/kubernetes/controller-manager.conf 10 years Automatic rotation

Update the validity period of Kubernetes certificates for self-built business clusters

The validity period of Kubernetes certificates on the self-built business clusters in the platform is 10 years by default. When the certificates expire or need to be adjusted, you can refer to the content of this article to manually update the validity period of the certificates.

Note:

Procedure

  1. Download the script (gen-certs.sh) (right-click on the link and select “Save link as…”) to your local machine.

  2. Copy the script to the /root/ directory on all control nodes of the cluster to be updated.

  3. Log in to each control node in the cluster and execute the corresponding script to update the validity period of the certificates.

    • If the container runtime is Docker, execute the following script:

      export DAYS="3650"      # Validity period after certificate renewal,Value cannot be greater than 3650
      bash gen-certs.sh master  <Node IP>   # master Node's IP
      
      # restart Pod Managed container
      master="apiserver controller-manager scheduler"
      for c in ${master}; do
        docker ps | grep "k8s_kube-${c}_" | awk '{print $1}' | xargs docker restart
      done
    • When the container runtime is Containerd, execute the following script:

      export DAYS="3650"
      bash gen-certs.sh master  <Node IP>  # master Node's IP
      
      # restart Pod Managed container
      master="kube-apiserver kube-controller-manager kube-scheduler"
      for c in ${master}; do
        crictl  ps  | grep "$c" | awk '{print $1}'| xargs crictl stop 
        crictl  ps -a  | grep "$c" | awk '{print $1}'| xargs crictl rm 
      done
  4. Select and execute the corresponding script on the control node to verify whether the certificate has been successfully updated and whether the cluster functions normally.

    • If the Kubernetes version of the cluster is lower than 1.21, execute the following script:

      kubeadm alpha certs check-expiration
    • When the Kubernetes version of the cluster is 1.21 or higher, execute the following script:

      kubeadm certs check-expiration