📖 Scenario: You are setting up a simple web application on Kubernetes. You want to secure your website by enabling HTTPS using TLS termination at the Ingress controller. This means the Ingress will handle the encryption and decryption of traffic, so your backend pods receive plain HTTP traffic.
🎯 Goal: Learn how to configure TLS termination on a Kubernetes Ingress resource by creating a TLS secret and referencing it in the Ingress configuration.
📋 What You'll Learn
Create a TLS secret with a certificate and private key
Create an Ingress resource that uses the TLS secret for HTTPS
Configure the Ingress to route traffic to a backend service
Verify that the Ingress is correctly set up for TLS termination
💡 Why This Matters
🌍 Real World
In real Kubernetes deployments, TLS termination at the Ingress controller secures web traffic by encrypting data between users and the cluster. This is a common practice for production web applications.
💼 Career
Understanding TLS termination with Ingress is essential for DevOps engineers and site reliability engineers who manage secure Kubernetes environments and ensure safe communication for applications.
Progress0 / 4 steps
1
Create a TLS secret
Create a TLS secret named my-tls-secret in the default namespace using the certificate file tls.crt and the private key file tls.key. Use the kubectl create secret tls command exactly as shown.
Kubernetes
Hint
Use the kubectl create secret tls command with the exact secret name my-tls-secret and specify the certificate and key files.
2
Create a basic Ingress resource with TLS
Create a YAML file named ingress.yaml that defines an Ingress resource named my-ingress in the default namespace. Add a tls section that references the secret my-tls-secret and sets the host to example.com. Under rules, add a rule for host example.com that routes HTTP traffic to the service named my-service on port 80. Use the exact keys and names as specified.
Kubernetes
Hint
Remember to add the tls section with hosts and secretName. Then add a rules section with the host and backend service details.
3
Apply the Ingress resource
Use the kubectl apply -f ingress.yaml command to create the Ingress resource in the cluster.
Kubernetes
Hint
Use kubectl apply -f ingress.yaml to create or update the Ingress resource.
4
Verify the Ingress TLS setup
Run kubectl describe ingress my-ingress and check the output to confirm that the TLS section shows the secret my-tls-secret and the host example.com. Then print the output exactly as shown.
Kubernetes
Hint
Use kubectl describe ingress my-ingress and look for the TLS secret and host in the output.
Practice
(1/5)
1. What is the main purpose of TLS termination in a Kubernetes Ingress?
easy
A. To monitor network traffic for security threats
B. To encrypt traffic between backend services
C. To generate TLS certificates automatically
D. To decrypt HTTPS traffic at the Ingress before forwarding to backend services
Solution
Step 1: Understand TLS termination role
TLS termination means decrypting encrypted HTTPS traffic at a central point.
Step 2: Identify Ingress function
Kubernetes Ingress can handle TLS termination by decrypting traffic before sending it to backend pods.
Final Answer:
To decrypt HTTPS traffic at the Ingress before forwarding to backend services -> Option D
Quick Check:
TLS termination = decrypt at Ingress [OK]
Hint: TLS termination means decrypting at Ingress, not backend [OK]
Common Mistakes:
Confusing TLS termination with encryption between services