diff --git a/README.md b/README.md index 14392689..f39b5088 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,68 @@ For additional information about the Policy Generator: - [Policy Generator reference YAML](https://github.com/stolostron/policy-generator-plugin/blob/main/docs/policygenerator-reference.yaml) - [Policy Generator examples](policygenerator) +## Transition from PlacementRule to Placement +### Prerequisite +- [ManagedClusterSet](https://open-cluster-management.io/concepts/managedclusterset/) and [ManagedClusterSetBinding](https://open-cluster-management.io/concepts/managedclusterset) +- `Policy`(The `namespace` in the `policy` should be bound to `ManagedClusterSetBinding`) +- `PlacementBinding` and `PlacementRule` +```yaml +apiVersion: policy.open-cluster-management.io/v1 +kind: PlacementBinding +metadata: + name: binding-policy-comp-operator +placementRef: + name: placement-policy-comp-operator + kind: PlacementRule + apiGroup: apps.open-cluster-management.io +subjects: + - name: policy-comp-operator + kind: Policy + apiGroup: policy.open-cluster-management.io +--- +apiVersion: apps.open-cluster-management.io/v1 +kind: PlacementRule +metadata: + name: placement-policy-comp-operator +spec: + clusterSelector: + matchExpressions: + - {key: vendor, operator: In, values: ["OpenShift"]} +``` + +## Convert PlacementRule to Placement +Create the `Placement` manifest as shown below. This `Placement` manifest replaces the `PlacementRule`. Ensure that the `namespace` specified (`comp-operator-ns`) matches the `namespace` used in `ManagedClusterSetBinding`. Copy `matchExpressions` from the `PlacementRule` and paste them into `spec.predicates.requiredClusterSelector.labelSelector`. Update the `PlacementBinding` to reference the new `Placement`. Change the `placementRef.kind` to `Placement` and update the `placementRef.apiGroup` to `cluster.open-cluster-management.io` to reflect the `Placement`'s API version. +```yaml +apiVersion: cluster.open-cluster-management.io/v1beta1 +kind: Placement +metadata: + name: placement-policy-comp-operator + namespace: comp-operator-ns // Please ensure that this namespace matches one in ManagedClusterSetBinding +spec: + predicates: + - requiredClusterSelector: + labelSelector: + matchExpressions: // From PlacementRule + - {key: vendor, operator: In, values: ["OpenShift"]} +--- +apiVersion: policy.open-cluster-management.io/v1 +kind: PlacementBinding +metadata: + name: binding-policy-comp-operator +placementRef: + name: placement-policy-comp-operator + kind: Placement // Set here to Placement + apiGroup: cluster.open-cluster-management.io // Set cluster.open-cluster-management.io +subjects: + - name: policy-comp-operator + kind: Policy + apiGroup: policy.open-cluster-management.io +``` + +For more details on Placement, refer to the [Placement concept](https://open-cluster-management.io/concepts/placement/) documentation. + +This explanation provides a clear transition from using `PlacementRule` to `Placement`, ensuring compatibility and proper configuration alignment with Open Cluster Management principles. + ## Community, discussion, contribution, and support Check the [Contributing policies](CONTRIBUTING.md) document for guidelines on how to contribute to @@ -111,3 +173,5 @@ are implemented in the product governance framework. - [Open Cluster Management Quick Start](https://https://open-cluster-management.io/getting-started/quick-start/) + +