Updating OpenShift cluster certificates
This document provides instructions on updating the certificates for the OpenShift 4.x cluster’s router and API server using Let’s Encrypt service.
1. Prerequisites
Before updating certificates, make sure you have the following:
-
Your cluster role is
cluster-admin
. -
OpenShift CLI (
oc cli
) is installed. -
You can create and edit DNS records in the hosted zone which contains the domain name of the cluster. In this document, we’ll refer to this domain name as
DNS_WILDCARD
. -
Certbot is installed.
To learn how to install Certbot, refer to Certbot instructions.On the Certbot instructions page, select the following options:
-
My HTTP website is running: select Other.
-
on: select your operating system (for example, macOS).
Figure 1. Certbot instructions pagePerforming any instructions other than installing Certbot is not necessary. -
2. Updating certificates
-
Start the console as a user with
sudo
privileges. -
Run the following command:
certbot certonly --manual
-
First run only: when prompted, enter your email address and agree to the terms of use, then choose whether you wish to share your email with the Electronic Frontier Foundation.
Specify domain names for certificates:
-
*.<DNS_WILDCARD>
.For example: *.openshift.example.com
. -
*.apps.<DNS_WILDCARD>
.For example: *.apps.openshift.example.com
.
-
-
Perform this optional step:
If you get the following message:
"You have an existing certificate that has exactly the same domains or certificate name you requested and isn’t close to expiry."
, select the Renew & replace the certificate option. -
In the hosted zone which contains the
DNS_WILDCARD
of the cluster, create the TXT records required by Certbot. Before you hit Enter, make sure the record exists and is up-to-date by running the following command in a different console window:nslookup -type=txt <dns_record>
Figure 2. Verifying the record -
If the certificate is issued successfully, you will get a corresponding message with the path to the key and certificate chain files:
Figure 3. Certificate saved successfully -
Delete the old router and API
secret
by running these commands:oc delete secret router-certs -n openshift-ingress oc delete secret router-certs -n openshift-config
-
Create the new router and API
secret
by running these commands:oc create secret tls router-certs --cert=<fullchain.pem> --key=<privkey.pem> -n openshift-ingress oc create secret tls router-certs --cert=<fullchain.pem> --key=<privkey.pem> -n openshift-config
-
Delete router pods by running the following command:
oc delete pods --all -n openshift-ingress