apiVersion: policy.open-cluster-management.io/v1
kind: Policy
metadata:
  name: cluster-disable-autoimport
  namespace: default
spec:
  remediationAction: enforce
  disabled: false
  policy-templates:
    - objectDefinition:
        apiVersion: policy.open-cluster-management.io/v1
        kind: ConfigurationPolicy
        metadata:
          name: disable-auto-import
        spec:
          object-templates-raw: |
            {{- range (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "").items }}
            - complianceType: musthave
              objectDefinition:
                kind: ManagedCluster
                apiVersion: cluster.open-cluster-management.io/v1
                metadata:
                  name: {{ .metadata.name }}
                  annotations:
                    import.open-cluster-management.io/disable-auto-import: ""
            {{- end }}
          pruneObjectBehavior: None
          remediationAction: enforce
          severity: low
---
apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSetBinding
metadata:
  name: global
  namespace: default
spec:
  clusterSet: global
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
metadata:
  name: cluster-disable-autoimport
placementRef:
  name: cluster-disable-autoimport
  kind: Placement
  apiGroup: cluster.open-cluster-management.io
subjects:
- name: cluster-disable-autoimport
  kind: Policy
  apiGroup: policy.open-cluster-management.io
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
  name: cluster-disable-autoimport
  namespace: default
spec:
  numberOfClusters: 1
  predicates:
    - requiredClusterSelector:
        labelSelector:
          matchLabels:
            local-cluster: "true"