Kubernetes Label 相关命令

Kubernetes About 528 words

查看标签

kubectl get pod nginx -n dev --show-labels

为 Pod 资源打标签

kubectl label pod nginx xxx=ccc -n dev

查看标签

[root@k8s-master ~]# kubectl get pod --show-labels -n dev
NAME    READY   STATUS    RESTARTS   AGE    LABELS
nginx   1/1     Running   0          2m7s   xxx=ccc

为 Pod 资源更新标签

kubectl label pod nginx xxx=ddd -n dev --overwrite

筛选标签

-l参数指定要筛选的标签

kubectl get pod -n dev -l xxx=ddd --show-labels

删除标签

标签-,如:xxx-

kubectl label pod nginx xxx- -n dev

输出:

[root@k8s-master ~]# kubectl label pod nginx xxx- -n dev
pod/nginx unlabeled
Views: 1,548 · Posted: 2022-03-07

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh