NoMatchingWorkloadsFound

當授權原則的選取器不符合任何 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://#"]

在此範例中,授權原則 httpbin-nopods 會選取具有標籤 app=bogus-label 的 Pod,而這些 Pod 不存在。

如何解決

  • 變更選取器以符合您擁有的 Pod
  • 標記 Pod 以符合選取器