未找到匹配的工作负载

当授权策略的选择器与任何 Pod 不匹配时,会发生此消息。

示例

您将收到此消息

Warning [IST0127] (AuthorizationPolicy httpbin-nopods.httpbin) No matching workloads for this resource with the following labels: app=bogus-label,version=v1

当您的集群具有以下授权策略时

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: httpbin-nopods
  namespace: httpbin
spec:
  selector:
    matchLabels:
      app: bogus-label # Bogus label. No matching workloads
      version: v1
  rules:
    - from:
        - source:
            principals: ["cluster.local/ns/default/sa/curl"]
        - source:
            namespaces: ["httpbin"]
      to:
        - operation:
            methods: ["GET"]
            paths: ["/info*"]
        - operation:
            methods: ["POST"]
            paths: ["/data"]
      when:
        - key: request.auth.claims[iss]
          values: ["https://127.0.0.1"]

在此示例中,授权策略 httpbin-nopods 选择具有标签 app=bogus-label 的 Pod,并且不存在任何这样的 Pod。

如何解决

  • 将选择器更改为匹配您拥有的 Pod
  • 标记 Pod 以匹配选择器