[英]how to filter pods against multiple label selectors with terratest?
I have a code that uses k8s
module of terratest
to list pods based on label selector.我有一个代码,它使用
k8s
的terratest
模块根据标签选择器列出 pod。
pods, err := k8s.ListPodsE(
t,
k8soptions,
filter,
)
where the filter is initialized with a string labelSelector like this,其中过滤器是用这样的字符串 labelSelector 初始化的,
filter := metav1.ListOptions{
LabelSelector: "kubeslice.io/app=foo",
}
So if I want to filter pods against more than one labels, say pods which has both kubeslice.io/pod-type=gateway
& kubeslice.io/app=foo
, how can I achieve that in this method ?因此,如果我想针对多个标签过滤 pod,比如同时具有
kubeslice.io/pod-type=gateway
和kubeslice.io/app=foo
的 pod,我该如何在这种方法中实现呢?
As pointed out by doublethink and I tested, we could provide a comma separated string of label selectors like this.正如doublethink所指出的,我测试过,我们可以像这样提供一个逗号分隔的标签选择器字符串。
filter := metav1.ListOptions{
LabelSelector: "kubeslice.io/app=foo,kubeslice.io/app=bar",
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.