Renew API certs for Openshift
-
When the API certs are due to expire (this is tracked in Zabbix)
Overview
The API certs are provided by LetsEncrypt, via a DNS challenge. Therefore, the process is to: - use certbot to generate a challenge - commit a DNS record that matches - obtain the cert - upload to OCP
Notes:
- If working on the staging cluster, replace api.ocp with api.ocp.stg as
required
Steps
-
On any machine (even your own laptop), install and run
certbotsudo dnf install certbot #if required mkdir ~/certbot && cd ~/certbot #if required certbot certonly --expand --keep --manual \ --preferred-challenges=dns -d "api.ocp.fedoraproject.org" \ --config-dir ./config \ --work-dir ./config \ --logs-dir ./logs
This will generate a DNS challenge, which needs to be committed as a TXT record.
-
Follow DNS process for a new host/record
The record will be for
_acme-challenge.api.ocp.fedoraproject.organd you can usegit log/git blameto find prior examples.Allow 20mins for propagation, or use the
update_dns.ymlplaybook as noted in the DNS process to push it faster. You can test it viadig -t TXT _acme-challenge.api.ocp.fedoraproject.organd check it returns the right string. -
Complete the
certbotprocessReturn to the
certbotprocess, and press Enter to tellcertbotto complete the challenge. It should pass and write the files to./config/live/api.ocp.fedoraproject.org -
Copy the files to Openshift control node
DATE=$(date '+%Y-%m-%d') scp ./config/live/api.ocp.fedoraproject.org/privkey.pem os-control01.rdu3.fedoraproject.org:/tmp/api.ocp.fedoraproject.org.key-$DATE scp ./config/live/api.ocp.fedoraproject.org/fullchain.pem os-control01.rdu3.fedoraproject.org:/tmp/api.ocp.fedoraproject.org.cert-$DATE
Change hostname to
.stg.rdu3as required. -
Log in to os-control01.rdu3.fedoraproject.org (or stg, as required)
ssh os-control01.rdu3.fedoraproject.org sudo -i DATE=$(date '+%Y-%m-%d') mv /tmp/api.ocp.fedoraproject.org.key-$DATE /tmp/api.ocp.fedoraproject.org.cert-$DATE /root
-
Delete and replace the cert secret in Openshift
oc delete secret api.ocp.fedoraproject.org -n openshift-config sleep 3 DATE=$(date '+%Y-%m-%d') oc create secret tls api.ocp.fedoraproject.org \ --cert=api.ocp.fedoraproject.org.cert-$DATE \ --key=api.ocp.fedoraproject.org.key-$DATE \ -n openshift-config
-
Wait a few mins and then check the API cert
You can verify the certificate by checking the API endpoint or using OpenShift CLI commands.
Want to help? Learn how to contribute to Fedora Docs ›