我如何在 or 条件下使用 kubectl 标签选择器?
How can i use kubectl labelselector with or contidion?
我想获取带标签的 pod
app=vovo
组件=db
当我得到一个带有标签 app=vovo 和 component=db 的 pod 时,我可以用下面的命令得到结果。
kubectl get pod -l app=vovo,component=db
但是,当我想得到结果时
app=vovo 或 component=db
如何使用一个 kubectl 命令获得结果?
根据 documentation,不支持 OR
标签选择操作
Caution: For both equality-based and set-based conditions there is no
logical OR (||) operator. Ensure your filter statements are structured
accordingly
这是一个结束 hack 你可以做的:
kubectl get pod -l app=volvo && kubectl get pod -l component=db --no-headers
这将 运行 两个 kubectl
查询两个不同的标签。
我想获取带标签的 pod
app=vovo 组件=db
当我得到一个带有标签 app=vovo 和 component=db 的 pod 时,我可以用下面的命令得到结果。
kubectl get pod -l app=vovo,component=db
但是,当我想得到结果时
app=vovo 或 component=db
如何使用一个 kubectl 命令获得结果?
OR
标签选择操作
Caution: For both equality-based and set-based conditions there is no logical OR (||) operator. Ensure your filter statements are structured accordingly
这是一个结束 hack 你可以做的:
kubectl get pod -l app=volvo && kubectl get pod -l component=db --no-headers
这将 运行 两个 kubectl
查询两个不同的标签。