当前位置:网站首页>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: {
}
边栏推荐
- ABCD four sequential execution methods, extended application
- Highly paid programmers & interview questions: how does redis of series 119 realize distributed locks?
- 用于压缩视频感知增强的多目标网络自适应时空融合
- tars源码分析之3
- notepad++如何统计单词数量
- 在已经知道表格列勾选一个显示一列
- What is tweeman's law?
- Redis interview question set
- Vulhub vulnerability recurrence 77_ zabbix
- CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
猜你喜欢
响应式移动Web测试题
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
颈椎、脚气
2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
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
About how idea sets up shortcut key sets
Wechat applet scroll view component scrollable view area
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
MySQL storage engine
随机推荐
Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
com. alibaba. nacos. api. exception. NacosException
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
[FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
Responsive mobile web test questions
MySQL 45 lecture learning notes (XIV) count (*)
Selenium ide plug-in download, installation and use tutorial
图的底部问题
Mobile adaptation: vw/vh
Redis interview question set
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
Splicing plain text into JSON strings - easy language method
Tar source code analysis 6
Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
Cochez une colonne d'affichage dans une colonne de tableau connue
Mysql 45讲学习笔记(十一)字符串字段怎么加索引
The most effective futures trend strategy: futures reverse merchandising
Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc