Docs/CloudNative/Kubernetes/Base/Pod标签.md
2022-10-18 16:59:37 +08:00

25 lines
No EOL
593 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```
## 查看命名空间default中的pod
kubectl get pods -n default --show-labels
```
结果如下:
```
NAME READY STATUS RESTARTS AGE LABELS
demo 1/1 Running 1 8d env=test,app=demo,version=v1
```
```
## 修改label
kubectl label -n default demo env=pre --ovwewrite
```
```
## 去掉label,标签名字后边加上一个减号(-
kubectl label -n default demo version-
```
```
## 查询标签为某个(些)值的pod
kubectl get pods -n default --show-labels -l env=pre
kubectl get pods -n default --show-labels -l 'env in (pre,test)'
```