Updating the TLS certificates on Kubernetes

In Kubernetes, TLS certificates are contained within a secret called tls-secret.

Before you begin

Ensure that you have the certificate and private key to be used.

About this task

To update the certificate on Kubernetes, first you must delete the existing secret and create it again with the new certificate information.

Procedure

  1. Run the following command to verify if the secret currently exists.
    kubectl get secrets
  2. If the tls-secret exists, delete it.
    kubectl delete secret tls-secret
  3. Create a new tls-secret secret with the new certificate and private key.
    create secret tls tls-secret --key tls.key --cert tls.crt
    Where the value for key is the private key file and cert is the certificate file.
  4. Verify
    kubectl get secret tls-secret -o yaml