Lesson 03 of 14 · Foundations of trust
PKI for a whole platform
Run certificates for a whole platform instead of one cluster: a hierarchy that limits blast radius, an inventory with owners, automation for every certificate type, expiry monitoring from the outside, and rehearsed rotation of intermediates and roots.
Many kinds of certificate
A platform runs far more certificates than people expect. Inventory them by type, because each type has a different issuer, lifetime and owner:
| Type | Example | Typical issuer | Lifetime |
|---|---|---|---|
| Public edge | app.example.com |
Public CA via ACME, or the cloud's certificate service | 90 days, trending shorter |
| Internal service / gateway | orders.internal |
Private CA through cert-manager | Days to months |
| Mesh workload | spiffe://…/sa/orders |
Mesh CA (with your intermediate) | ~24 hours |
| Kubernetes components | API server, kubelet, etcd | Cluster CA (kubeadm or managed) | 1 year by default; kubelet rotates |
| Client / partner / agent | a connector at a customer site | Private CA, per-client | Weeks to a year |
| Signing keys | image and artifact signing | KMS/HSM or keyless (Sigstore) | Varies |
A school prints many kinds of card: student IDs, visitor badges, staff passes, library cards. They are made by different offices and expire at different times. If nobody keeps a list of every kind of card and who renews it, one morning all the staff passes expire and nobody can open the doors.
A hierarchy that limits blast radius
Root CA (offline: HSM or a locked-down cloud CA; used only to sign intermediates)
├─ Intermediate: public-edge (or use a public CA)
├─ Intermediate: prod cell-1 → gateway certs, mesh intermediate for cell-1
├─ Intermediate: prod cell-2 → …
├─ Intermediate: non-prod
└─ Intermediate: client/agent certificates
- The root key is offline. Signing an intermediate is a rare, ceremonial event with two people present.
- One intermediate per environment, cell or purpose. If one leaks, revoke and replace it; everything else keeps working.
- Name constraints (where supported) restrict an intermediate to certain domains, so a compromised one cannot mint
*.example.comfor everything. - Keep keys in KMS/HSM. Regulated environments may require FIPS 140-validated modules.
Automate every type
- Public: ACME (cert-manager with Let's Encrypt or a commercial ACME CA), or the cloud's own certificate service on the load balancer. Use DNS-01 for wildcards.
- Internal: cert-manager
ClusterIssuerbacked by Vault, a cloud private CA or a CA Secret; apps requestCertificateresources through the golden path. - Mesh: plug your intermediate into the mesh CA (for example
istio-csrwith cert-manager, or Linkerd's trust anchor and issuer). - Kubernetes components: managed clusters rotate them; on kubeadm, enable kubelet rotation and schedule
kubeadm certs renewbefore the one-year expiry (upgrades renew them too).
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: orders-tls
namespace: shop
spec:
secretName: orders-tls
duration: 720h # 30 days
renewBefore: 240h # renew 10 days early
dnsNames: [ "orders.shop.svc", "orders.internal.example.com" ]
issuerRef:
kind: ClusterIssuer
name: internal-ca
Monitor from both sides
- Inside: cert-manager metrics (
certmanager_certificate_expiration_timestamp_seconds, Ready conditions), kubeadm expiry, mesh CA health. - Outside: probe the endpoints the way clients do (blackbox exporter, synthetic checks) and alert on the served certificate's expiry. A renewed Secret that a load balancer or a long-running process never reloaded is a classic outage.
- Alert at 30, 14 and 7 days, each with an owner from the inventory.
The certificate nobody owned
Many expiry outages involve a certificate created by hand years ago, on a component nobody remembers. The fix is the inventory: every certificate has an owner, an issuer and an automated renewal, or it is replaced with one that does.
Rotation drills: intermediates and roots
Rotate before you have to, and practise on non-production first.
Intermediate rotation (routine): issue a new intermediate from the root, point the issuer at it, let leaves renew naturally (or force renewal), revoke the old intermediate once no valid leaf chains to it.
Root rotation (rare, risky): the order matters.
1. Create the new root (offline).
2. Distribute a TRUST BUNDLE containing old + new roots to every client and workload.
Wait until everything has picked it up.
3. Issue new intermediates from the new root; renew leaves under them.
4. Verify nothing still presents a chain to the old root (metrics, scans).
5. Remove the old root from the bundles.
Going deeper
trust-manager (from the cert-manager project) distributes CA bundles into ConfigMaps across namespaces, which makes step 2 a declarative change instead of a manual hunt. For meshes, follow the vendor's documented trust-anchor rotation, which uses the same "trust both, then switch, then remove" sequence.
Try it
With cert-manager on a test cluster, create a CA ClusterIssuer and the Certificate above with duration: 1h and renewBefore: 50m. Watch kubectl get certificate -w: it renews every ten minutes. Then delete the Secret and watch cert-manager reissue it. Finally, add an alert rule on the expiration metric.
Recap
- Inventory every certificate type with its issuer, lifetime and owner.
- Offline root, intermediates per environment, cell or purpose, keys in KMS/HSM.
- Automate issuance for every type, and monitor expiry from inside and as clients see it.
- Rotate on a schedule. For roots: trust both, switch, then remove.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.