查看namespace的标签
[root@k8scloude1 pod]# kubectl get ns --show-labelsNAMESTATUSAGELABELSdefaultActive7d1hkubernetes.io/metadata.name=defaultkube-node-leaseActive7d1hkubernetes.io/metadata.name=kube-node-leasekube-publicActive7d1hkubernetes.io/metadata.name=kube-publickube-systemActive7d1hkubernetes.io/metadata.name=kube-systemns1Active6d5hkubernetes.io/metadata.name=ns1ns2Active6d5hkubernetes.io/metadata.name=ns2podActive4d2hkubernetes.io/metadata.name=pod
查看pod的标签
[root@k8scloude1 pod]# kubectl get pod -A --show-labelsNAMESPACENAMEREADYSTATUSRESTARTSAGELABELSkube-systemcalico-kube-controllers-6b9fbfff44-4jzkj1/1Running127dk8s-app=calico-kube-controllers,pod-template-hash=6b9fbfff44kube-systemcalico-node-bdlgm1/1Running77dcontroller-revision-hash=6b57d9cd54,k8s-app=calico-node,pod-template-generation=1kube-systemcalico-node-hx8bk1/1Running77dcontroller-revision-hash=6b57d9cd54,k8s-app=calico-node,pod-template-generation=1kube-systemcalico-node-nsbfs1/1Running77dcontroller-revision-hash=6b57d9cd54,k8s-app=calico-node,pod-template-generation=1kube-systemcoredns-545d6fc579-7wm951/1Running77d1hk8s-app=kube-dns,pod-template-hash=545d6fc579kube-systemcoredns-545d6fc579-87q8j1/1Running77d1hk8s-app=kube-dns,pod-template-hash=545d6fc579kube-systemetcd-k8scloude11/1Running77d1hcomponent=etcd,tier=control-planekube-systemkube-apiserver-k8scloude11/1Running117d1hcomponent=kube-apiserver,tier=control-planekube-systemkube-controller-manager-k8scloude11/1Running77d1hcomponent=kube-controller-manager,tier=control-planekube-systemkube-proxy-599xh1/1Running77d1hcontroller-revision-hash=6795549d44,k8s-app=kube-proxy,pod-template-generation=1kube-systemkube-proxy-lpj8z1/1Running77d1hcontroller-revision-hash=6795549d44,k8s-app=kube-proxy,pod-template-generation=1kube-systemkube-proxy-zxlk91/1Running77d1hcontroller-revision-hash=6795549d44,k8s-app=kube-proxy,pod-template-generation=1kube-systemkube-scheduler-k8scloude11/1Running77d1hcomponent=kube-scheduler,tier=control-planekube-systemmetrics-server-bcfb98c76-k5dmj1/1Running66d5hk8s-app=metrics-server,pod-template-hash=bcfb98c76
3.4.2 创建标签以node-role.kubernetes.io/control-plane= 标签为例,键是node-role.kubernetes.io/control-plane,值为空 。
创建标签的语法:kubectl label 对象类型 对象名 键=值
给k8scloude2节点设置标签
[root@k8scloude1 pod]# kubectl label nodes k8scloude2 k8snodename=k8scloude2node/k8scloude2 labeled[root@k8scloude1 pod]# kubectl get nodes --show-labelsNAMESTATUSROLESAGEVERSIONLABELSk8scloude1Readycontrol-plane,master7d1hv1.21.0beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8scloude1,kubernetes.io/os=linux,node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=,node.kubernetes.io/exclude-from-external-load-balancers=k8scloude2Ready<none>7d1hv1.21.0beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,k8snodename=k8scloude2,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8scloude2,kubernetes.io/os=linuxk8scloude3Ready<none>7d1hv1.21.0beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8scloude3,kubernetes.io/os=linux
k8scloude2节点删除标签
[root@k8scloude1 pod]# kubectl label nodes k8scloude2 k8snodename-node/k8scloude2 labeled[root@k8scloude1 pod]# kubectl get nodes --show-labelsNAMESTATUSROLESAGEVERSIONLABELSk8scloude1Readycontrol-plane,master7d1hv1.21.0beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8scloude1,kubernetes.io/os=linux,node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=,node.kubernetes.io/exclude-from-external-load-balancers=k8scloude2Ready<none>7d1hv1.21.0beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8scloude2,kubernetes.io/os=linuxk8scloude3Ready<none>7d1hv1.21.0beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8scloude3,kubernetes.io/os=linux
经验总结扩展阅读
- 多情总被无情伤 这些星座是爱情里的傻瓜
- JAVA的File对象
- 秋天冰箱的温度怎么调才正确 冰箱不制冷的原因是什么
- 性格坚强的三大星座女 却最让人心疼
- 外出发展 最易发财的星座
- 画饼专家 这些星座男的话不能全信
- 2023年9月13日是剪指甲吉日吗 2023年9月13日是剪指甲的黄道吉日吗
- 工资过10万的十大职业 哪些工作工资超高
- 2023年9月13日是年前洗澡的黄道吉日吗 2023年农历七月廿九年前洗澡吉日
- 十二星座秉承单身主义的原因 遇不到对的人还是享受孤独