Checking OpenShift Certificates
This guide covers methods for checking the expiration dates of critical OpenShift certificates, including the API server and Ingress controller. While OpenShift typically auto-rotates most internal certificates, manually verifying them can be useful for troubleshooting and custom monitoring.
Key Certificate Locations
Critical certificates are stored as Kubernetes Secrets across different namespaces:
| Component | Namespace | Secret Name |
|---|---|---|
| API Server | openshift-kube-apiserver | kube-apiserver-cert-key-pair |
| Ingress (default) | openshift-ingress | router-certs-default |
| Controller Manager | openshift-kube-controller-manager | Various cert secrets |
| Scheduler | openshift-kube-scheduler | Various cert secrets |
Quick Checks
Use these one-liners to manually inspect specific certificates.
API Server Certificate
To check the expiration date directly:
To view full certificate details including the validity period:
Default Ingress Controller Certificate
To check the expiration date:
Automated Expiration Checks
When dealing with many certificates, automation is necessary. Here are several approaches for scripting certificate checks.
Option 1: Multi-Namespace Checking
This script iterates over key namespaces and extracts the end date for all TLS secrets:
Option 2: Comprehensive Warning Script (Recommended)
This script calculates the remaining days for each certificate in a namespace and provides warnings if they are close to expiring. It handles epoch time conversion for robust comparison.
Note: Save as check-certs.sh, run chmod +x check-certs.sh, and configure it as a cron job for regular monitoring.
Option 3: Quick One-Liners
If you prefer one-liners over a script, you can use jq to loop through secrets:
Built-In Monitoring
While scripts are helpful for point-in-time checks, OpenShift provides built-in mechanisms for monitoring:
- Prometheus Alerts: OpenShift’s default monitoring stack includes Prometheus alerts for certificate expiration.
- Web Console: Check Observe → Alerting in the OpenShift web console for active certificate expiration warnings.
- CSR Approval: For pending Certificate Signing Requests (often relevant during node addition or cert rotation), check status with
oc get csr -wand approve manually if necessary usingoc adm certificate approve <csr-name>.