Using cert-manager in Kubernetes as a CA for External InfrastructureBrief · digest for November 7
Brief≈ 1 min

Using cert-manager in Kubernetes as a CA for External Infrastructure

Deployed in Kubernetes, cert-manager is often treated as a strictly internal cluster tool. However, Michael Pechner reminded us: the controller operates on DNS rather than pods, and can serve as a free CA for external virtual machines.

Instead of running separate certbot daemons, configuring a dns01 challenge is enough. The controller itself will call the DNS API and store the certificate in a Secret:

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-dns01
spec:
  acme:
    email: admin@example.com
    server: https://acme-v02.api.letsencrypt.org/directory
    privateKeySecretRef:
      name: letsencrypt-key
    solvers:
      - dns01:
          cloudflare:
            apiTokenSecretRef:
              name: cloudflare-token
              key: api-token

Once issued, the certificate is fetched onto the target server:

kubectl get secret ext-tls -o jsonpath='{.data.tls\.crt}' | base64 -d > /etc/ssl/app.crt
kubectl get secret ext-tls -o jsonpath='{.data.tls\.key}' | base64 -d > /etc/ssl/app.key
chmod 0600 /etc/ssl/app.key && systemctl reload nginx

Just like in declarative management in Kubernetes, centralization automates key rotation every 60 days.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 3