liveBook · Manning

Kubectl set selector

As explained in Kubernetes in Action, Second Edition

kubectl set selector is a kubectl command that changes the label selector of a Kubernetes resource.

kubectl set selector changes the label selector on a Kubernetes Service. The selector determines which pods receive the Service’s forwarded traffic, so changing it can redirect clients between application versions. section 11.1.2

Redirect the quiz Service

A quiz Service initially selects pods labeled app=quiz and rel=stable. To include quiz pods without the stable-release label, run: kubectl set selector service quiz app=quiz. Kubernetes reports service/quiz selector updated. Verify the result with kubectl get svc -o wide. section 11.1.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Defines label matching and demonstrates one command, while deferring broader Service configuration to edits or manifests.
Examples
Uses the quiz Service, stable and canary labels, kubectl set selector, and kubectl get svc -o wide.
What it assumes
Uses Services, pods, and labels as prerequisites while clarifying that matching pod labels determine forwarded traffic.
What you can do after
Operate/configure a Service selector with kubectl and verify the changed selector using kubectl get svc -o wide.
How it connects
Connects Services, label selectors, pods, traffic forwarding, and canary releases.

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.