当前位置:网站首页>Label management of kubernetes cluster
Label management of kubernetes cluster
2022-07-04 06:59:00 【Fate in the Jianghu】
kubernetes Cluster Label management
One 、Label Introduce
1. The label is k8s Characteristic management way , Easy to classify and manage resource objects .
2. A tag can correspond to multiple resources , A resource can also have multiple tags , They are many to many relationships .
3. A special resource object , Must be attached to a specific resource object , Used to identify the purpose of the resource object .
4. A resource has multiple tags , Can achieve different dimensions of Management .
Two 、 Check local k8s State of the cluster
[[email protected]-master ~]# kubectl get nodes -owide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-master Ready control-plane,master 18h v1.23.1 192.168.3.201 <none> CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 containerd://1.6.6
k8s-node01 Ready <none> 18h v1.23.1 192.168.3.202 <none> CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 containerd://1.6.6
k8s-node02 Ready <none> 18h v1.23.1 192.168.3.203 <none> CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 containerd://1.6.6
3、 ... and 、Label The creation of
1. Add a label to the work node
[[email protected]-master ~]# kubectl label nodes k8s-node02 fun=work02
node/k8s-node02 labeled
2. to pod tagged
[[email protected]-master ~]# kubectl label pod cirror-28253 fun=ittest
pod/cirror-28253 labeled
[[email protected]-master ~]# kubectl label pod cirror-28253 env=proc
pod/cirror-28253 labeled
3. Label the work node with role
[[email protected]-master ~]# kubectl label nodes k8s-node01 node-role.kubernetes.io/worker=
node/k8s-node01 labeled
Four 、Label Modification of
Modify the label
[[email protected]-master ~]# kubectl label nodes k8s-node02 fun=node02 --overwrite
node/k8s-node02 labeled
5、 ... and 、Label Query for
1. List all labels of the node
[[email protected]-master ~]# kubectl get nodes --show-labels
NAME STATUS ROLES AGE VERSION LABELS
k8s-master Ready control-plane,master 18h v1.23.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-master,kubernetes.io/os=linux,node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=,node.kubernetes.io/exclude-from-external-load-balancers=
k8s-node01 Ready worker 18h v1.23.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-node01,kubernetes.io/os=linux,node-role.kubernetes.io/worker=
k8s-node02 Ready <none> 18h v1.23.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,fun=node02,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-node02,kubernetes.io/os=linux,type=dell730
2. Query with worker Nodes of a role
[[email protected]-master ~]# kubectl get nodes -l node-role.kubernetes.io/worker
NAME STATUS ROLES AGE VERSION
k8s-node01 Ready worker 18h v1.23.1
3. Query with type Node of label
[[email protected]-master ~]# kubectl get nodes -l type
NAME STATUS ROLES AGE VERSION
k8s-node02 Ready <none> 18h v1.23.1
6、 ... and 、Label The deletion of
[[email protected]-master ~]# kubectl label nodes k8s-node02 fun-
node/k8s-node02 unlabeled
[[email protected]-master ~]# kubectl get node -l fun
No resources found
7、 ... and 、kubernetes Annotations use
1. Add notes to the work node
[[email protected]-master ~]# kubectl annotate nodes k8s-node01 test="this is a work node"
node/k8s-node01 annotated
2. View comments
[[email protected]-master ~]# kubectl describe nodes k8s-node01 |grep test
test: this is a work node
3. Modify the note
kubectl annotate nodes k8s-node01 test=11 --overwrite
4. Delete comments
kubectl annotate nodes k8s-node01 test-
8、 ... and 、 stay yaml Label usage of script
[[email protected]-master ~]# kubectl run web01 --image=nginx:1.21 -n k8s-test -o yaml --dry-run=client
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: web01
name: web01
namespace: k8s-test
spec:
containers:
- image: nginx:1.21
name: web01
resources: {
}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {
}
边栏推荐
- Splicing plain text into JSON strings - easy language method
- JS common time processing functions
- Tar source code analysis 9
- tars源码分析之8
- Redis interview question set
- tars源码分析之6
- Cell reports: Wei Fuwen group of the Institute of zoology, Chinese Academy of Sciences analyzes the function of seasonal changes in the intestinal flora of giant pandas
- Deep profile data leakage prevention scheme
- 云Redis 有什么用? 云redis怎么用?
- [FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
猜你喜欢
响应式移动Web测试题
Fundamentals of SQL database operation
颈椎、脚气
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
Campus network problems
Industrial computer anti-virus
A new understanding of how to encrypt industrial computers: host reinforcement application
About how idea sets up shortcut key sets
校园网络问题
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
随机推荐
How does the recv of TCP socket receive messages of specified length?
[FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
MySQL 45 learning notes (XI) how to index string fields
thread priority
Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes
2022年,或許是未來10年經濟最好的一年,2022年你畢業了嗎?畢業後是怎麼計劃的?
Latex中的单引号,双引号如何输入?
A new understanding of how to encrypt industrial computers: host reinforcement application
Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
Deep profile data leakage prevention scheme
测试用例的设计
Centos8 install mysql 7 unable to start up
notepad++如何统计单词数量
What is industrial computer encryption and how to do it
Tar source code analysis Part 2
Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
tars源码分析之7
What is a spotlight effect?
What is tweeman's law?
leetcode825. 适龄的朋友