open-cluster-management-io / policy-generator-plugin

A Kustomize generator plugin to generate Open Cluster Management policies
Apache License 2.0
29 stars 31 forks source link

Error when using matchExpressions on clusterSelector PolicyGenerator/PolicySets #90

Closed pazpuwi closed 1 year ago

pazpuwi commented 1 year ago

If you use clusterSelectors as mentioned in the policy-generator-plugin/docs/policygenerator-reference.yaml an Error occurs.

E0116 10:11:28.062063 1 git_subscriber_item.go:155] failed to prepare resources to apply and there is no resource to apply. err: failure in plugin configured via /tmp/kust-plugin-config-471838647; exit status 1: exit status 1Subscription error.

Solution for us was to use clusterSelector insted of clusterSelectors

Example PolicySet:

apiVersion: policy.open-cluster-management.io/v1
kind: PolicyGenerator
metadata:
  name: policy-generator
policySets:
- name: test
    placement:
      clusterSelector:
        matchExpressions:
          - key: foo
            operator: In
            values:
              - bar
dhaiducek commented 1 year ago

@pazpuwi Thanks for opening an issue! The generator doesn't currently support providing matchExpressions directly. Currently the workaround for this is to write a Placement or PlacementRule manifest and supply the path to it in placementPath or placementRulePath. clusterSelectors and labelSelectors both currently only support providing key: value pairs, but we have an open item to enable providing matchExpressions directly as your example: https://issues.redhat.com/browse/ACM-2694

Please let me know if this addresses your issue.

pazpuwi commented 1 year ago

@dhaiducek Thanks a lot for the fast answer. That Information helps a lot. The support for matchExpressions would be great.