Skip to main content
πŸŽ“ Claude Code Masterclass Learn AI-assisted development on Udemy β€” plus the companion book on Leanpub & Amazon. Start Learning
cert-manager: Automate TLS Certificates in Kubernetes
DevOps

cert-manager: Automate TLS Certificates in Kubernetes

Zero-touch TLS with cert-manager β€” Let's Encrypt, Venafi, Vault CA, wildcard certs, and automatic renewal for all your Ingress resources.

LB
Luca Berton
Β· 1 min read

What Is cert-manager?

cert-manager automates TLS certificate management in Kubernetes. Issue certificates from Let’s Encrypt, Vault, Venafi, or any ACME-compatible CA β€” with automatic renewal. CNCF Graduated, 12K+ stars.

Installation

helm repo add jetstack https://charts.jetstack.io
helm install cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --set crds.enabled=true

ClusterIssuer (Let’s Encrypt)

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-prod
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email: admin@yourdomain.com
    privateKeySecretRef:
      name: letsencrypt-prod-key
    solvers:
      - http01:
          ingress:
            class: nginx
      - dns01:
          cloudDNS:
            project: my-gcp-project
          selector:
            dnsZones:
              - "yourdomain.com"

Automatic Certificate for Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-app
  annotations:
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
    - hosts:
        - app.yourdomain.com
      secretName: app-tls  # cert-manager creates this automatically
  rules:
    - host: app.yourdomain.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: my-app
                port:
                  number: 8080

That’s it. cert-manager will:

  1. Detect the annotation
  2. Request a certificate from Let’s Encrypt
  3. Complete the HTTP-01 or DNS-01 challenge
  4. Store the cert in the app-tls Secret
  5. Renew automatically 30 days before expiry

Wildcard Certificates (DNS-01)

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: wildcard-cert
  namespace: default
spec:
  secretName: wildcard-tls
  issuerRef:
    name: letsencrypt-prod
    kind: ClusterIssuer
  dnsNames:
    - "yourdomain.com"
    - "*.yourdomain.com"

Wildcard requires DNS-01 challenge (not HTTP-01).

Internal CA (HashiCorp Vault)

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: vault-issuer
spec:
  vault:
    server: https://vault.example.com
    path: pki_int/sign/kubernetes
    auth:
      kubernetes:
        role: cert-manager
        mountPath: /v1/auth/kubernetes
        serviceAccountRef:
          name: cert-manager

Certificate Lifecycle

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Certificate│────▢│ CertRequest  │────▢│   Order     β”‚
β”‚  (desired)  β”‚     β”‚ (internal)   β”‚     β”‚ (ACME)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                    β”‚   Secret     │◀────│  Challenge   β”‚
                    β”‚ (TLS cert)   β”‚     β”‚ (HTTP/DNS)   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                    Auto-renew at 66% lifetime

Monitoring

# PrometheusRule for cert-manager
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
spec:
  groups:
    - name: cert-manager
      rules:
        - alert: CertificateExpiringSoon
          expr: certmanager_certificate_expiration_timestamp_seconds - time() < 7*24*3600
          labels:
            severity: warning
          annotations:
            summary: "Certificate {{ $labels.name }} expires in 7 days"

Free 30-min AI & Cloud consultation

Book Now