⑤. 给k8s对象打标签
- ①. 通过命令行的方式打标签
[root@k8smaster k8syaml]# kubectl get pod NAME READY STATUS RESTARTS AGE mynginx 1/1 Running 0 34s [root@k8smaster k8syaml]# kubectl label pod mynginx name=tangzhi # 将mynginx进行打标签 pod/mynginx labeled [root@k8smaster k8syaml]# kubectl get pod --show-labels # 查看pod的标签 NAME READY STATUS RESTARTS AGE LABELS mynginx 1/1 Running 0 91s name=tangzhi,run=mynginx [root@k8smaster k8syaml]# kubectl label pod mynginx name- # 将标签name进行删除 pod/mynginx labeled [root@k8smaster k8syaml]# kubectl get pod --show-labels NAME READY STATUS RESTARTS AGE LABELS mynginx 1/1 Running 0 119s run=mynginx
②. 通过yaml的方式打标签