Kubernetes Deep Dive Room

Sign Up Free or Log In to participate!

Can a SVC supports multiple label selectors? How SVC knows which label selector to use?

When client makes a request, do client need to input any label selector to the SVC?

1 Answers

The client sees a service via the service name from kubernetes DNS, remember a service name as soon as it is established it is stable and has a fixed ip. the name of the service is the name specified in the service metadata section.

The service has a selector that will specify one or more labels, so, yes the service can specify more than one label for the selector and all of them have to match pod labels, for the pod to be selected.

you have more control on labels and selections using matchExpressions

       component: redis  
      - {key: tier, operator: In, values: [cache]}  
      - {key: environment, operator: NotIn, values: [dev]}  

 check for more at https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors


I agree with what Walid has said +1

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?