有没有办法根据特定的元数据标签获取名称空间

问题描述 投票:1回答:1

My namespace有一些自定义元数据标签。有些标签有些没有。有没有办法使用kubectl获取具有特定标签的命名空间?

kubernetes kubectl
1个回答
1
投票

是。像这样:

$ kubectl create ns nswithlabels

$ kubectl label namespace nswithlabels this=thing

$ kubectl describe ns/nswithlabels
Name:         nswithlabels
Labels:       this=thing
Annotations:  <none>
Status:       Active

No resource quota.

No resource limits.

$ kubectl get ns -l=this
NAME           STATUS    AGE
nswithlabels   Active    6m

注意:我也可以在最后一个命令中使用-l=this=thing来指定匹配所需的键和值。

© www.soinside.com 2019 - 2024. All rights reserved.