我想使用基于集合的选择器来过滤豆荚。
以下豆荚
+ kubectl get pods --show-labels
NAME READY STATUS RESTARTS AGE LABELS
csi-cephfsplugin-dk7g6 3/3 Running 0 7d12h app=csi-cephfsplugin,controller-revision-hash=758476fc67,pod-template-generation=12
csi-cephfsplugin-jlcpv 3/3 Running 0 7d12h app=csi-cephfsplugin,controller-revision-hash=758476fc67,pod-template-generation=12
csi-cephfsplugin-ll85n 3/3 Running 0 7d12h app=csi-cephfsplugin,controller-revision-hash=758476fc67,pod-template-generation=12
csi-cephfsplugin-pbf5n 3/3 Running 0 7d12h app=csi-cephfsplugin,controller-revision-hash=758476fc67,pod-template-generation=12
csi-cephfsplugin-provisioner-6f7ffd894d-9jt8c 6/6 Running 0 7d12h app=csi-cephfsplugin-provisioner,pod-template-hash=6f7ffd894d
csi-cephfsplugin-provisioner-6f7ffd894d-q74x2 6/6 Running 0 7d12h app=csi-cephfsplugin-provisioner,pod-template-hash=6f7ffd894d
csi-cephfsplugin-provisioner-6f7ffd894d-vn8m7 6/6 Running 0 7d12h app=csi-cephfsplugin-provisioner,pod-template-hash=6f7ffd894d
csi-cephfsplugin-sqkz6 3/3 Running 0 7d12h app=csi-cephfsplugin,controller-revision-hash=758476fc67,pod-template-generation=12
csi-rbdplugin-2qf4v 3/3 Running 0 7d12h app=csi-rbdplugin,controller-revision-hash=79c748c46c,pod-template-generation=12
csi-rbdplugin-5f8ng 3/3 Running 0 7d12h app=csi-rbdplugin,controller-revision-hash=79c748c46c,pod-template-generation=12
csi-rbdplugin-6b9l2 3/3 Running 0 7d12h app=csi-rbdplugin,controller-revision-hash=79c748c46c,pod-template-generation=12
csi-rbdplugin-6whd8 3/3 Running 0 7d12h app=csi-rbdplugin,controller-revision-hash=79c748c46c,pod-template-generation=12
csi-rbdplugin-p67v7 3/3 Running 0 7d12h app=csi-rbdplugin,controller-revision-hash=79c748c46c,pod-template-generation=12
csi-rbdplugin-provisioner-7dffff7f4d-47bsb 7/7 Running 0 7d12h app=csi-rbdplugin-provisioner,pod-template-hash=7dffff7f4d
csi-rbdplugin-provisioner-7dffff7f4d-mdzfv 7/7 Running 0 7d12h app=csi-rbdplugin-provisioner,pod-template-hash=7dffff7f4d
csi-rbdplugin-provisioner-7dffff7f4d-zh76c 7/7 Running 0 7d12h app=csi-rbdplugin-provisioner,pod-template-hash=7dffff7f4d
< many other pods >
我想用包含关键字csi的标签过滤豆荚,
kubectl get pods -l 'app in (csi)'
但要犯错误
error: name cannot be provided when a selector is specified
知道吗?
发布于 2022-10-25 19:33:21
您可以使用awk来匹配荚名。
kubectl get pods --no-headers --show-labels | awk '{if ($NF ~ ".*app=csi.*") print $0}'
$NF是一个变量,表示文件/流中的最后一列。
https://stackoverflow.com/questions/74196783
复制相似问题