What You'll Build
In this lab you will expose the IPL analytics platform to external traffic with production-grade HTTPS using the Nginx IngressController and cert-manager with Let's Encrypt. The complete pipeline installs the Nginx IngressController as a DaemonSet with `externalTrafficPolicy: Local`, installs cert-manager with a ClusterIssuer using the Let's Encrypt staging environment for initial validation, deploys an Ingress resource with host-based and path-based routing rules, and verifies the end-to-end TLS chain from browser to backend service. You will then switch to the production Let's Encrypt issuer, simulate a certificate expiry by setting a near-expiry date, and confirm that cert-manager automatically renews the certificate before the expiry threshold — demonstrating the zero-maintenance certificate lifecycle that is one of the primary operational benefits of the cert-manager model.
The lab is structured around a deliberate progression: staging issuer first to validate the ACME configuration without consuming the production rate limit, production issuer second after the staging certificate confirms the entire chain works, and certificate rotation simulation third to provide direct evidence that cert-manager renewal is functioning correctly. This staging-then-production progression is the correct operational protocol for any cert-manager deployment — an error in the ACME configuration that wastes five production certificate requests while debugging consumes 10% of the weekly domain quota, a problem that the staging environment eliminates at no cost.
Prerequisites
- A domain name with DNS management access — the lab uses `ipl.example.com` as a placeholder; substitute your actual domain. For local testing without a real domain, use a wildcard DNS service like nip.io with the cluster's external IP.
- A Kubernetes cluster with an external LoadBalancer provisioner (cloud cluster on EKS, GKE, or AKS) — kind and minikube do not provision external IPs natively and require the MetalLB add-on for this lab.
- Helm v3 installed for the Nginx IngressController and cert-manager installations — verify with `helm version` before beginning.
- AWS Route53 credentials (or equivalent for your DNS provider) stored as a Kubernetes Secret for the DNS-01 ACME solver, or a publicly accessible cluster for HTTP-01 validation.
- The M4 Exercise platform running with StatefulSet PostgreSQL and HPA-configured API Deployment — this lab adds the external access layer on top of the existing platform.
Setup & Project Structure
Install the Nginx IngressController and cert-manager via Helm, which handles all the CRD installation, ServiceAccount provisioning, and RBAC configuration that manual manifest application would require individually. Always install cert-manager's CRDs before the cert-manager Helm chart — the CRDs must exist before the controller starts or it will crash on startup before the CRD admission webhooks are registered.
# Install IngressController and cert-manager via Helm
# ── Nginx IngressController ────────────────────────────────────────────────
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-nginx --create-namespace --set controller.kind=DaemonSet --set controller.hostNetwork=false --set controller.service.externalTrafficPolicy=Local --set controller.metrics.enabled=true --set controller.podAnnotations."prometheus.io/scrape"=true
# Wait for the LoadBalancer external IP to be assigned
kubectl wait svc ingress-nginx-controller -n ingress-nginx --for=jsonpath='{.status.loadBalancer.ingress[0].hostname}' --timeout=300s
INGRESS_IP=$(kubectl get svc ingress-nginx-controller -n ingress-nginx -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
echo "IngressController external address: $INGRESS_IP"
# ── Update DNS A record to point to the IngressController ─────────────────
# For Route53 (replace with actual hosted zone ID and domain):
aws route53 change-resource-record-sets --hosted-zone-id Z1234ABCDEF567 --change-batch '{
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "api.ipl.example.com",
"Type": "CNAME",
"TTL": 300,
"ResourceRecords": [{"Value": "'$INGRESS_IP'"}]
}
}]
}'
# ── cert-manager ───────────────────────────────────────────────────────────
helm repo add jetstack https://charts.jetstack.io
helm repo update
# Install CRDs first (required before the chart)
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.crds.yaml
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=false \ # CRDs already applied above
--set serviceAccount.annotations."eks.amazonaws.com/role-arn"=arn:aws:iam::123456789012:role/cert-manager-route53
kubectl wait pods -n cert-manager -l app.kubernetes.io/instance=cert-manager --for=condition=Ready --timeout=120s
echo "cert-manager ready ✓" Step 1 — Foundation
Create the Let's Encrypt staging ClusterIssuer, deploy the Ingress resource with TLS referencing the staging issuer, and wait for cert-manager to issue the staging certificate. The staging certificate will not be trusted by browsers but is valid for verifying that the ACME challenge, DNS configuration, and IngressController routing all work correctly before committing to a production certificate.
# Step 1: Staging issuer + Ingress + certificate verification
# ── Create staging ClusterIssuer ───────────────────────────────────────────
kubectl apply -f - << 'EOF'
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
spec:
acme:
server: https://acme-staging-v02.api.letsencrypt.org/directory
email: devops@ipl-platform.example.com
privateKeySecretRef: {name: letsencrypt-staging-key}
solvers:
- dns01:
route53:
region: ap-south-1
hostedZoneID: Z1234ABCDEF567
EOF
# ── Deploy Ingress with staging issuer ────────────────────────────────────
kubectl apply -f - << 'EOF'
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ipl-platform-ingress
namespace: production
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-staging"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/limit-rps: "100"
spec:
ingressClassName: nginx
tls:
- hosts: [api.ipl.example.com]
secretName: ipl-tls-staging
rules:
- host: api.ipl.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service: {name: ipl-api, port: {number: 8000}}
EOF
# Watch certificate issuance progress
kubectl get certificate -n production -w
# ipl-tls-staging False ipl-tls-staging 1m ← provisioning
# ipl-tls-staging True ipl-tls-staging 3m ← issued ✓
# Verify with curl (staging cert is not browser-trusted, use -k for curl)
curl -kv https://api.ipl.example.com/health 2>&1 | grep -E "issuer|subject|200"
# issuer: O=fake LE AUTHORITY R3 ← staging CA, confirms ACME flow works ✓
# HTTP/2 200 Step 2 — Core Logic
Switch to the production Let's Encrypt issuer by updating the Ingress annotation and deleting the staging certificate Secret to force a fresh issuance. Verify the production certificate is trusted by the system certificate store and that `curl` without `-k` succeeds. Then simulate a near-expiry scenario by patching the certificate's `renewBefore` to 89 days (effectively treating the 90-day certificate as already within the renewal window) and confirming that cert-manager triggers a renewal.
# Step 2: Production issuer + certificate rotation simulation
# ── Create production ClusterIssuer ───────────────────────────────────────
kubectl apply -f - << 'EOF'
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-production
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: devops@ipl-platform.example.com
privateKeySecretRef: {name: letsencrypt-production-key}
solvers:
- dns01:
route53:
region: ap-south-1
hostedZoneID: Z1234ABCDEF567
EOF
# ── Update Ingress to use production issuer ────────────────────────────────
kubectl annotate ingress ipl-platform-ingress -n production cert-manager.io/cluster-issuer=letsencrypt-production --overwrite
# Delete staging Secret to force new issuance with production CA
kubectl delete secret ipl-tls-staging -n production
# cert-manager detects missing Secret and creates a new Certificate request
# Update Ingress TLS Secret name
kubectl patch ingress ipl-platform-ingress -n production -p '{"spec":{"tls":[{"hosts":["api.ipl.example.com"],"secretName":"ipl-tls-prod"}]}}'
# Wait for production certificate
kubectl wait certificate/ipl-tls-prod -n production --for=condition=Ready --timeout=300s
# Verify production certificate (no -k needed — trusted by browsers)
curl -v https://api.ipl.example.com/health 2>&1 | grep -E "issuer|subject|200"
# issuer: C=US, O=Let's Encrypt, CN=R3 ← production LE CA ✓
# subject: CN=api.ipl.example.com
# HTTP/2 200
# ── Simulate certificate renewal ──────────────────────────────────────────
# Force renewal by annotating the Certificate object
kubectl annotate certificate ipl-tls-prod -n production cert-manager.io/force-renewal="$(date +%s)" --overwrite
# Watch cert-manager renew the certificate
kubectl get certificate ipl-tls-prod -n production -w
# NAME READY SECRET AGE
# ipl-tls-prod True ipl-tls-prod 15m
# ipl-tls-prod False ipl-tls-prod 15m ← renewal in progress
# ipl-tls-prod True ipl-tls-prod 16m ← renewed ✓
# Verify the new certificate's NotAfter date was extended
kubectl get certificate ipl-tls-prod -n production -o jsonpath='{.status.notAfter}'
# Expected: date approximately 90 days from now (new certificate issued) Step 3 — Integration & Enhancement
Verify the complete end-to-end TLS chain: DNS resolution, TLS handshake with the production certificate, HTTP routing to the correct backend service, and the HTTPS redirect for plain HTTP requests. Add a second Ingress rule for the pgAdmin interface using the development profile, demonstrating host-based routing with a wildcard certificate that covers both subdomains.
# End-to-end TLS chain verification + second Ingress host rule
# ── Complete TLS chain verification ────────────────────────────────────────
echo "=== TLS Chain Verification ==="
# 1. DNS resolves to IngressController
echo -n "1. DNS resolves correctly: "
RESOLVED=$(dig +short api.ipl.example.com)
[ -n "$RESOLVED" ] && echo "PASS ✓ ($RESOLVED)" || echo "FAIL ✗ — check DNS record"
# 2. HTTPS returns 200 with valid certificate
echo -n "2. HTTPS with valid cert: "
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://api.ipl.example.com/health)
[ "$STATUS" = "200" ] && echo "PASS ✓" || echo "FAIL ✗ (HTTP $STATUS)"
# 3. HTTP redirects to HTTPS (ssl-redirect annotation)
echo -n "3. HTTP → HTTPS redirect: "
REDIRECT=$(curl -s -o /dev/null -w "%{http_code}" http://api.ipl.example.com/health)
[ "$REDIRECT" = "308" ] && echo "PASS ✓ (308 Permanent Redirect)" || echo "FAIL ✗ (got: $REDIRECT)"
# 4. Certificate is trusted (no -k needed)
echo -n "4. Certificate trusted: "
curl -s https://api.ipl.example.com/health > /dev/null && echo "PASS ✓" || echo "FAIL ✗"
# 5. Certificate expiry is > 60 days away (recently renewed)
echo -n "5. Cert renewed, >60d expiry: "
NOT_AFTER=$(kubectl get certificate ipl-tls-prod -n production -o jsonpath='{.status.notAfter}')
DAYS_LEFT=$(( ( $(date -d "$NOT_AFTER" +%s) - $(date +%s) ) / 86400 ))
[ "$DAYS_LEFT" -gt "60" ] && echo "PASS ✓ ($DAYS_LEFT days left)" || echo "FAIL ✗"
# ── Add rate limiting verification ────────────────────────────────────────
echo -n "6. Rate limiting (429 at 101+): "
RESULT=$(for i in $(seq 1 150); do
curl -s -o /dev/null -w "%{http_code}
" https://api.ipl.example.com/health
done | sort | uniq -c | sort -rn | head -3)
echo "$RESULT"
echo "$RESULT" | grep -q "429" && echo "PASS ✓" || echo "WARN — rate limit may not have triggered"
echo "=== Lab complete ===" Step 4 — Testing & Verification
Complete the lab verification checklist and produce a summary of the complete platform architecture from M1 through M4, tracing each component's role from the container image layer through the Kubernetes workload layer to the external access layer. This architectural summary is the capstone of the first four modules, making the complete system visible as an integrated whole before M5 adds the security and RBAC layer.
# Final lab checklist and platform architecture summary
echo "=== M4 Lab — Ingress TLS & cert-manager Verification ==="
# 1-6 from Step 3 above...
# 7. cert-manager auto-renewal confirmed
echo -n "7. cert-manager auto-renewal: "
kubectl describe certificate ipl-tls-prod -n production | grep -q "Renewed" && echo "PASS ✓" || kubectl describe certificate ipl-tls-prod -n production | grep -q "Issuing" && echo "IN PROGRESS ⏳" || echo "NOT YET TRIGGERED"
echo ""
echo "=== Complete Platform Architecture Summary ==="
echo ""
echo "EXTERNAL LAYER:"
echo " HTTPS://api.ipl.example.com → Route53 DNS → AWS NLB"
echo " NLB → Nginx IngressController DaemonSet (externalTrafficPolicy: Local)"
echo " TLS: Let's Encrypt cert in 'ipl-tls-prod' Secret, auto-renewed by cert-manager"
echo ""
echo "KUBERNETES WORKLOADS:"
kubectl get deployment,statefulset -n production --no-headers -o custom-columns="KIND:.kind,NAME:.metadata.name,READY:.status.readyReplicas"
echo ""
echo "AUTOSCALING:"
kubectl get hpa -n production --no-headers -o custom-columns="NAME:.metadata.name,MIN:.spec.minReplicas,MAX:.spec.maxReplicas,CURRENT:.status.currentReplicas"
echo ""
echo "STORAGE:"
kubectl get pvc -n production --no-headers -o custom-columns="NAME:.metadata.name,STATUS:.status.phase,CAPACITY:.status.capacity.storage"
echo ""
echo "NETWORKING:"
kubectl get svc -n production --no-headers -o custom-columns="NAME:.metadata.name,TYPE:.spec.type,PORT:.spec.ports[0].port"
echo ""
echo "CERTIFICATES:"
kubectl get certificate -n production --no-headers -o custom-columns="NAME:.metadata.name,READY:.status.conditions[0].status,EXPIRY:.status.notAfter" Warning: Let's Encrypt's production ACME endpoint rate-limits certificate issuance to 50 certificates per registered domain per week. If you request more than 50 certificates for `ipl.example.com` in a week — which can happen easily if you are debugging the Ingress configuration and deleting and recreating certificates repeatedly — the domain is rate-limited and all new certificate requests fail with a 429 error for the remainder of the week. Always use the staging environment (`acme-staging-v02.api.letsencrypt.org`) for all testing and debugging, and switch to production only when the staging certificate confirms the entire pipeline is working correctly. The staging environment has a much higher rate limit (30,000 new orders per 3 hours) specifically to allow integration testing.
Extension Challenge: Configure the Ingress with OAuth2 Proxy for the pgAdmin admin interface, requiring GitHub or Google authentication before any request reaches the backend service. Add the annotations nginx.ingress.kubernetes.io/auth-url pointing to the OAuth2 Proxy service and nginx.ingress.kubernetes.io/auth-signin for the authentication redirect. Deploy OAuth2 Proxy as a Deployment with a ClusterIP Service in the production namespace, configured with a GitHub OAuth App client ID and secret stored as a Kubernetes Secret. This exercises Secret injection into a Deployment, external HTTPS callback configuration for the OAuth App, and multi-service Ingress routing where the auth-url annotation introduces a sub-request to the OAuth Proxy before each protected request reaches the backend.
- Always test cert-manager ACME configuration with the Let's Encrypt staging environment before switching to production — staging has a much higher rate limit and prevents production rate limit exhaustion during debugging.
- The three-phase lab structure — staging validation, production issuance, rotation verification — provides independent evidence for three distinct TLS chain properties: ACME configuration, CA trust, and renewal automation.
- Force-renewal annotation (`cert-manager.io/force-renewal`) triggers an immediate certificate renewal outside the automatic schedule, enabling rotation testing without waiting for the 30-day renewal window.
- Nginx `ssl-redirect: true` requires port 80 to be configured on the IngressController's LoadBalancer Service — without port 80, HTTP traffic never reaches the controller to be redirected to HTTPS.
- The complete M1–M4 platform architecture traces a request from `docker build` through ECR registry, Kubernetes Deployment, ClusterIP Service, Ingress routing, NLB, and DNS — each layer built and verified in sequence.
- cert-manager's zero-maintenance TLS model — automatic provisioning on Ingress creation, automatic renewal 30 days before expiry, automatic Secret update — eliminates the operational overhead that made TLS certificate management a common source of production outages.