当前位置:网站首页>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: {
}
边栏推荐
- What is tweeman's law?
- Tar source code analysis Part 2
- MySQL relearn 2- Alibaba cloud server CentOS installation mysql8.0
- MySQL 45 lecture learning notes (VII) line lock
- MySQL 45 lecture learning notes (12) MySQL will "shake" for a while
- MySQL 45 learning notes (XI) how to index string fields
- uniapp小程序分包
- Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
- [Valentine's day] - you can change your love and write down your lover's name
- MySQL 45 lecture learning notes (XIII) delete half of the table data, and the table file size remains the same
猜你喜欢

List of top ten professional skills required for data science work
![[MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)](/img/03/2b37e63d0d482d5020b7421ac974cb.jpg)
[MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)

Industrial computer anti-virus
![[backpack DP] backpack problem](/img/7e/1ead6fd0ab61806ce971e1612b4ed6.jpg)
[backpack DP] backpack problem

Uniapp applet subcontracting

期末周,我裂开

Splicing plain text into JSON strings - easy language method

Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown

what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!

MySQL relearn 2- Alibaba cloud server CentOS installation mysql8.0
随机推荐
由于dms升级为了新版,我之前的sql在老版本的dms中,这种情况下,如何找回我之前的sql呢?
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
What is tweeman's law?
MySQL 45 learning notes (XI) how to index string fields
notepad++如何统计单词数量
Uniapp applet subcontracting
Highly paid programmers & interview questions: how does redis of series 119 realize distributed locks?
tars源码分析之7
Tar source code analysis 4
How to share the source code anti disclosure scheme
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
How does the inner roll break?
Wechat applet scroll view component scrollable view area
tars源码分析之10
用于压缩视频感知增强的多目标网络自适应时空融合
Review of enterprise security incidents: how can enterprises do a good job in preventing source code leakage?
Fundamentals of SQL database operation
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
Flink memory model, network buffer, memory tuning, troubleshooting
Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes