KubernetesCXIV · Certificate and TLS OperationsCertificate and TLS operations
Certificate rotation and renewal — the operational discipline
What you'll learn
- Configure certificate rotation via cert-manager renewBefore
- Handle renewal failures (rate limits, CA compromise, DNS propagation)
- Apply the overlap period for safe rotation
- Build the operational discipline of monitoring and testing renewal
Prerequisites
Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16
Certificate rotation and renewal is the operational discipline of certificate management. This lesson walks cert-manager’s automatic renewal, the failure modes, the rotation strategy, and the discipline.
cert-manager automatic renewal
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: myapp-cert
spec:
secretName: myapp-tls
duration: 2160h # 90 days
renewBefore: 720h # renew 30 days before expiry
issuerRef:
name: letsencrypt-prod
cert-manager monitors each certificate and renews it
before renewBefore. The renewal is automatic; no
human intervention required.
The renewal flow:
- cert-manager checks the certificate’s expiry
against
renewBefore. - If within the renewal window, cert-manager requests a new certificate from the Issuer.
- The Issuer returns the new certificate.
- cert-manager updates the Secret with the new material.
- The kubelet syncs the Secret to the Pod’s volume.
The renewal flow
flowchart LR
A[cert-manager checks expiry] --> B{Within renewBefore?}
B -->|No| C[No action]
B -->|Yes| D[Request new cert]
D --> E{Success?}
E -->|Yes| F[Update Secret]
E -->|No| G[Retry with backoff]
G --> D
F -->|kubelet sync| H[Pod volume updated]
The renewal flow:
- cert-manager periodically checks each certificate’s expiry.
- Within the renewal window, cert-manager requests a new certificate.
- If successful, the Secret is updated.
- The kubelet syncs the Secret to the Pod’s volume (eventually consistent).
- If the request fails, cert-manager retries with exponential backoff.
The failure modes
flowchart LR
A[Failure modes] --> B[ACME rate limits]
A --> C[CA key compromised]
A --> D[DNS propagation]
A --> E[Network egress blocked]
A --> F[Issuer misconfigured]
The failure modes:
- ACME rate limits. Let’s Encrypt limits certificates per domain per week; renewal bursts can exhaust the quota.
- CA key compromised. The CA’s private key is compromised; every certificate signed by it must be revoked.
- DNS propagation. A dns-01 challenge requires DNS propagation; slow propagation delays the renewal.
- Network egress blocked. NetworkPolicy blocks ACME traffic; renewal fails.
- Issuer misconfigured. The Issuer’s configuration is wrong (expired account, mis-typed email).
The rotation strategy
flowchart LR
A[New cert issued] --> B[Old cert still valid]
B --> C[Overlap period]
C --> D[Application uses new cert]
D --> E[Old cert expires]
The rotation strategy:
- Overlap period. The new certificate is available before the old expires. Default with Let’s Encrypt: 60 days overlap (90-day cert, renewBefore 30 days).
- Application reload. The application hot-reloads the certificate without restart.
- Canary. A canary deployment validates the new certificate before full rollout.
The overlap period is the safety margin; if the new certificate is broken, the old certificate is still valid for a while.
The monitoring
certmanager_certificate_expiration_timestamp_seconds - time() < 86400 * 14
Alert when a certificate expires within 14 days. This is a backup; cert-manager should renew automatically before the alert fires.
sum by (namespace, name) (certmanager_certificate_ready_status{condition="True"})
Alert when no certificate is ready (renewal failed).
Quiz
Knowledge check · 4 questions
Q1. What does cert-manager's `renewBefore` control?
Q2. Monitoring should alert on approaching certificate expiry even where renewal is automated.
Q3. Recover from a wave of simultaneous renewals that has hit the ACME rate limit, and prevent the next one.
Forty Certificates for subdomains of example.com were all created on the same afternoon three months ago, each with duration 2160h and renewBefore 720h. They all entered their renewal window within the same hour. `kubectl get certificaterequests -A` shows 31 in a failed state, and the Order status carries `429 urn:ietf:params:acme:error:rateLimited: too many certificates already issued for example.com`. The oldest affected certificates expire in 29 days.
Q4. With duration 2160h and renewBefore 720h, how long is the window in which both the new and the old certificate are valid, and which two cert-manager metrics should alert on renewal trouble?
Passing score: 75%. Answers are checked in this browser.
The operational discipline
Certificate rotation in production rests on five non-negotiable elements:
- renewBefore 30 days. Generous safety margin.
- Overlap period. New cert before old expires.
- Hot-reload support. Application reloads without restart.
- Monitor expiry. Alert on certs expiring soon.
- Test renewal quarterly. Verify cert-manager renews correctly.
Certificate rotation is production TLS management. The discipline is automatic renewal with monitoring and testing.