Kubernetes: Trusted TLS Certificate with a LoadBalancer Service and Ingress

How it fits together

Browser → cloud LoadBalancer (public IP) → Ingress Controller → Ingress rule (TLS ends here) → app Service (ClusterIP) → Pods
The certificate lives in a Kubernetes Secret, and the Ingress uses it. There are two ways to get a certificate that browsers trust:

  • Path A: public domain. cert-manager gets a free Let's Encrypt certificate and renews it automatically. Every browser trusts it with no extra setup. Use this if you can.
  • Path B: internal or private site. You create your own CA (certificate authority) and install it on each client machine so they trust it.

Step 0: Prerequisites

  • A working cluster on a cloud or bare metal. On bare metal you need MetalLB so LoadBalancer Services get an IP.
  • kubectl and helm installed.
  • For Path A: a domain you control, for example app.example.com.

Step 1: Install an Ingress Controller (this creates the LoadBalancer Service)

Note: the community ingress-nginx project was retired in March 2026 and no longer gets fixes. For new clusters, use a maintained controller. This guide uses Traefik. The Ingress and cert-manager steps are the same for any controller; only the ingressClassName changes.

helm repo add traefik https://traefik.github.io/charts helm repo update helm install traefik traefik/traefik -n traefik --create-namespace 

Get the external IP of the LoadBalancer:

kubectl get svc -n traefik traefik # NAME TYPE EXTERNAL-IP PORT(S) # traefik LoadBalancer a1b2c3d4e5f6-1234567890.us-east-1.elb.amazonaws.com 80:3xxxx/TCP,443:3xxxx/TCP 

If it shows <pending>, wait a minute. On bare metal, check MetalLB.

Step 2: Point DNS at the LoadBalancer

At your DNS provider, create an A record: app.example.com → 203.0.113.10. On AWS, which gives a hostname a1b2c3d4e5f6-1234567890.us-east-1.elb.amazonaws.com instead of an IP, create a CNAME instead. a1b2c3d4e5f6-1234567890.us-east-1.elb.amazonaws.com=> app.example.com

Check it:

nslookup app.example.com 

Step 3: Deploy your app and a ClusterIP Service

# app.yaml apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: replicas: 2 selector: matchLabels: { app: myapp } template: metadata: labels: { app: myapp } spec: containers: - name: myapp image: nginx:stable # replace with your image  ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: myapp-svc spec: type: ClusterIP # the Ingress handles outside traffic, not this Service  selector: { app: myapp } ports: - port: 80 targetPort: 80 
kubectl apply -f app.yaml 

Path A: Trusted certificate with cert-manager and Let's Encrypt

Step 4: Install cert-manager

helm repo add jetstack https://charts.jetstack.io helm repo update helm install cert-manager jetstack/cert-manager \ -n cert-manager --create-namespace \ --set crds.enabled=true kubectl get pods -n cert-manager # all 3 pods should be Running 

Step 5: Create the ClusterIssuers (staging first, then production)

Let's Encrypt limits how many certificates production can issue, so test against staging first.

# issuers.yaml # For Staging apiVersion: cert-manager.io/v1 kind: ClusterIssuer metadata: name: letsencrypt-staging spec: acme: server: https://acme-staging-v02.api.letsencrypt.org/directory email: you@example.com privateKeySecretRef: name: letsencrypt-staging-key # cert-manager generates an ACME account private key and stores it inside a Kubernetes Secret.  # This key identifies your account when communicating with Let's Encrypt.  # Important: This is not your application's TLS private key. They are two separate secrets.  solvers: - http01: ingress: ingressClassName: traefik --- # For Prod apiVersion: cert-manager.io/v1 kind: ClusterIssuer metadata: name: letsencrypt-prod spec: acme: server: https://acme-v02.api.letsencrypt.org/directory email: you@example.com privateKeySecretRef: name: letsencrypt-prod-key solvers: - http01: ingress: ingressClassName: traefik 
  • This YAML file creates a ClusterIssuer using cert-manager in Kubernetes.
  • Its responsibility is to tell cert-manager how to obtain SSL/TLS certificates from Let's Encrypt automatically, using Traefik as the Ingress Controller to verify domain ownership.
  • cert-manager creates an account on Let's Encrypt's server and saves the account key in the letsencrypt-staging-key Secret
