Skip to content

TLS Certificate Automation with cert-manager

Interactive Diagram

새 탭 ↗

We’ll also cover how cert-manager is used to issue certificates for Ingress inside AKS.

We designed cert-manager to be installed at the cluster level, managed via Argo CD Init as a cluster-wide utility.

Once deployed, cert-manager is used to configure a Let’s Encrypt Issuer as a ClusterIssuer.

Issuing and using a certificate for an Ingress means referencing the ClusterIssuer configured above.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-apps-server
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/backend-protocol: HTTP
nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
spec:
ingressClassName: webapprouting.kubernetes.azure.com
rules:
- host: a.b.example.net
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: a-service
port:
number: 80
tls:
- hosts:
- a.b.example.net
secretName: a.b-letsencrypt-prod

You can follow the standard kubectl apply approach from the cert-manager docs.

We used the manifest at https://github.com/cert-manager/cert-manager/releases/download/v1.17.0/cert-manager.yaml.

Creating a Let’s Encrypt ClusterIssuer

Let’s Encrypt provides two Issuer flavors (Prod and Staging) and the Staging one produces an ā€œunsafe siteā€ warning.

# Prod issuer
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
namespace: cert-manager
spec:
acme:
# The ACME server URL
server: https://acme-v02.api.letsencrypt.org/directory
# Email address used for ACME registration
email: admin@example.com
# Name of a secret used to store the ACME account private key
privateKeySecretRef:
name: letsencrypt-prod
# Enable the HTTP-01 challenge provider
solvers:
- http01:
ingress:
ingressClassName: webapprouting.kubernetes.azure.com
---
# Staging Issuer
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
namespace: cert-manager
spec:
acme:
# The ACME server URL
server: https://acme-staging-v02.api.letsencrypt.org/directory
# Email address used for ACME registration
email: admin@example.com
# Name of a secret used to store the ACME account private key
privateKeySecretRef:
name: letsencrypt-staging
# Enable the HTTP-01 challenge provider
solvers:
- http01:
ingress:
ingressClassName: webapprouting.kubernetes.azure.com

Example Ingress configuration

apiVersion: v1
kind: Namespace
metadata:
name: sample-test
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: store-front
namespace: sample-test
annotations:
kubernetes.io/ingress.class: webapprouting.kubernetes.azure.com
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
tls:
- secretName: sample-app-ingress-cert-prod
hosts:
- app.example.net
rules:
- host: app.example.net
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: sample-test
port:
number: 80

Running this test, you can confirm the certificate was issued successfully:

  • Validate with the staging issuer first. Let’s Encrypt issues at most 50 certificates per registered domain every 7 days, and 5 certificates per exact set of domains every 7 days. Repeatedly retrying against the prod issuer while fixing configuration can hit these limits and block issuance for days. Switch the annotation to letsencrypt-prod only after the Certificate becomes Ready with staging.
  • HTTP-01 requires inbound access on port 80 from the internet. Let’s Encrypt connects directly to http://<domain>/.well-known/acme-challenge/..., so domains behind a private Ingress or firewall fail. For those, and for wildcard certificates (*.example.com), use DNS-01. With Azure DNS, give cert-manager a workload identity so it can create the TXT records.
  • ClusterIssuer is a cluster-scoped resource. The metadata.namespace in the example above is ignored. The ACME account key Secret (privateKeySecretRef) is created in the namespace where cert-manager is installed (cert-manager by default).
  • When issuance stalls, follow the resources in order. cert-manager creates Certificate → CertificateRequest → Order → Challenge. The events from kubectl describe challenge -n <namespace> record the actual cause, such as an HTTP response code or a DNS lookup failure.
  • Monitor expiry. Even if automatic renewal fails, the existing certificate looks fine until it expires. Alert on certificates with fewer than 14 days left using the certmanager_certificate_expiration_timestamp_seconds metric that cert-manager exposes.

Let’s Encrypt is a nonprofit that issues free TLS certificates. Among the types of TLS certificates, it issues fully automatable DV (Domain Validated) certificates for free, using the ACME protocol (RFC 8555). It’s not limited to a root domain or a single subdomain, it also issues free wildcard certificates (*.example.com) that cover every subdomain under one certificate (wildcards are issued only through DNS-01). Issued certificates are valid for 90 days, and cert-manager renews by default at 2/3 of the lifetime (about 30 days before expiry for a 90-day certificate). Renewals that use ACME Renewal Info (ARI) are exempt from the issuance limits, but other renewals may still be subject to some of them, so find the cause of a failed renewal before retrying repeatedly.

cert-manager is a Kubernetes utility that automates certificate management (issuance, renewal), and supports both DNS-based and HTTP-request-based issuance for ACME. HTTP-request-based issuance requires the domain being certified to be reachable over HTTP.

Automating security controls across the whole supply chain (from Secret management, to image vulnerability scanning, to SBOM/signing, CSPM, and automated TLS certificates) as code turns the deployment pipeline itself into the basis for trust. The next article covers the Kubernetes operations practice that these security controls run on top of: Utility configuration, performance testing, and backup/recovery.

Previous post: Operating Cloud Security Posture with CSPM