Introduction: Why Build Your Own Certificate Management System
Once a Homelab has a few services, certificates end up scattered across Nginx configs, Kubernetes Secrets, container mount directories and a handful of VMs. Public certificates are covered by Let’s Encrypt and Cloudflare, but internal services are not so forgiving: self-signed certificates trigger warnings in browsers and command-line tools everywhere, and public CAs will not issue certificates for *.homelab.internal at all.
This post documents the certificate management chain I built in my Homelab:
- step-ca as the internal private CA, exposing an ACME endpoint and the
stepCLI; - cert-manager requests and renews certificates in Kubernetes and writes the results into Secrets;
- Prometheus collects certificate expiry, renewal time and readiness;
- Vault PKI as the alternative when you need audit trails and central policy, which I also got working end to end this time;
- Cloudflare keeps handling public domains, described here as a comparison.
The hands-on parts ran on a Debian 12 + k3s VM with step-ca 0.30.2, step CLI 0.31.0, cert-manager 1.21.3 and Vault 2.2.2. Vault PKI was wired into cert-manager on the same VM and issued real certificates, and I also tested the Prometheus/Alertmanager alerting chain plus revocation on both step-ca and Vault. The Cloudflare API is described only as a design option; SPIFFE/SPIRE and the cert-manager CSI Driver are future work and not covered here.
Architecture: The Certificate Management Picture
Start with the big picture. The CA layer issues certificates, cert-manager hooks issuance into Kubernetes, the consumption layer is Ingress, Pods and VMs, and the monitoring layer collects certificate state.
graph TB
subgraph CA["CA layer"]
StepCA["step-ca<br/>private CA"]
Vault["Vault PKI<br/>optional"]
CF["Cloudflare<br/>public certs"]
end
subgraph Issue["Issuance layer"]
CM["cert-manager"]
ACME["ACME / HTTP-01"]
end
subgraph Use["Consumption layer"]
Traefik["Traefik"]
Ing["Ingress"]
Pod["Pod"]
VM["VMs / bare-metal services"]
end
subgraph Monitor["Monitoring layer"]
Prom["Prometheus"]
Grafana["Grafana"]
AM["Alertmanager"]
end
StepCA -->|ACME| CM
Vault -->|Vault Issuer| CM
CF -->|Origin CA| Traefik
Traefik --> Ing
CM -->|Secret| Ing
CM -->|Secret / CSI| Pod
StepCA -->|step CLI| VM
CM -->|metrics| Prom
Prom --> Grafana
Prom --> AM
style StepCA fill:#4f46e5,color:#fff
style CM fill:#326ce5,color:#fff
style Vault fill:#000,color:#fff
Choosing Between the Three Options
| Option | Best for | Strengths | Limitations |
|---|---|---|---|
| step-ca | Internal services, dev environments, Kubernetes | Single binary, ACME support, short-lived certificates | You must distribute the root CA to clients |
| Vault PKI | Audit requirements, dynamic credentials, central policy | Complete permission model and audit trail | Higher deployment and operations cost |
| Cloudflare | Services exposed to the public internet | Managed edge certificates, long-lived Origin CA | Only covers traffic proxied by Cloudflare |
My choice is step-ca for the internal CA and cert-manager for automation on the Kubernetes side. Vault issues certificates for more sensitive services, and Cloudflare keeps managing public domains. The three do not conflict; split them by domain and by consumer.
Network Topology
graph LR
U["User"] --> CF["Cloudflare"]
CF -->|Full Strict| Traefik["Traefik<br/>Origin Certificate"]
Traefik --> K8s["k3s / Kubernetes<br/>step-ca certificates"]
K8s --> DB[("PostgreSQL<br/>optional Vault certs")]
CA["step-ca<br/>ca.homelab.internal:8443"] --> K8s
style CF fill:#f38020,color:#fff
style Traefik fill:#24a1c1,color:#fff
style K8s fill:#326ce5,color:#fff
style CA fill:#4f46e5,color:#fff
The lab has no separate internal DNS, so ca.homelab.internal and the test domains resolve to the lab VM through a CoreDNS server block for homelab.internal. In production, put these records in your own DNS instead of patching CoreDNS long term.
Option One: A Private CA with step-ca
step-ca is Smallstep’s open-source CA server. It runs from a single binary and supports ACME, JWK, OIDC and other provisioners, which suits a Homelab-sized deployment.
Why step-ca
What I cared about most:
- Light to deploy: no database cluster, just BadgerDB on disk;
- cert-manager can use ACME directly, with no custom Issuer;
- Short default certificate lifetimes keep the exposure window small if a key leaks;
- The
stepCLI covers initialisation, issuance, inspection and client trust setup.
Preparation
Create the directories and a dedicated user. The commands below run on Debian 12 and the CA listens on 8443.
sudo useradd -r -s /bin/false step
sudo mkdir -p /opt/step-ca/{config,secrets,db,certs}
sudo chown -R step:step /opt/step-ca
# Generate the passphrase for the CA private key; step-ca reads this file at startup
sudo -u step sh -c 'openssl rand -base64 24 > /opt/step-ca/secrets/password.txt'
sudo chmod 600 /opt/step-ca/secrets/password.txt
export STEPPATH=/opt/step-ca
export CA_NAME="Homelab Root CA"
export CA_ADDRESS=":8443"
export CA_PROVISIONER="[email protected]"
CA_PROVISIONER is the name of the first JWK provisioner. You will need it later when issuing manually with step ca token or step ca certificate.
Installing step and step-ca
This post uses step CLI 0.31.0 and step-ca 0.30.2. The download URLs and the archive layout look like this:
cd /tmp
curl -sLO https://github.com/smallstep/cli/releases/download/v0.31.0/step_linux_amd64.tar.gz
tar xzf step_linux_amd64.tar.gz
sudo install -m 755 step_linux_amd64/bin/step /usr/local/bin/step
curl -sLO https://github.com/smallstep/certificates/releases/download/v0.30.2/step-ca_linux_amd64.tar.gz
tar xzf step-ca_linux_amd64.tar.gz
sudo install -m 755 step-ca_linux_amd64/step-ca /usr/local/bin/step-ca
step version
step-ca version
The step-ca tarball contains step-ca_linux_amd64/step-ca, not the binary at the root. The mv step-ca /usr/local/bin/ from some tutorials will not find the file.
Initialising the CA
Create the ACME provisioner during initialisation. step ca init in step-ca 0.30 supports --acme, which is less hassle than starting the CA first and adding the provisioner through the admin API.
cd /opt/step-ca
sudo -u step env STEPPATH=/opt/step-ca step ca init \
--name="$CA_NAME" \
--dns=ca.homelab.internal \
--dns=ca.plz.ac \
--dns=10.31.0.141 \
--address="$CA_ADDRESS" \
--provisioner="$CA_PROVISIONER" \
--acme \
--deployment-type=standalone \
--password-file=/opt/step-ca/secrets/password.txt
--dns can be repeated; do not write one comma-separated string, because step-ca will not split it for you. --deployment-type=standalone means no connection to Smallstep’s cloud service and keys stay entirely local. 10.31.0.141 is the CA address in the lab; use your own CA IP in a real deployment, or omit this SAN if clients only reach the CA by hostname.
After initialisation the directory looks like this:
/opt/step-ca/
├── certs/
│ ├── root_ca.crt
│ └── intermediate_ca.crt
├── config/
│ ├── ca.json
│ └── defaults.json
├── db/
├── secrets/
│ ├── password.txt
│ ├── root_ca_key
│ └── intermediate_ca_key
└── ...
The root CA certificate lives in certs/ and the private key in secrets/. Some examples put root_ca.crt under secrets/, which does not match the real 0.30 layout.
Adjusting Certificate Lifetimes
authority.claims in ca.json controls the default lifetime. Below are only the fields you need to change; do not replace the whole file. To make the renewal test observable within minutes, I set the default to 10 minutes:
{
"authority": {
"claims": {
"minTLSCertDuration": "5m",
"maxTLSCertDuration": "2160h",
"defaultTLSCertDuration": "10m",
"disableRenewal": false,
"allowRenewalAfterExpiry": true
},
"provisioners": [
{
"type": "ACME",
"name": "acme",
"claims": {
"minTLSCertDuration": "5m",
"maxTLSCertDuration": "2160h",
"defaultTLSCertDuration": "10m"
}
}
]
}
}
In production, set defaultTLSCertDuration to 24h or 720h. ACME clients cannot request a lifetime in the order; the final lifetime comes from the CA’s provisioner configuration, and cert-manager’s duration field does not change it under an ACME Issuer. Keep the JWK provisioner generated during initialisation in the provisioners array and add claims only to the ACME entry.
Restart the CA after the change, then step ca provisioner list shows the ACME provisioner and its claims:
sudo systemctl restart step-ca
sudo step ca provisioner list \
--ca-url=https://ca.homelab.internal:8443 \
--root=/opt/step-ca/certs/root_ca.crt
systemd Service
Run the CA as a systemd service under the dedicated step user, and restrict the directories it can write:
# /etc/systemd/system/step-ca.service
[Unit]
Description=step-ca Certificate Authority
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=step
Group=step
Environment=STEPPATH=/opt/step-ca
ExecStart=/usr/local/bin/step-ca /opt/step-ca/config/ca.json --password-file=/opt/step-ca/secrets/password.txt
Restart=on-failure
RestartSec=10
NoNewPrivileges=yes
PrivateTmp=yes
ProtectSystem=strict
ProtectHome=yes
ReadWritePaths=/opt/step-ca/db
[Install]
WantedBy=multi-user.target
ProtectSystem=strict mounts most of the filesystem read-only, so ReadWritePaths must include at least db. If you later enable other features that write files, add those directories too, otherwise the CA fails with permission errors at startup or during issuance.
Start it and check:
sudo systemctl daemon-reload
sudo systemctl enable --now step-ca
sudo systemctl status step-ca --lines=0 --no-pager
sudo step ca health \
--ca-url=https://ca.homelab.internal:8443 \
--root=/opt/step-ca/certs/root_ca.crt
Once step ca health returns ok, the CA’s HTTPS and ACME endpoints are up. The screenshot shows the running service and the provisioner list:

