TLS Secrets for Ingress
What you'll learn: How to create and use TLS certificate Secrets to enable HTTPS termination in Kubernetes Ingress controllers.
Why TLS Secrets Matter
When you expose services through Ingress (which you learned in lesson 1225: TLS Termination with Ingress), you need somewhere secure to store the SSL/TLS certificates and private keys. Kubernetes Secrets provide this storage, keeping your certificates safe while making them available to the Ingress controller.
Think of a TLS Secret as a locked safe deposit box at a bank—it holds your valuable certificates and keys, and only the Ingress controller (the authorized party) can access them to establish secure HTTPS connections.
Creating a TLS Secret
TLS Secrets are a special Secret type (kubernetes.io/tls) that must contain two specific keys:
apiVersion: v1
kind: Secret
metadata:
name: my-tls-secret
namespace: default
type: kubernetes.io/tls
data:
tls.crt: <base64-encoded-certificate>
tls.key: <base64-encoded-private-key>
Or create one imperatively:
kubectl create secret tls my-tls-secret \
--cert=path/to/cert.crt \
--key=path/to/key.key
Referencing in Ingress
Once created, reference the Secret in your Ingress resource:
spec:
tls:
- hosts:
- myapp.example.com
secretName: my-tls-secret
The Ingress controller reads this Secret, extracts the certificate and key, and uses them to terminate TLS connections for the specified host.
Key Takeaway: TLS Secrets store certificates and private keys as kubernetes.io/tls type Secrets, which Ingress controllers use to enable HTTPS termination securely without exposing sensitive cryptographic material.