Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are Label and Label Selector in kubernetes

Shulou Source: shulou.com Published: 2022-06-01 08:08:07 10月03日 Update

Editor to share with you what Label and Label Selector in kubernetes are, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

One: what is Label

Label is another core concept in the Kubernetes series. Is a set of key/value pairs bound to K8s resource objects. The key of the labels property of the same object must be unique. Label can be attached to various resource objects, such as Node,Pod,Service,RC, etc.

The multi-dimensional resource grouping management function is realized by bundling one or more unused label to the specified resource object, so as to flexibly and conveniently carry out resource allocation, scheduling, configuration, deployment and other management work.

Two: what is Label selector?

Label selector is the core grouping mechanism of Kubernetes. Through label selector clients / users, a group of resource objects with common characteristics or attributes can be identified.

Third, the query conditions of Label selector

Query conditions based on equality of values: similar to the = or in the SQL statement! For example: select * from pod where name= (or! =) 'redis-slave'

Subset-based query conditions: similar to in or not in; in SQL statements such as: select * from pod where name in (or not in) ('redis-slave','redis-master')

The two query conditions can also be combined.

Four: Label selector usage scenarios

The 1.kube-controller process filters the number of Pod replicas to be monitored through the Label Selector defined on the resource object RC, so that the number of Pod replicas always conforms to the expected fully automatic control flow.

The 2.kupe-proxy process selects the corresponding Pod through the Label Selector of Service, and automatically builds each Service to forward the request to the routing table of the corresponding Pod, thus realizing the intelligent load balancing mechanism of Service.

3. By defining a specific Label for some Node and using NodeSelector as a label scheduling strategy in the Pod definition file, the Kube-scheduler process can achieve the Pod-oriented scheduling feature.

The above is all the content of the article "what are Label and Label Selector in kubernetes". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Resources objects conditions queries articles processes scheduling content replicas attributes quantity mechanisms cores statements grouping management balance not much not used fully automatic Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Apple Linux macOS Xiaomi