Here's a pull request that looks like tidying up. Someone renames the Secret a Certificate writes to, so it matches a new naming convention:
apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: api namespace: shop spec: secretName: api-example-com-tls # was: api-tls dnsNames: - api.example.com issuerRef: name: letsencrypt-prod kind: ClusterIssuer The diff is one line. The Certificate goes Ready a minute later. Nothing alerts.
The Ingress in the same namespace still says secretName: api-tls. It wasn't in the PR.
What cert-manager does with the rename
cert-manager issues a certificate into the new Secret, api-example-com-tls. The old Secret, api-tls, stays where it is. Nothing deletes it. Nothing renews it either, because no Certificate points at it anymore.
So the Ingress keeps serving the certificate in api-tls. It's valid today and it will be valid next week. Then one day it expires, weeks after the PR was merged and forgotten.
I read this in the cert-manager v1.21.3 source while writing PR checks for cert-manager changes. Don't take my word for it. The steps below let you see it on a test cluster.
Why the docs don't warn you
The docs cover the nearest case. The Certificate usage page says that by default cert-manager "does not delete the Secret" when its Certificate is deleted, and that you need the --enable-certificate-owner-ref controller flag if you want it cleaned up.
That default is deliberate. Deleting a Certificate by mistake doesn't take your site down. But the page is about deletion. In a rename the Certificate is still there and still Ready, so nobody goes looking for a leftover.
The timing makes it worse. The same page gives the defaults: a certificate lasts 90 days and cert-manager renews it two thirds of the way through. So on the day of the rename, the certificate in the old Secret has somewhere between 30 and 90 days left. That's how long you wait for the outage.
How to check by hand
Everything here is read-only.
Before you merge a rename, find who still uses the old name:
kubectl get ingress,gateway -n shop -o yaml | grep -n 'api-tls' Drop ,gateway if you don't run Gateway API. Check Deployments that mount the Secret as a volume too.
To find leftovers already sitting in a cluster, use the annotation cert-manager puts on each Secret it issues, cert-manager.io/certificate-name. List what each Certificate writes to, list what each TLS Secret says it came from, and compare the two:
kubectl get certificates -A -o json \ | jq -r '.items[] | "\(.metadata.namespace)/\(.metadata.name) \(.spec.secretName)"' \ | sort > certs.txt kubectl get secrets -A --field-selector type=kubernetes.io/tls -o json \ | jq -r '.items[] | select(.metadata.annotations["cert-manager.io/certificate-name"]) | "\(.metadata.namespace)/\(.metadata.annotations["cert-manager.io/certificate-name"]) \(.metadata.name)"' \ | sort > secrets.txt comm -13 certs.txt secrets.txt Each line it prints is a Secret whose Certificate is gone or now writes somewhere else. Nothing will renew it. In my example it prints shop/api api-tls.
One caution. The second command pulls whole Secret objects through your terminal before jq throws the data away, so run it from a place where you're allowed to read TLS Secrets.
For any Secret on that list that something still uses, see when it expires:
kubectl get secret api-tls -n shop -o jsonpath='{.data.tls\.crt}' \ | base64 -d | openssl x509 -noout -enddate It prints a line that starts with notAfter=. That date is your deadline.
What to do about it
Change the Certificate and every consumer of the Secret in the same PR. That means Ingress tls entries, Gateway certificateRefs and mounted volumes.
Once the new Secret is in use, delete the old one yourself. cert-manager won't.
If you want Secrets removed when a Certificate is deleted, that's what --enable-certificate-owner-ref is for. Know the trade-off first: with it on, deleting a Certificate by mistake also deletes the certificate your site is serving. And it's about deletion. I haven't tested what it does on a rename, so I wouldn't lean on it for this.
In review, a changed secretName should raise one question: who else has the old name written down?
The same thing happens when a Certificate is deleted while an Ingress still uses its Secret. The Secret stays, keeps serving, and expires in place.
Have you hit this in production? I'd like to know how long it took to trace it back to the PR.