Question 15
Domain 4: Services, Networking, and Service DiscoveryIn namespace q36, how should you update Service app-svc to switch traffic from app-blue to app-green in a blue-green deployment?
Correct answer: A
Explanation
In a blue-green deployment, the Service routes traffic by its selector, so changing the selector changes which pods receive requests. Updating the Service to match the labels on app-green pods switches traffic away from app-blue without changing the application itself.
Why each option is right or wrong
A. Patch the Service selector to match the labels used by app-green pods instead of app-blue pods.
Kubernetes Services route traffic by matching the Service’s `.spec.selector` against Pod labels, as defined in the Service API (`v1/Service`). In namespace `q36`, patching `app-svc` so its selector matches the labels on the `app-green` Pods causes Endpoints/EndpointSlices to be rebuilt to point at those Pods, which immediately shifts traffic away from `app-blue` without recreating the Service or changing the workload objects.
B. Scale app-green to 0 and scale app-blue to a higher replica count.
C. Change the Service type from ClusterIP to LoadBalancer.
D. Edit the Deployment image for app-blue from nginx:1.20 to nginx:1.25.