0
0
Kubernetesdevops~30 mins

A/B testing with Ingress in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
A/B Testing with Ingress in Kubernetes
📖 Scenario: You are working as a DevOps engineer for a web application team. They want to test two versions of their website to see which one users prefer. This is called A/B testing. You will use Kubernetes Ingress to route 50% of the traffic to version A and 50% to version B.
🎯 Goal: Set up a Kubernetes Ingress resource that splits incoming traffic evenly between two backend services named version-a and version-b. This will enable A/B testing by sending half of the users to each version.
📋 What You'll Learn
Create an Ingress resource named ab-testing-ingress
Use the nginx Ingress controller annotations for traffic splitting
Route traffic to two services: version-a and version-b
Split traffic evenly: 50% to version-a and 50% to version-b
Use the host example.com and path /
💡 Why This Matters
🌍 Real World
A/B testing helps teams improve websites by comparing two versions with real users. Kubernetes Ingress can route traffic to different versions easily.
💼 Career
DevOps engineers often configure Ingress controllers for traffic management, load balancing, and testing new application versions safely.
Progress0 / 4 steps
1
Create the basic Ingress resource
Create a Kubernetes Ingress resource named ab-testing-ingress with host example.com and path / that routes all traffic to the service version-a on port 80. Use the networking.k8s.io/v1 API version.
Kubernetes
Need a hint?

Define an Ingress with one rule for host example.com and path /. Set the backend service to version-a on port 80.

2
Add annotation for traffic splitting
Add the annotation nginx.ingress.kubernetes.io/canary with value "true" to the Ingress metadata to enable canary traffic splitting.
Kubernetes
Need a hint?

Add the annotation under metadata with key nginx.ingress.kubernetes.io/canary and value "true".

3
Add the canary backend with weight
Add a second path entry under spec.rules[0].http.paths with the same path / and pathType Prefix. Set the backend service name to version-b and port number to 80. Add the annotations nginx.ingress.kubernetes.io/canary-weight with value 50 to split traffic evenly.
Kubernetes
Need a hint?

Add a second path with the same / path and backend service version-b. Add the annotation nginx.ingress.kubernetes.io/canary-weight: "50" to split traffic evenly.

4
Display the final Ingress YAML
Print the complete Ingress YAML configuration to verify the A/B testing setup.
Kubernetes
Need a hint?

Use print statements to output the full Ingress YAML exactly as configured.