ACME Endpoint
step-ca serves its ACME directory at /acme/{provisioner}/directory. The provisioner here is named acme, so the URL is:
https://ca.homelab.internal:8443/acme/acme/directory
You can verify it directly:
sudo curl -s --cacert /opt/step-ca/certs/root_ca.crt \
https://ca.homelab.internal:8443/acme/acme/directory | jq
The output contains newNonce, newAccount, newOrder, revokeCert and keyChange. cert-manager’s ACME Issuer hits newNonce and newAccount first, then creates an order.
Trusting the Root CA on Clients
There is no way around this with a private CA: install the root CA in each client’s trust store. On Linux:
# Verify the fingerprint before installing, so you never trust an unknown certificate from the network
step ca root root_ca.crt \
--ca-url=https://ca.homelab.internal:8443 \
--fingerprint <root-ca-fingerprint>
sudo cp root_ca.crt /usr/local/share/ca-certificates/homelab-ca.crt
sudo update-ca-certificates
# Verify
curl https://ca.homelab.internal:8443/health
macOS:
sudo security add-trusted-cert -d -r trustRoot \
-k /Library/Keychains/System.keychain root_ca.crt
Windows (administrator PowerShell):
Import-Certificate -FilePath "C:\temp\root_ca.crt" `
-CertStoreLocation Cert:\LocalMachine\Root
When a container image has no system trust store, copy the root CA into the image:
FROM alpine:3.22
COPY root_ca.crt /usr/local/share/ca-certificates/homelab-ca.crt
RUN update-ca-certificates
Or mount it from a ConfigMap in Kubernetes and point SSL_CERT_FILE at it. Do not reimplement trust logic in every application; centralise it where you can.
Container Deployment (Optional)
If you would rather not install binaries on the host, the official image works too. This compose file is equivalent to the systemd unit and suits running the CA on a separate Docker host:
services:
step-ca:
image: smallstep/step-ca:0.30.2
container_name: step-ca
restart: unless-stopped
ports:
- "8443:8443"
volumes:
- ./step:/home/step
environment:
- DOCKER_STEPCA_INIT_NAME=Homelab Root CA
- DOCKER_STEPCA_INIT_DNS_NAMES=ca.homelab.internal,ca.plz.ac
- DOCKER_STEPCA_INIT_REMOTE_MANAGEMENT=true
- DOCKER_STEPCA_INIT_ACME=true
healthcheck:
test: ["CMD", "step", "ca", "health"]
interval: 30s
timeout: 10s
retries: 3
I did not run this part separately in the lab; the image’s init parameters change between versions, so read the README for your version before using it.
Option Two: Automated Issuance with cert-manager
cert-manager does three things: it creates a CertificateRequest from a Certificate or an Ingress annotation, requests the certificate from the ACME server, and writes the result into a Secret and renews it before expiry.
Installing cert-manager
This post uses cert-manager v1.21.3. Recent Helm charts install CRDs with crds.enabled; the old installCRDs is no longer recommended.
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.21.3 \
--set crds.enabled=true \
--set prometheus.enabled=true
kubectl get pods -n cert-manager
kubectl wait --for=condition=Ready pods --all -n cert-manager --timeout=120s
prometheus.enabled=true adds prometheus.io/scrape and prometheus.io/port annotations to the cert-manager Pods and exposes metrics on port 9402.
Configuring the step-ca Issuer
Convert the root CA to base64 and put it in the ClusterIssuer’s caBundle. This step is not optional; without it cert-manager reports x509: certificate signed by unknown authority when it connects to https://ca.homelab.internal:8443.
CA_B64=$(sudo base64 -w0 /opt/step-ca/certs/root_ca.crt)
cat <<EOF | kubectl apply -f -
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: step-ca-issuer
spec:
acme:
server: https://ca.homelab.internal:8443/acme/acme/directory
email: [email protected]
privateKeySecretRef:
name: step-ca-account-key
caBundle: ${CA_B64}
solvers:
- http01:
ingress:
ingressClassName: traefik
EOF
ingressClassName: traefik makes Traefik handle the Ingress created by the HTTP-01 solver. Older examples use class: traefik; ingressClassName is clearer in current versions.
Check the Issuer status:
kubectl get clusterissuer step-ca-issuer
kubectl describe clusterissuer step-ca-issuer
READY=True with the message The ACME account was registered with the ACME server means cert-manager validated step-ca’s TLS with the caBundle and registered the ACME account.
Requesting a Certificate
Create a test namespace and a Certificate:
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: test-cert
namespace: cert-test
spec:
secretName: test-tls
commonName: test.apps.homelab.internal
dnsNames:
- test.apps.homelab.internal
renewBefore: 5m
issuerRef:
name: step-ca-issuer
kind: ClusterIssuer
Save the YAML above as test-cert.yaml, then apply it:
kubectl create namespace cert-test
kubectl apply -f test-cert.yaml
kubectl wait --for=condition=Ready certificate/test-cert -n cert-test --timeout=120s
kubectl get certificate -n cert-test
In this lab, a Certificate went from creation to Ready=True in about 20 seconds. cert-manager creates an Order and an HTTP-01 Challenge, step-ca reaches http://test.apps.homelab.internal/.well-known/acme-challenge/... through Traefik, and issues the certificate once validation passes.

Wildcards and duration
A common broken example is requesting *.apps.homelab.internal while using an HTTP-01 solver. That combination cannot work: ACME HTTP-01 only validates a concrete hostname, and wildcards require DNS-01. To issue a wildcard, give cert-manager a DNS-01 solver such as RFC2136, Cloudflare DNS or a webhook.
Another easy trap is duration. The ACME protocol has no field for requesting a lifetime; the CA’s provisioner decides it. cert-manager’s duration does not change what step-ca issues under an ACME Issuer. If you set renewBefore longer than the actual lifetime, cert-manager renews in a loop. My approach: check step-ca’s defaultTLSCertDuration first, then set renewBefore to roughly half of it.
Automatic Requests via Ingress Annotations
The more common pattern is to let cert-manager watch an Ingress’s tls block and create the Certificate itself:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myapp
namespace: cert-test
annotations:
cert-manager.io/cluster-issuer: step-ca-issuer
spec:
ingressClassName: traefik
tls:
- hosts:
- myapp.apps.homelab.internal
secretName: tls-myapp
rules:
- host: myapp.apps.homelab.internal
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: myapp
port:
number: 80
After the Ingress is created, cert-manager generates a Certificate named tls-myapp and the matching Secret. Traefik loads the certificate from the Secret and HTTPS handshakes succeed. Certificates generated from an Ingress usually have SANs but no Common Name, which is normal cert-manager behaviour.
Inspecting the Certificate
kubectl get certificate -n cert-test test-cert -o wide
kubectl describe certificate -n cert-test test-cert
kubectl get secret -n cert-test test-tls -o jsonpath='{.data.tls\.crt}' \
| base64 -d \
| openssl x509 -noout -subject -issuer -dates -ext subjectAltName
The actual output includes:
subject=CN = test.apps.homelab.internal
issuer=O = Homelab Root CA, CN = Homelab Root CA Intermediate CA
X509v3 Subject Alternative Name:
DNS:test.apps.homelab.internal

The chain is leaf certificate → step-ca Intermediate CA → Homelab Root CA. As long as a client trusts the root CA, it can validate the whole chain.
Option Three: Vault PKI
Vault’s PKI Secrets Engine fits environments that need audit trails, dynamic credentials and central policy. This time I ran the whole Vault PKI chain on the same lab VM: Vault 2.2.2 with the file backend, Vault’s own HTTPS certificate issued by step-ca, and cert-manager issuing certificates through a Vault Issuer with Kubernetes auth.
Deploying Vault
Issue Vault’s HTTPS certificate from step-ca first, for vault.homelab.internal:
sudo useradd -r -s /bin/false vault
sudo mkdir -p /opt/vault/{data,tls}
PROV=$(sudo step ca provisioner list \
--ca-url=https://ca.homelab.internal:8443 \
--root=/opt/step-ca/certs/root_ca.crt \
| jq -r '.[] | select(.type=="JWK") | .name')
sudo STEPPATH=/opt/step-ca step ca certificate vault.homelab.internal \
/opt/vault/tls/vault.crt /opt/vault/tls/vault.key \
--ca-url=https://ca.homelab.internal:8443 \
--root=/opt/step-ca/certs/root_ca.crt \
--provisioner="$PROV" \
--provisioner-password-file=/opt/step-ca/secrets/password.txt \
--password-file=/opt/step-ca/secrets/password.txt \
--not-after=720h
# Hand the certificate and key to the vault user, and copy the root CA somewhere Vault can read
sudo chown -R vault:vault /opt/vault
sudo chmod 600 /opt/vault/tls/vault.key
sudo cp /opt/step-ca/certs/root_ca.crt /opt/vault/tls/root_ca.crt
sudo chmod 644 /opt/vault/tls/root_ca.crt
The lab uses disable_mlock = true for convenience; in production enable mlock and disable swap so private keys are never paged to disk. The Vault config uses file storage and listens on 8200:
# /etc/vault.d/vault.hcl
ui = true
disable_mlock = true
api_addr = "https://vault.homelab.internal:8200"
cluster_addr = "https://vault.homelab.internal:8201"
storage "file" {
path = "/opt/vault/data"
}
listener "tcp" {
address = "0.0.0.0:8200"
tls_cert_file = "/opt/vault/tls/vault.crt"
tls_key_file = "/opt/vault/tls/vault.key"
}
The systemd unit runs Vault as a dedicated user:
[Unit]
Description=HashiCorp Vault
After=network-online.target
Wants=network-online.target
[Service]
User=vault
Group=vault
ExecStart=/usr/local/bin/vault server -config=/etc/vault.d/vault.hcl
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
For convenience the lab initialises with 1 share and a threshold of 1; do not do this in production:
export VAULT_ADDR=https://vault.homelab.internal:8200
export VAULT_CACERT=/opt/vault/tls/root_ca.crt
vault operator init -key-shares=1 -key-threshold=1 -format=json \
| sudo tee /opt/vault/init.json >/dev/null
UNSEAL=$(sudo jq -r '.unseal_keys_b64[0]' /opt/vault/init.json)
ROOT=$(sudo jq -r '.root_token' /opt/vault/init.json)
vault operator unseal "$UNSEAL"
vault login "$ROOT"
vault status
When vault status shows Initialized true and Sealed false, the service is up:

Enabling PKI and the Intermediate CA
vault secrets enable pki
vault secrets tune -max-lease-ttl=87600h pki
vault write -field=certificate pki/root/generate/internal \
common_name="Homelab Vault Root CA" \
issuer_name="homelab-root" \
ttl=87600h > vault_root_ca.crt
vault write pki/config/urls \
issuing_certificates="https://vault.homelab.internal:8200/v1/pki/ca" \
crl_distribution_points="https://vault.homelab.internal:8200/v1/pki/crl"
vault secrets enable -path=pki_int pki
vault secrets tune -max-lease-ttl=43800h pki_int
vault write -format=json pki_int/intermediate/generate/internal \
common_name="Homelab Vault Intermediate CA" \
issuer_name="homelab-intermediate" \
| jq -r '.data.csr' > pki_intermediate.csr
vault write -format=json pki/root/sign-intermediate \
issuer_ref="homelab-root" \
csr=@pki_intermediate.csr \
format=pem_bundle \
ttl="43800h" \
| jq -r '.data.certificate' > intermediate.cert.pem
vault write pki_int/intermediate/set-signed certificate=@intermediate.cert.pem
Creating a Role and Policy
vault write pki_int/roles/homelab-internal \
allowed_domains="homelab.internal,svc.cluster.local" \
allow_subdomains=true \
allow_bare_domains=true \
max_ttl="720h" \
generate_lease=true \
no_store=false
vault policy write cert-manager-policy - <<'EOF'
path "pki_int/sign/homelab-internal" {
capabilities = ["create", "update"]
}
path "pki_int/issue/homelab-internal" {
capabilities = ["create"]
}
EOF
no_store=false makes Vault keep issuance records, so you can later list serial numbers with vault list pki_int/certs.
Kubernetes Authentication
Vault runs outside the cluster, so auth/kubernetes/config needs a token reviewer JWT and the Kubernetes CA. First create a ServiceAccount used only for token review:
apiVersion: v1
kind: Namespace
metadata:
name: vault
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: vault-auth
namespace: vault
---
apiVersion: v1
kind: Secret
metadata:
name: vault-auth-token
namespace: vault
annotations:
kubernetes.io/service-account.name: vault-auth
type: kubernetes.io/service-account-token
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: vault-auth-delegator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: vault-auth
namespace: vault
TOKEN=$(kubectl -n vault get secret vault-auth-token -o jsonpath='{.data.token}' | base64 -d)
CA=$(kubectl -n vault get secret vault-auth-token -o jsonpath='{.data.ca\.crt}' | base64 -d)
vault auth enable kubernetes
vault write auth/kubernetes/config \
kubernetes_host="https://10.31.0.141:6443" \
token_reviewer_jwt="$TOKEN" \
kubernetes_ca_cert="$CA"
vault write auth/kubernetes/role/cert-manager \
bound_service_account_names=cert-manager \
bound_service_account_namespaces=cert-manager \
policies=cert-manager-policy \
ttl=1h
Set kubernetes_host to the k3s API address, not https://kubernetes.default.svc, because Vault is not running in a Pod.
cert-manager Vault Issuer
cert-manager supports Vault Issuers natively, with no extra plugin. Use serviceAccountRef so cert-manager exchanges its own Pod’s ServiceAccount token for a Vault token:
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: vault-issuer
spec:
vault:
server: https://vault.homelab.internal:8200
path: pki_int/sign/homelab-internal
caBundle: <base64-step-ca-root>
auth:
kubernetes:
role: cert-manager
mountPath: /v1/auth/kubernetes
serviceAccountRef:
name: cert-manager
caBundle here is the trust root for Vault’s HTTPS certificate, which is the step-ca root CA, not the Vault PKI root CA. The two CAs are separate in this setup: step-ca protects Vault’s API, and Vault PKI issues certificates for workloads.
The cert-manager ServiceAccount also needs permission to create serviceaccounts/token, otherwise the Issuer reports:
serviceaccounts "cert-manager" is forbidden:
User "system:serviceaccount:cert-manager:cert-manager"
cannot create resource "serviceaccounts/token"
Add a Role and RoleBinding:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: cert-manager-token-creator
namespace: cert-manager
rules:
- apiGroups: [""]
resources: ["serviceaccounts/token"]
verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: cert-manager-token-creator
namespace: cert-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: cert-manager-token-creator
subjects:
- kind: ServiceAccount
name: cert-manager
namespace: cert-manager
The Issuer then becomes Ready=True with the message Vault verified:

Issuing a Certificate from Vault PKI
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: vault-test
namespace: cert-test
spec:
secretName: vault-test-tls
commonName: vault-test.apps.homelab.internal
dnsNames:
- vault-test.apps.homelab.internal
duration: 24h
issuerRef:
name: vault-issuer
kind: ClusterIssuer
Save the YAML above as vault-test.yaml, then apply it:
kubectl apply -f vault-test.yaml
kubectl wait --for=condition=Ready certificate/vault-test -n cert-test --timeout=120s
kubectl get certificate -n cert-test vault-test -o wide
The result is a certificate issued by Homelab Vault Intermediate CA, valid for 24 hours, with the correct SAN:
subject=CN = vault-test.apps.homelab.internal
issuer=CN = Homelab Vault Intermediate CA
notBefore=Nov 13 17:25:51 2026 GMT
notAfter=Nov 14 17:26:21 2026 GMT
X509v3 Subject Alternative Name:
DNS:vault-test.apps.homelab.internal

The chain is leaf certificate → Homelab Vault Intermediate CA → Homelab Vault Root CA. The serial number also shows up under Vault’s pki_int/certs, confirming that no_store=false and generate_lease=true both took effect:
vault list pki_int/certs
Keys
----
1f:2a:b8:9a:9b:68:ae:70:ff:31:66:ea:75:09:84:2e:24:e3:05:b9
Certificate Monitoring and Alerting
Issuance is only the beginning. What actually bites is a certificate expiring with nobody noticing, so monitoring must cover three things: when it expires, when it renews, and whether a failed renewal is visible.
cert-manager Metrics
cert-manager exposes Prometheus metrics on port 9402. With prometheus.enabled=true you can scrape them directly:
| Metric | Meaning |
|---|---|
certmanager_certificate_expiration_timestamp_seconds |
Certificate expiry timestamp |
certmanager_certificate_ready_status |
Whether the certificate is ready; condition="True" with value 1 means healthy |
certmanager_certificate_renewal_timestamp_seconds |
Scheduled renewal timestamp |
certmanager_controller_sync_call_count |
Controller sync call count |
If the cluster runs the Prometheus Operator, a ServiceMonitor is the least work:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: cert-manager
namespace: cert-manager
spec:
selector:
matchLabels:
app.kubernetes.io/name: cert-manager
app.kubernetes.io/component: controller
endpoints:
- port: http-metrics
interval: 30s
Without the Prometheus Operator, scrape cert-manager.cert-manager.svc:9402 directly from the Prometheus scrape config, or use Pod annotations for service discovery. With the annotation approach, the relabel step must rewrite __address__ to PodIP:9402; a keep rule alone is not enough.

Alerting Rules
These rules cover expiring soon, already expired, not ready, and the controller disappearing:
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: cert-manager-alerts
namespace: monitoring
spec:
groups:
- name: cert-manager
rules:
- alert: CertificateExpiringSoon
expr: |
(certmanager_certificate_expiration_timestamp_seconds - time()) < 7 * 24 * 3600
and
(certmanager_certificate_expiration_timestamp_seconds - time()) > 0
for: 1h
labels:
severity: warning
annotations:
summary: "Certificate {{ $labels.name }} expires in 7 days"
description: "Certificate {{ $labels.name }} in {{ $labels.namespace }} will expire soon."
- alert: CertificateExpiringCritical
expr: |
(certmanager_certificate_expiration_timestamp_seconds - time()) < 24 * 3600
and
(certmanager_certificate_expiration_timestamp_seconds - time()) > 0
for: 10m
labels:
severity: critical
annotations:
summary: "Certificate {{ $labels.name }} expires in 24 hours"
description: "Certificate {{ $labels.name }} in {{ $labels.namespace }} needs immediate attention."
- alert: CertificateExpired
expr: |
certmanager_certificate_expiration_timestamp_seconds - time() < 0
for: 5m
labels:
severity: critical
annotations:
summary: "Certificate {{ $labels.name }} has expired"
description: "Certificate {{ $labels.name }} in {{ $labels.namespace }} is past its expiry time."
- alert: CertificateNotReady
expr: |
certmanager_certificate_ready_status{condition="True"} == 0
for: 15m
labels:
severity: warning
annotations:
summary: "Certificate {{ $labels.name }} is not ready"
description: "Certificate {{ $labels.name }} in {{ $labels.namespace }} has been not ready for 15 minutes."
- alert: CertManagerAbsent
expr: |
absent(up{job="cert-manager"} == 1)
for: 10m
labels:
severity: critical
annotations:
summary: "cert-manager is down"
description: "cert-manager has been unavailable for more than 10 minutes."
The job label in CertManagerAbsent depends on your scrape config; with a ServiceMonitor it is usually not literally cert-manager. Check the real labels with up{job=~".*cert-manager.*"} before deploying.
Testing the Alerting Chain
Reading rule text is not enough, so I ran a minimal Prometheus 3.16.0 and Alertmanager 0.35.0 in the lab and confirmed that metrics are scraped from cert-manager, the rule reaches firing, and Alertmanager receives the alert. I did not install the full kube-prometheus-stack; two minimal Deployments plus ConfigMaps were enough to validate the chain. In production, just use the Prometheus Operator’s ServiceMonitor and PrometheusRule.
The Prometheus scrape config points straight at the cert-manager Service:
scrape_configs:
- job_name: cert-manager
static_configs:
- targets: ["cert-manager.cert-manager.svc:9402"]
The rule file starts with a single CertificateNotReady rule, with for shortened to 30 seconds for easier observation:
groups:
- name: cert-manager
rules:
- alert: CertificateNotReady
expr: certmanager_certificate_ready_status{condition="True"} == 0
for: 30s
labels:
severity: warning
annotations:
summary: "Certificate {{ $labels.name }} is not ready"
Then create a Certificate that references a non-existent Issuer so it stays Ready=False:
kubectl apply -f - <<'EOF'
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: alert-test
namespace: cert-test
spec:
secretName: alert-test-tls
commonName: alert-test.apps.homelab.internal
dnsNames:
- alert-test.apps.homelab.internal
issuerRef:
name: does-not-exist
kind: ClusterIssuer
EOF
After roughly one scrape interval plus 30 seconds, both Prometheus and Alertmanager show the alert:
kubectl get certificate -n cert-test alert-test
curl -s localhost:9090/api/v1/alerts | jq -r '.data.alerts[] | [.labels.alertname, .state, .labels.name] | @tsv'
curl -s localhost:9093/api/v2/alerts | jq -r '.[] | [.labels.alertname, .status.state, .labels.name] | @tsv'
The actual output is CertificateNotReady firing alert-test and CertificateNotReady active alert-test:

The lab Alertmanager only has an empty receiver, so I verified the chain through its API. In production, point the receiver at Slack, email or a webhook, and keep a duration such as for: 15m so transient blips do not page anyone.
External Certificates: blackbox-exporter
For services outside Kubernetes, use blackbox-exporter’s TLS probe:
modules:
tls_connect:
prober: tcp
timeout: 5s
tcp:
tls: true
tls_config:
insecure_skip_verify: false
Prometheus scrape config:
scrape_configs:
- job_name: blackbox-tls
metrics_path: /probe
params:
module: [tls_connect]
static_configs:
- targets:
- ca.homelab.internal:8443
- vault.homelab.internal:8200
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox-exporter:9115
The matching alert:
- alert: TLSCertExpiringSoon
expr: |
probe_ssl_earliest_cert_expiry - time() < 7 * 24 * 3600
for: 1h
labels:
severity: warning
annotations:
summary: "TLS certificate for {{ $labels.instance }} expires soon"
Cloudflare Certificates
When a domain is hosted on Cloudflare, certificates come in two layers:
- Edge Certificate: Cloudflare to the visitor, managed automatically by Universal SSL and usually needing no manual renewal;
- Origin Certificate: Cloudflare to the origin, valid for up to 15 years, suitable for Traefik or Nginx.
Inspect edge certificate packs and Origin CA certificates through the API:
export CF_API_TOKEN="..."
export CF_ZONE_ID="..."
curl -s "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/ssl/certificate_packs" \
-H "Authorization: Bearer ${CF_API_TOKEN}" \
| jq '.result[] | {id, type, status, hosts, expires_on: .certificates[0].expires_on}'
curl -s "https://api.cloudflare.com/client/v4/certificates?zone_id=${CF_ZONE_ID}" \
-H "Authorization: Bearer ${CF_API_TOKEN}" \
| jq '.result[] | {id, hostnames, expires_on, request_type}'
I did not call the real API in the lab. Cloudflare’s token permissions and response fields change with the product, so validate any script with a read-only token before putting it into service.
Hands-On: End-to-End Tests
Lab Environment
| Item | Configuration |
|---|---|
| OS | Debian 12 (bookworm) |
| Virtualisation | Proxmox VE VM, 4 vCPU / 5.8 GiB |
| Kubernetes | k3s v1.32.3+k3s1, single node |
| Ingress | Traefik 3.3.2 (bundled with k3s) |
| Private CA | step-ca 0.30.2 / step CLI 0.31.0 |
| cert-manager | v1.21.3 |
| Vault | 2.2.2, file backend |
| Monitoring | Prometheus 3.16.0 / Alertmanager 0.35.0 |
| Default certificate lifetime | 10 minutes (only to test renewal; 24 hours for the Vault test) |
The test domains are test.apps.homelab.internal, renew.apps.homelab.internal and myapp.apps.homelab.internal. step-ca runs on the same VM, listening on 8443; Traefik listens on 80/443.
Test 1: Issuing a Certificate for an Internal Service
Create a Certificate and wait for it to become ready:
kubectl create namespace cert-test
kubectl apply -f - <<'EOF'
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: test-cert
namespace: cert-test
spec:
secretName: test-tls
commonName: test.apps.homelab.internal
dnsNames:
- test.apps.homelab.internal
renewBefore: 5m
issuerRef:
name: step-ca-issuer
kind: ClusterIssuer
EOF
kubectl wait --for=condition=Ready certificate/test-cert -n cert-test --timeout=120s
kubectl get certificate -n cert-test
The result is READY=True with the status Certificate is up to date and has not expired, about 20 seconds after creation.
Inspect the certificate details:
kubectl get secret -n cert-test test-tls -o jsonpath='{.data.tls\.crt}' \
| base64 -d \
| openssl x509 -noout -subject -issuer -dates -ext subjectAltName
The output confirms the subject, issuer and SAN:
subject=CN = test.apps.homelab.internal
issuer=O = Homelab Root CA, CN = Homelab Root CA Intermediate CA
X509v3 Subject Alternative Name:
DNS:test.apps.homelab.internal
This also verifies the CA chain: the client trusts the root CA, the intermediate CA issued the leaf, and the root CA issued the intermediate.
Test 2: Automatic Renewal
To see renewal within minutes, I set step-ca’s ACME default lifetime to 10 minutes and gave the Certificate renewBefore: 5m:
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: renew-test
namespace: cert-test
spec:
secretName: renew-test-tls
commonName: renew.apps.homelab.internal
dnsNames:
- renew.apps.homelab.internal
renewBefore: 5m
issuerRef:
name: step-ca-issuer
kind: ClusterIssuer
Save the YAML above as renew-cert.yaml, then apply it:
kubectl apply -f renew-cert.yaml
kubectl wait --for=condition=Ready certificate/renew-test -n cert-test --timeout=120s
kubectl get certificate -n cert-test renew-test -o wide
After the first issuance the certificate is valid from 16:48:22 to 16:59:22 and renewalTime is 16:54:22, exactly 5 minutes early. When renewal time arrived, cert-manager created renew-test-2, then renew-test-3 for the same 10-minute lifetime. The screenshot shows revision=3 with a new serial number and updated notBefore/notAfter:

That shows renewal actually works, not just the first issuance. Production would not use a 10-minute lifetime; 24 hours with renewBefore: 8h is more appropriate.
Test 3: Automatic Issuance from Ingress Annotations
Deploy nginx and an Ingress carrying the cert-manager annotation:
kubectl apply -f - <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: cert-test
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: nginx
image: nginx:1.27-alpine
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: myapp
namespace: cert-test
spec:
selector:
app: myapp
ports:
- port: 80
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myapp
namespace: cert-test
annotations:
cert-manager.io/cluster-issuer: step-ca-issuer
spec:
ingressClassName: traefik
tls:
- hosts:
- myapp.apps.homelab.internal
secretName: tls-myapp
rules:
- host: myapp.apps.homelab.internal
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: myapp
port:
number: 80
EOF
kubectl wait --for=condition=Ready certificate/tls-myapp -n cert-test --timeout=120s
kubectl get ingress,certificate -n cert-test
Once tls-myapp is Ready=True, verify HTTPS with curl:
sudo curl -sSI \
--cacert /opt/step-ca/certs/root_ca.crt \
--resolve myapp.apps.homelab.internal:443:10.31.0.141 \
https://myapp.apps.homelab.internal/
It returns HTTP/2 200, which means Traefik has loaded the Secret cert-manager generated and both the TLS handshake and certificate validation succeed:

Test 4: Monitoring Metrics
Port-forward cert-manager’s metrics port locally and query the three key metrics:
kubectl -n cert-manager port-forward svc/cert-manager 9402:9402 >/dev/null 2>&1 &
sleep 2
curl -s localhost:9402/metrics \
| grep -E '^certmanager_certificate_(expiration_timestamp_seconds|ready_status|renewal_timestamp_seconds)'
The output shows expiry, readiness and renewal times for test-cert, renew-test and tls-myapp. ready_status{condition="True"} is 1 and condition="False" is 0, matching the resource state; see the metrics screenshot above.
Test Results Summary
| Item | Result |
|---|---|
| step-ca service | systemd active (running), step ca health returns ok |
| ACME account | ClusterIssuer Ready=True, account registered |
| First issuance | Certificate Ready=True, about 20 seconds |
| Certificate chain | Leaf → Intermediate CA → Root CA, SAN correct |
| Automatic renewal | revision went from 1 to 3, serial and validity updated |
| Ingress issuance | tls-myapp Ready, HTTPS returns HTTP/2 200 |
| Vault PKI | vault-issuer Ready, vault-test issued by the Vault Intermediate CA, valid for 24 hours |
| Monitoring metrics | Expiry, readiness and renewal metrics all scrape correctly |
| Alerting chain | CertificateNotReady reaches firing, Alertmanager receives an active alert |
| step-ca revocation | Both mTLS and JWK token revocation succeed; the serial appears in /1.0/crl |
| Vault revocation | revocation_time is recorded and the serial appears in the Vault CRL |
What Was Not Verified
The following are described as design options only and were not fully deployed on this k3s VM:
- Real Cloudflare API calls (needs a domain and API token);
- SPIFFE/SPIRE workload identity;
- Certificate mounting and rotation with the cert-manager CSI Driver;
- The DNS-01 flow for wildcard certificates (needs programmable DNS).
Anything not explicitly tested here is a design example, not a configuration proven in production.
Troubleshooting
1. x509: certificate signed by unknown authority
The most common error when cert-manager talks to step-ca. Either the ClusterIssuer has no caBundle, or the base64 content is wrong.
# Confirm the root CA path
sudo ls -l /opt/step-ca/certs/root_ca.crt
# Regenerate the base64, taking care to keep it on one line
CA_B64=$(sudo base64 -w0 /opt/step-ca/certs/root_ca.crt)
echo "$CA_B64" | head -c 80; echo
kubectl describe clusterissuer step-ca-issuer
2. HTTP-01 cannot issue wildcards
An ACME HTTP-01 challenge fetches /.well-known/acme-challenge/<token> from a concrete domain, and a wildcard has no hostname of its own, so DNS-01 is the only option. cert-manager usually reports the error in the message of the Order or Challenge:
kubectl get order,challenge -n cert-test
kubectl describe challenge -n cert-test <challenge-name>
3. Certificates renew in a loop
If renewBefore is greater than or equal to the certificate’s actual lifetime, cert-manager considers it perpetually due for renewal. Check the real lifetime first:
kubectl get certificate -n cert-test renew-test -o jsonpath='{.status.notAfter}{"\n"}'
Then compare with step-ca’s provisioner config:
sudo step ca provisioner list \
--ca-url=https://ca.homelab.internal:8443 \
--root=/opt/step-ca/certs/root_ca.crt
Set renewBefore to roughly half the real lifetime, or increase the CA’s defaultTLSCertDuration.
4. A custom CoreDNS hosts entry causes CrashLoopBackOff
If you add another hosts block to CoreDNS’s .override file, CoreDNS reports:
plugin/hosts: this plugin can only be used once per Server Block
because the default k3s Corefile already has a hosts /etc/coredns/NodeHosts block. The right approach is a separate server block for homelab.internal, placed in a .server file in coredns-custom:
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns-custom
namespace: kube-system
data:
homelab.server: |
homelab.internal:53 {
errors
hosts {
10.31.0.141 ca.homelab.internal test.apps.homelab.internal myapp.apps.homelab.internal
fallthrough
}
forward . /etc/resolv.conf
}
Restart CoreDNS afterwards:
kubectl -n kube-system rollout restart deployment coredns
Also, k3s periodically reconciles NodeHosts in the coredns ConfigMap, so entries added by hand can vanish after a while. In production, keep records in your own DNS instead of editing CoreDNS long term.
5. step ca root download fails
step ca root verifies the root CA’s fingerprint. Without one it may refuse to download or fall back to the system trust store:
step ca root root_ca.crt \
--ca-url=https://ca.homelab.internal:8443 \
--fingerprint <root-ca-fingerprint>
The fingerprint is in the CA initialisation output, or you can get it on the CA host with:
step certificate fingerprint /opt/step-ca/certs/root_ca.crt
6. The CA cannot write its database under systemd
If you see permission denied or BadgerDB fails to open, check that ReadWritePaths under ProtectSystem=strict includes /opt/step-ca/db and that the directory is owned by step:step:
sudo systemctl status step-ca --no-pager
sudo journalctl -u step-ca -n 50 --no-pager
sudo ls -ld /opt/step-ca/db
Certificate Revocation and Incident Response
Deleting a Certificate or a Secret is not revocation. Deletion only stops cert-manager from managing the object; the issued certificate remains usable until it expires. Real incident response means revoking at the CA that issued it and confirming that clients check revocation state.
step-ca CRLs and Revocation
CRL support in step-ca is off by default. The config goes at the top level of ca.json, not inside authority:
{
"crl": {
"enabled": true,
"generateOnRevoke": true,
"cacheDuration": "24h"
}
}
step-ca’s docs still mark CRL support as experimental, so verify compatibility with your own clients before relying on it. I first put crl under authority and /1.0/crl kept returning 404 with Certificate Revocation Lists are not enabled in the log. Moving it to the top level and restarting step-ca fixed the CRL endpoint:
sudo systemctl restart step-ca
sudo curl -s --cacert /opt/step-ca/certs/root_ca.crt \
https://ca.homelab.internal:8443/1.0/crl \
-o /tmp/ca.crl
To revoke, pull the certificate and key out of the Secret and authenticate with mTLS:
kubectl get secret -n cert-test revoke-test-tls -o jsonpath='{.data.tls\.crt}' \
| base64 -d > /tmp/revoke-test.crt
kubectl get secret -n cert-test revoke-test-tls -o jsonpath='{.data.tls\.key}' \
| base64 -d > /tmp/revoke-test.key
sudo step ca revoke \
--cert=/tmp/revoke-test.crt \
--key=/tmp/revoke-test.key \
--ca-url=https://ca.homelab.internal:8443 \
--root=/opt/step-ca/certs/root_ca.crt \
--reason=KeyCompromise
You can also revoke by serial number with a JWK token:
PROV=$(sudo step ca provisioner list \
--ca-url=https://ca.homelab.internal:8443 \
--root=/opt/step-ca/certs/root_ca.crt \
| jq -r '.[] | select(.type=="JWK") | .name')
# step ca token --revoke expects a decimal serial number; openssl x509 -serial prints hex
TOKEN=$(sudo step ca token <serial-number> --revoke \
--ca-url=https://ca.homelab.internal:8443 \
--root=/opt/step-ca/certs/root_ca.crt \
--provisioner="$PROV" \
--provisioner-password-file=/opt/step-ca/secrets/password.txt)
sudo step ca revoke <serial-number> \
--token="$TOKEN" \
--ca-url=https://ca.homelab.internal:8443 \
--root=/opt/step-ca/certs/root_ca.crt \
--reason=KeyCompromise
The revoked serial appears in the CRL:
sudo openssl crl -inform DER -in /tmp/ca.crl -noout -text \
| sed -n '/Revoked Certificates/,+6p'

There is an easy-to-miss limitation: enabling the CRL service does not add a CRL distribution point to newly issued certificates. Clients must be configured with the CRL URL explicitly, or the application must check it itself; otherwise revocation only stops renewal and does not stop an already-issued certificate from being used until it expires. Shorter lifetimes shrink that window.
Vault PKI Revocation
Vault revocation is more direct: write the serial number to pki_int/revoke:
export VAULT_ADDR=https://vault.homelab.internal:8200
export VAULT_CACERT=/opt/vault/tls/root_ca.crt
SERIAL=$(vault list -format=json pki_int/certs | jq -r '.[0]')
vault write pki_int/revoke serial_number="$SERIAL"
vault read pki_int/cert/$SERIAL | grep -E 'revocation_time|state'
Then fetch Vault’s CRL to confirm the serial is revoked:
curl -s --cacert /opt/vault/tls/root_ca.crt \
https://vault.homelab.internal:8200/v1/pki_int/crl/pem \
| openssl crl -in /dev/stdin -noout -text \
| sed -n '/Revoked Certificates/,+3p'

Incident Response Order
A leaked certificate key, a compromised host and a leaked CA key are handled in different orders, but the overall direction is the same:
- Scope it: get the certificate serial number, the Secret or host holding the key, the issuer and the expiry time. Check both
openssl x509 -serialand the CA’s issuance logs. - Isolate: stop the service using the certificate, remove the corresponding Secret or mount, and block traffic at the edge if needed. Do not revoke while the old key keeps serving.
- Revoke: run revoke on the issuing CA and record the reason (
KeyCompromisefor a leaked key) and who did it. Keep revocation records in both step-ca and Vault. - Rotate: delete the old Secret and let cert-manager reissue;
rotationPolicy: Alwaysguarantees a new private key on every renewal. If the issuing CA itself may be compromised, replacing leaf certificates is not enough: rotate the intermediate CA or even the root CA and redistribute the trust chain. - Verify: confirm the old serial appears in the CRL or OCSP, confirm clients reject the old certificate, and check logs for any remaining use of the old serial.
- Review: inspect CA logs, cert-manager Events and the Kubernetes audit log, shorten lifetimes and
renewBefore, and add the missing alerts.
A few configuration notes:
- Set
allowRenewalAfterExpirytofalsein production so expired certificates cannot keep renewing; - Deleting a Certificate does not revoke it; you must call the CA’s revoke explicitly;
- Short-lived certificates shrink the exposure window but do not replace revocation;
- Keep the root CA key offline where possible and issue day to day only from the intermediate CA;
- If clients never check CRLs, revocation has limited effect, and short lifetimes plus fast rotation matter more.
Best Practices
Certificate Lifecycle
| Stage | Recommendation |
|---|---|
| Issuance | Use 24h to 7d certificates for internal services to limit the impact of a leak |
| Storage | Enable etcd encryption for Kubernetes Secrets; keep CA keys offline |
| Distribution | cert-manager writes Secrets; Ingress and Pods mount them automatically |
| Renewal | Set renewBefore to 1/3 to 1/2 of the lifetime |
| Monitoring | Warn at 7 days, alert critically at 24 hours |
| Rotation | Use rotationPolicy: Always when the private key must change |
Hardening
- Keep the root CA key offline and issue day to day only from the intermediate CA;
- Listen only on the internal network; never expose the ACME endpoint directly to the internet;
- Restrict each Issuer to the domains it needs, and limit Vault roles with
allowed_domains; - Enable audit logging on the CA and cert-manager, keeping at least issuance, renewal and failure records;
- Back up the root CA, intermediate CA,
ca.jsonand thedb; rehearsing restore matters more than the backup itself.
Backup and Restore
# Stop the service before backing up so BadgerDB is not archived mid-write
sudo systemctl stop step-ca
# Back up step-ca certificates, keys, config and database
sudo tar czf step-ca-backup.tar.gz \
-C /opt step-ca/certs step-ca/secrets step-ca/config step-ca/db
sudo systemctl start step-ca
# Back up cert-manager resources
kubectl get certificate,certificaterequest,issuer,clusterissuer -A -o yaml \
> cert-manager-backup.yaml
# Back up the TLS Secrets cert-manager generated
kubectl get secrets -A -l cert-manager.io/certificate-name \
-o yaml > tls-secrets-backup.yaml
When restoring, bring the CA back first, then cert-manager’s CRDs and resources, and finally let cert-manager reissue or renew. Do not back up only Secrets without the CA keys, or renewal becomes impossible once certificates expire.
Conclusion
This chain now runs on a single 4 vCPU k3s VM: step-ca is the internal CA, cert-manager handles requests and renewals, Vault PKI issues certificates that need separate audit and policy, Traefik loads certificates from Secrets, and Prometheus/Alertmanager handle metrics and alerts. The hands-on tests cover first issuance, automatic renewal, Ingress annotation issuance, Vault issuance, the alerting chain, and revocation plus CRL queries on both CAs.
A few things are worth doing next:
- Set up DNS-01 for wildcard domains to get around the HTTP-01 limitation;
- Flesh out Vault audit and lease policies;
- Introduce SPIFFE/SPIRE or the cert-manager CSI Driver at larger scale to reduce reliance on Secrets.
Certificate management does not need the most complex setup on day one. Get the CA, Issuer, renewal and alerting working first, then add policy as services become more important; maintenance stays much cheaper.
References
Comments