TechBuzzPro

Cert Manager Restore Order: Prevent Unnecessary ACME Issuance?

· 5 min read · Apps & Browsers

In this article
  1. Background: How cert-manager and ACME Work
  2. What “Restore Order” Means in Practice
  3. When Restoring an Order Prevents Unnecessary Issuance
  4. When Restoring an Order Does NOT Prevent Issuance
  5. How to Properly Restore to Avoid Unnecessary Issuance
  6. Common Problems and Misconceptions
  7. Alternatives to Restoring Orders
  8. Frequently Asked Questions

Yes, restoring a cert-manager Order resource can prevent unnecessary ACME certificate issuance, but only in specific recovery scenarios. When you restore an Order (and its associated CertificateRequest and Secret) from a backup after a cluster failure, cert-manager can resume the issuance process without creating a new ACME order, saving you from rate limits and redundant certificate requests. However, restoring an Order alone—without the corresponding private key and certificate—will not prevent issuance; it may actually trigger a new one.

Background: How cert-manager and ACME Work

cert-manager is a Kubernetes-native tool that automates the lifecycle of TLS certificates. It uses the ACME protocol (e.g., Let's Encrypt) to request certificates. The key resources are:

  • Certificate: The desired certificate definition (e.g., domain, issuer, renewal policy).
  • Order: A single ACME order for a set of domains, created by the Certificate controller.
  • CertificateRequest: A request for a signed certificate, referencing a specific Order.
  • Secret: Stores the private key and the issued certificate.

When you create a Certificate, cert-manager creates an Order, then a CertificateRequest, and finally stores the issued certificate in a Secret. If the cluster crashes mid-process, you might need to restore these resources from a backup.

What “Restore Order” Means in Practice

Restoring an Order means recreating the Order object in Kubernetes from a backup (e.g., Velero, etcd snapshot). This is only useful if the Order is still in a valid state—for example, if the ACME server has already issued the certificate but the Secret was lost. In that case, restoring the Order can make cert-manager re-sync the Secret from the ACME server, avoiding a new order.

However, if the Order is in a state like "pending" or "invalid", restoring it won't help. cert-manager will likely mark it as failed and create a new Order, which is the unnecessary issuance you wanted to avoid.

When Restoring an Order Prevents Unnecessary Issuance

Here are the scenarios where restoring an Order (along with the right resources) can save you from a redundant ACME request:

  1. Secret lost, Order still valid: The ACME server has already issued the certificate, but the Secret was deleted accidentally. Restoring the Order (and the CertificateRequest) allows cert-manager to retrieve the certificate from the ACME server and recreate the Secret.
  2. Cluster restore after etcd backup: If you restore the entire cluster state from a backup, the Order and its associated resources are restored together. cert-manager will see the Order as already processed and won't create a new one.
  3. ACME server still has the order cached: Some ACME servers allow you to fetch an existing order by its URL. If the Order resource is restored with the correct URL, cert-manager can re-use it.

In these cases, you avoid hitting ACME rate limits (e.g., Let's Encrypt's 5 duplicate certificates per week) and reduce unnecessary load on the CA.

When Restoring an Order Does NOT Prevent Issuance

Restoring an Order is not a magic bullet. It will not prevent a new ACME issuance in these common situations:

  • Order is in a failed state: If the Order was already marked as "invalid" or "expired", cert-manager will ignore it and create a fresh Order.
  • Private key is missing: Without the private key, the restored certificate is useless. cert-manager will generate a new key and request a new certificate.
  • Certificate resource is missing: If the Certificate object that owns the Order is gone, the restored Order is orphaned and will be garbage-collected.
  • Backup is older than the Order: If the backup predates the Order, restoring it won't include the Order at all.

In these cases, restoring the Order alone will not stop cert-manager from creating a new Order—it might even cause a conflict.

How to Properly Restore to Avoid Unnecessary Issuance

To successfully prevent a new ACME order, follow this order of restoration:

  1. Restore the Secret containing the private key and existing certificate (if available).
  2. Restore the CertificateRequest that references the Order.
  3. Restore the Order with its original status and URL.
  4. Restore the Certificate object that ties everything together.

If you have the Secret with the private key and certificate, you don't even need to restore the Order—just restore the Secret and the Certificate, and cert-manager will see the certificate as valid and not renew until it's near expiry.

Common Problems and Misconceptions

Misconception: Restoring an Order always prevents a new issuance. As explained, it depends on the state. A common mistake is restoring only the Order from a backup while the Secret is missing. This will cause cert-manager to issue a new certificate because it cannot find the private key.

Problem: Order restored but stuck in "pending". This can happen if the ACME server has no record of the order (e.g., the order expired on the server). cert-manager will eventually time out and create a new Order.

Problem: Duplicate Order resources. If you restore an Order while the original still exists (e.g., in a multi-replica scenario), you might get two Orders for the same certificate. This can lead to unnecessary issuance.

Alternatives to Restoring Orders

If you want to avoid unnecessary ACME issuance after a disaster, consider these alternatives:

  • Back up the Secret: The most reliable way is to back up the Secret containing the private key and certificate. Restoring that alone prevents issuance.
  • Use cert-manager's built-in backup/restore: Some tools like cmctl have experimental export/import features.
  • Increase ACME rate limits: Not a direct solution, but you can request higher limits from Let's Encrypt if you have a legitimate need.
  • Use a different issuer: For internal PKI, use a CA that doesn't have strict rate limits.

Frequently Asked Questions

Q: Can I restore just the Order to get the same certificate back?
Only if the ACME server still has the order and you have the private key. Otherwise, no.

Q: Will restoring an Order cause rate limit issues?
If the Order is valid and you have the key, no. If it's invalid, cert-manager will create a new Order, which could hit rate limits.

Q: How do I check if my Order is still valid?
Run kubectl get order -o yaml and look at the status.state field. If it's "valid" or "ready", it's usable.

Q: What's the best backup strategy for cert-manager?
Back up all cert-manager resources (Certificate, Order, CertificateRequest, Secret) together, preferably with Velero or etcd snapshot.

Q: Does cert-manager automatically retry failed Orders?
Yes, it will retry a failed Order a limited number of times, then create a new one.