Kubernetes Labels & Selectors - Kubernetes

What is Kubernetes Labels & Selectors?

Labels

A key-value pairs which are attached to pods, replication controller and services is called Labels. They are used as recognizing attributes for objects such as pods and replication controller. They can be appended to an object at creation time and can be added or altered at the run time.

Selectors

Labels do not offer individuality. In overall, we can say numerous objects can carry the same labels. Labels selector are core grouping primitive in Kubernetes. They are used by the users to choose a set of objects.
Kubernetes API currently supports two type of selectors −

  • Equality-based selectors
  • Set-based selectors

Equality-based Selectors

They let filtering by key and value. Matching objects should please all the stated labels.

Set-based Selectors

Set-based selectors allow filtering of keys according to a set of values.

In the above code, we are using the label selector as app: salesplatform and component as component: neo4j.

When we run the file using the kubectl command, it will make a service with the name sp-neo4j-standalone which will connect on port 7474. The ype is NodePort with the new label selector as app: salesplatform and component: neo4j.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Kubernetes Topics