kubectl apply -f issuers.yaml kubectl get clusterissuer # READY should be True kubectl get clusterissuer letsencrypt-staging # READY should be True 

Step 6: Create the Ingress with TLS

# ingress.yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: myapp-ingress annotations: cert-manager.io/cluster-issuer: letsencrypt-staging # switch to letsencrypt-prod once staging works  # tells cert-manager to get a certificate spec: ingressClassName: traefik tls: - hosts: - app.example.com secretName: myapp-tls # Your website certificate and its key  # cert-manager saves the Let's Encrypt certificate here  rules: - host: app.example.com http: paths: - path: / pathType: Prefix backend: service: name: myapp-svc port: number: 80 
kubectl apply -f ingress.yaml 

cert-manager sees the annotation, creates a Certificate, completes the HTTP-01 challenge on port 80, and stores the certificate in myapp-tls.

Step 7: Verify, then switch to production

kubectl get certificate # READY = True kubectl describe certificate myapp-tls curl -vk https://app.example.com # issuer should mention "(STAGING)" 

Once staging works, switch to production. Delete the staging Secret so a new certificate is issued:

kubectl annotate ingress myapp-ingress cert-manager.io/cluster-issuer=letsencrypt-prod --overwrite kubectl delete secret myapp-tls kubectl get certificate -w # wait for READY = True curl -v https://app.example.com # no -k needed: the certificate is publicly trusted 

Renewal is automatic. cert-manager renews about 30 days before expiry.

If it doesn't work

Symptom Check
Certificate stuck at False kubectl get challenges,orders -A, then kubectl describe challenge <name>
Challenge fails DNS must point to the LB IP, and port 80 must be open to the internet
Wildcard needed (*.example.com) Use a DNS-01 solver (Cloudflare, Route53, etc.) instead of HTTP-01
Wrong certificate served secretName and hosts in tls: must match the rules.host

Path B: Internal site with your own CA

Step 4B: Create a CA and a server certificate

# Assume: app.internal.local is a domain name (hostname) for your internal website or application. # 1. Create the CA (keep ca.key safe) openssl genrsa -out ca.key 4096 openssl req -x509 -new -nodes -key ca.key -sha256 -days 3650 \ -subj "/CN=My Internal CA" -out ca.crt # Check it openssl x509 -in ca.crt -noout -subject -enddate # These two commands generate a private key and a Certificate Signing Request (CSR) for your website openssl genrsa -out tls.key 2048 openssl req -new -key tls.key -subj "/CN=app.internal.local" -out tls.csr # 3. Sign it with the CA. Browsers require the SAN entry. cat > san.ext <<EOF subjectAltName = DNS:app.internal.local extendedKeyUsage = serverAuth EOF openssl x509 -req -in tls.csr -CA ca.crt -CAkey ca.key -CAcreateserial \ -out tls.crt -days 825 -sha256 -extfile san.ext # ca.crt => Your CA certificate # ca.key => Your CA private key # tls.crt => Website certificate # tls.key => Website private key # Check the certificate: openssl x509 -in tls.crt -noout -subject -issuer -dates -ext subjectAltName openssl verify -CAfile ca.crt tls.crt # should print: tls.crt: OK 

Step 5B: Store it as a TLS Secret - Store the certificate in a Kubernetes Secret

kubectl create secret tls myapp-tls --cert=tls.crt --key=tls.key kubectl get secret myapp-tls # TYPE: kubernetes.io/tls 

Step 6B: Create the Ingress with TLS

No cert-manager annotation is needed here:

