Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is label?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "what is label". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is label".

I. introduction

Label is actually a pair of key/value, which is associated to objects, and label can be attached to various resource objects, such as Node,Pod,Service,RC, etc.

A resource has multiple tags, which can be managed in different dimensions.

Label can be attached to an object when it is created, or it can be added or modified through API after the object is created.

Second, reasons for using Label

2.1 when there are more and more resources of the same type, it is necessary to divide and manage resources. At this time, you can use Label to name resource objects to facilitate configuration, deployment and other management work, and improve the efficiency of resource management. The function of label is similar to that of Java package, which can manage different files separately, making the whole more organized and convenient for maintenance.

2.2 references to objects are made through Label.

3. Append label to the object when creating the object: apiVersion: v1kind: Namespacemetadata: name: hubble-manager---apiVersion: apps/v1kind: Deploymentmetadata: name: hubble-biz-cm-pod # pod name One set of namespace for one operator: hubble-manager # namespace name spec: replicas: 2 # specify the number of deployments selector: matchLabels: app: hubble-biz-cm # rc when managing pod, select the tag containing app=hubble-biz-cm to manage template: # Pod deployment template metadata: labels: app: hubble-biz-cm # create two tags for pod App,proj proj: hubble-manager spec: containers:-# Collector component image: hubble-biz-cm:2.2.8-008 imagePullPolicy: Always name: hubble-biz-cm # name the container, and the tag is not the same concept The same name is just for easy identification of the application-apiVersion: v1kind: Servicemetadata: name: m-biz-cm namespace: hubble-manager annotations: service.loadbalancer-address-type: "private" # Intranet: public/private service.loadbalancer-provider: "" # operator letter If it is a private network private, ignore the project information of service.loadbalancer-project: "hubble" # service spec: type: LoadBalancer # must be specified as LoadBalancer ports:-name: m-biz-cm port: 9666 # exposed port protocol: TCP # Communication Protocol: optional TCP,UDP targetPort: 9666 # Port selector: app: hubble-biz-cm # of the backend Pod forwarded to specify the Pod to be forwarded The Pod of the app=hubble-biz-cm defined in the spec.template.metadata.labels defined above selected here will be used as the back-end server of the QLB. IV. Label-related commands

1. Add label app=tomcat to the Pod named tomcat.

Kubectl label pods tomcat app=tomcat

2. Change the Pod named tomcat from label to app=tomcat1, and overwrite the existing value

Kubectl label-overwrite pods tomcat app=tomcat1

3. Add all the pod in namespace to label

Kubectl label pods-all test=test

4. Delete the label named "app". (connected by "-" minus sign)

Kubectl label pods tomcat app-

Thank you for your reading, the above is the content of "what is label", after the study of this article, I believe you have a deeper understanding of what is label, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report