Geavanceerd
Zoeken inInstallatiegidsen
Zo zoek je
  • Plak een foutmelding tussen aanhalingstekens, bijv. "permission denied", om de oplossingstabel te vinden.
  • Kies een gebied en een deel van de gids (installeren, eerste instellingen, dagelijks gebruik, beveiliging, oplossingen) om direct naar de juiste stap te gaan.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Gids 55cert-manager · Kubernetes

Install and set up cert-manager (TLS in Kubernetes)

cert-manager gets and renews TLS certificates inside Kubernetes: from Let's Encrypt (ACME), your company CA, HashiCorp Vault or a self-signed CA. You describe the certificate you want; cert-manager makes the key, solves the challenge, stores the certificate in a Secret and renews it before it expires. This guide installs cert-manager with Helm, creates staging and production Let's Encrypt issuers (HTTP-01 and DNS-01), gets certificates for an Ingress or a Gateway, and covers the debugging chain when a certificate is not ready.

  • 9 Lessen
  • 3 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

55.1

Know it before you install

An Issuer (one namespace) or ClusterIssuer (whole cluster) says how to get certificates. A Certificate says what you want (DNS names, secret name). cert-manager creates a CertificateRequest → Order → Challenge (for ACME) and finally a Secret of type kubernetes.io/tls.

ItemValue
InstallHelm chart jetstack/cert-manager (or oci://quay.io/jetstack/charts/cert-manager)
Namespacecert-manager (controller, webhook, cainjector)
CRDsCertificate, Issuer, ClusterIssuer, CertificateRequest, Order, Challenge
CLIcmctl (optional)
Outputa TLS Secret (tls.crt, tls.key) in the app namespace

What you need: a Kubernetes cluster, Helm, an ingress controller or Gateway that is reachable on port 80 from the internet (for HTTP-01), or API access to your DNS (for DNS-01).

55.2

Install with Helm

Pin the version (see the cert-manager releases):

helm repo add jetstack https://charts.jetstack.io
helm repo update
helm upgrade --install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --version v1.19.1 --set crds.enabled=true --set prometheus.enabled=true --wait
kubectl -n cert-manager get pods
cert-manager-6d…               1/1   Running
cert-manager-cainjector-5f…    1/1   Running
cert-manager-webhook-7b…       1/1   Running

crds.enabled=true installs the CRDs with the chart. Keep the version pinned and upgrade on purpose.

55.3

First configuration: Let's Encrypt issuers

Always start with staging (no rate limits), then switch to production:

cluster-issuers.yaml
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-staging
spec:
  acme:
    server: https://acme-staging-v02.api.letsencrypt.org/directory
    email: ops@example.com
    privateKeySecretRef:
      name: letsencrypt-staging-account
    solvers:
      - http01:
          ingress:
            ingressClassName: nginx
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-prod
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email: ops@example.com
    privateKeySecretRef:
      name: letsencrypt-prod-account
    solvers:
      - http01:
          ingress:
            ingressClassName: nginx
kubectl apply -f cluster-issuers.yaml
kubectl get clusterissuer
NAME                  READY
letsencrypt-staging   True
letsencrypt-prod      True

For wildcards or clusters that are not public, use DNS-01. Example with Cloudflare (an API token that may only edit DNS of that zone):

kubectl -n cert-manager create secret generic cloudflare-api-token --from-literal=api-token='CF_TOKEN_HERE'
dns01-solver.yaml
    solvers:
      - dns01:
          cloudflare:
            apiTokenSecretRef:
              name: cloudflare-api-token
              key: api-token
        selector:
          dnsZones: ["example.com"]

(Add this solver to a ClusterIssuer's solvers list. Route 53, Azure DNS, Google Cloud DNS and others work the same way — best with workload identity instead of keys.)

55.4

Get certificates

The easy way — an annotation on the Ingress; cert-manager makes the Certificate for you:

ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: shop
  namespace: shop
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  ingressClassName: nginx
  tls:
    - hosts: [shop.example.com]
      secretName: shop-tls
  rules:
    - host: shop.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service: { name: shop, port: { number: 80 } }

Or an explicit Certificate (also for a Gateway listener, or any app that reads a TLS secret):

certificate.yaml
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: wildcard-example
  namespace: gateway
spec:
  secretName: wildcard-example-tls
  dnsNames: ["example.com", "*.example.com"]
  issuerRef:
    kind: ClusterIssuer
    name: letsencrypt-prod
  privateKey:
    algorithm: ECDSA
    size: 256
    rotationPolicy: Always
kubectl apply -f certificate.yaml
kubectl -n gateway get certificate
NAME               READY   SECRET                 AGE
wildcard-example   True    wildcard-example-tls   2m

cert-manager renews 30 days (one third of the lifetime) before expiry by default.

55.5

Daily use: check and debug

When a certificate is not READY, follow the chain down:

kubectl get certificate,certificaterequest,order,challenge -A
kubectl -n shop describe certificate shop-tls
kubectl -n shop describe order shop-tls-1-123456
kubectl -n shop describe challenge shop-tls-1-123456-789
kubectl -n cert-manager logs deploy/cert-manager --tail 50
cmctl status certificate shop-tls -n shop
cmctl renew shop-tls -n shop
kubectl -n shop get secret shop-tls -o jsonpath='{.data.tls\.crt}' | base64 -d | openssl x509 -noout -subject -enddate

Real uses at work:

  • HTTPS for every Ingress/Gateway without manual work.
  • An internal CA (CA or Vault issuer) for mTLS between services.
  • Wildcard certificates with DNS-01 for many subdomains.

55.6

Make it safe

Security checklist:

  • Test with the staging issuer first (Let's Encrypt rate limits).
  • DNS API tokens with the smallest scope (one zone, DNS edit), or workload identity.
  • RBAC: only platform admins may create/modify ClusterIssuers.
  • rotationPolicy: Always for new private keys at every renewal.
  • Monitor expiry (cert-manager Prometheus metrics certmanager_certificate_expiration_timestamp_seconds) and alert.
  • Keep cert-manager updated; its webhook must stay reachable from the API server.

55.7

Update and remove

helm repo update
helm upgrade cert-manager jetstack/cert-manager -n cert-manager --version v1.19.2 --reuse-values --wait

Read the upgrade notes for every minor version. Before removing cert-manager, delete or back up your Certificates and Issuers; removing the CRDs deletes all those objects.

Commando's in deze les

55.8

Fix common problems

ProblemCauseFix
Challenge pending: Waiting for HTTP-01 challenge propagation: … 404The challenge URL is not reachable from the internet on port 80.DNS must point to the ingress; open port 80; check the ingressClassName in the solver.
Challenge pending with DNS-01Wrong token rights or wrong zone.describe challenge; check the token and dnsZones.
Order errored: rateLimitedToo many certificates for the domain.Wait; use staging for tests.
Internal error occurred: failed calling webhook "webhook.cert-manager.io"The API server can not reach the webhook (firewall, private clusters).Allow the control plane to reach the webhook port (often 10250); check the webhook Pod.
Issuer not ReadyWrong ACME URL or account secret.kubectl describe clusterissuer; check the email and server URL.
Browser shows a "Fake LE" certificateYou used the staging issuer.Change to letsencrypt-prod; delete the old secret so a new one is issued.

55.9

Next steps

1Which objects does cert-manager create on the way to a certificate?

CertificateRequest → Order → Challenge, and finally the TLS Secret.

2Why start with the Let's Encrypt staging issuer?

Staging has no strict rate limits, so mistakes do not block your domain.

Alle commando's in dit hoofdstuk