# ingress.yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: myapp-ingress spec: ingressClassName: traefik tls: - hosts: - app.internal.local secretName: myapp-tls # the Secret from Step 5  rules: - host: app.internal.local # must match the certificate's hostname  http: paths: - path: / pathType: Prefix backend: service: name: myapp-svc port: number: 80 

Step 7B: Make clients trust your CA

Install ca.crt (never ca.key) on each machine that will open the site:

OS Command
Ubuntu/Debian sudo cp ca.crt /usr/local/share/ca-certificates/my-ca.crt && sudo update-ca-certificates
RHEL/Fedora sudo cp ca.crt /etc/pki/ca-trust/source/anchors/ && sudo update-ca-trust
Windows (admin) certutil -addstore -f "Root" ca.crt
macOS sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ca.crt
  • Firefox keeps its own trust store, so import the CA under Settings → Certificates → Authorities. Pods that call the site also need ca.crt, for example mounted from a ConfigMap
  • Restart the browser after installing.
  • For many Windows PCs, push the CA through Group Policy.

Test:

# without installing the CA, pass it directly: curl -v --cacert ca.crt https://app.internal.local # after installing the CA on the machine: curl -v https://app.internal.local 

In the browser, open https://app.internal.local. You should see a padlock and no warning.

Tip: to avoid managing certificates by hand, load your CA into cert-manager as a CA issuer. Then Ingresses get auto-renewed internal certificates, just like Path A:
Steps:

# Give cert-manager your CA kubectl create secret tls my-ca -n cert-manager --cert=ca.crt --key=ca.key kubectl get secret my-ca -n cert-manager # The Secret must be in the cert-manager namespace. 

Create the CA issuer:

# internal-ca-issuer.yaml apiVersion: cert-manager.io/v1 kind: ClusterIssuer metadata: name: internal-ca spec: ca: secretName: my-ca 
kubectl apply -f internal-ca-issuer.yaml kubectl get clusterissuer internal-ca # READY = True # If it isn't ready, run kubectl describe clusterissuer internal-ca. The Secret name or namespace is usually wrong. 

Add the annotation to your Ingress:

# ingress.yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: myapp-ingress annotations: cert-manager.io/cluster-issuer: internal-ca # ← turns on automatic certificates  cert-manager.io/duration: 2160h # optional: certificate valid 90 days  cert-manager.io/renew-before: 720h # optional: renew 30 days before expiry spec: ingressClassName: traefik tls: - hosts: - app.internal.local secretName: myapp-tls # cert-manager creates and renews this  rules: - host: app.internal.local http: paths: - path: / pathType: Prefix backend: service: name: myapp-svc port: number: 80 

Check that the certificate was issued:

kubectl get certificate # NAME READY SECRET AGE # myapp-tls True myapp-tls 30s kubectl describe certificate myapp-tls # look for: Not After: (expiry date) # Renewal Time: (when cert-manager will renew it automatically) # Check which issuer signed it: kubectl get secret myapp-tls -o jsonpath='{.data.tls\.crt}' | base64 -d \ | openssl x509 -noout -subject -issuer -dates # issuer should be: CN = My Internal CA 

Test that renewal works (optional, but recommended):
Force a renewal now instead of waiting. Install cmctl, the cert-manager CLI, from its GitHub releases page, then run:

cmctl renew myapp-tls 

Or, without cmctl, delete the Secret and cert-manager recreates it:

kubectl delete secret myapp-tls # Then check: kubectl get certificate -w # READY goes back to True kubectl describe certificate myapp-tls # new "Not Before" date 

If this works, automatic renewal will work too.

Summary

The difference between the path A and B is who creates the myapp-tls Secret that contains both the website's signed certificate and its private key:

  • cert-manager sees the annotation on the Ingress.
  • cert-manager gets the website certificate from Let's Encrypt in Path A, or by signing it with your CA in Path B.
  • cert-manager saves the certificate and key into the Secret named myapp-tls
  • Traefik reads myapp-tls and uses it for HTTPS.
  • Before expiry, cert-manager gets a new certificate and saves it into the same myapp-tls