With Placement
, you can select a set of ManagedClusters
from the ManagedClusterSets
bound to the placement namespace.
Check the CONTRIBUTING Doc for how to contribute to the repo.
You have at least one running kubernetes cluster;
git clone https://github.com/open-cluster-management-io/placement.git
cd placement
Set environment variables.
export KUBECONFIG=</path/to/kubeconfig>
Build the docker image to run the placement controller.
go install github.com/openshift/imagebuilder/cmd/[email protected]
make images
export IMAGE_NAME=<placement_image_name> # export IMAGE_NAME=quay.io/open-cluster-management/placement:latest
If your are using kind, load image into the kind cluster.
kind load docker-image <placement_image_name> # kind load docker-image quay.io/open-cluster-management/placement:latest
And then deploy placement manager on the cluster.
make deploy-hub
After a successful deployment, check on the cluster and see the placement controller has been deployed.
kubectl -n open-cluster-management-hub get pods
NAME READY STATUS RESTARTS AGE
cluster-manager-placement-controller-cf9bbd6c-x9dnd 1/1 Running 0 2m16s
Here is an example.
Create a ManagedClusterSet
.
cat <<EOF | kubectl apply -f -
apiVersion: cluster.open-cluster-management.io/v1alpha1
kind: ManagedClusterSet
metadata:
name: clusterset1
EOF
Create a ManagedCluster
and assign it to clusterset clusterset1
.
cat <<EOF | kubectl apply -f -
apiVersion: cluster.open-cluster-management.io/v1
kind: ManagedCluster
metadata:
name: cluster1
labels:
cluster.open-cluster-management.io/clusterset: clusterset1
vendor: OpenShift
spec:
hubAcceptsClient: true
EOF
Create a ManagedClusterSetBinding
to bind the ManagedClusterSet
to the default namespace.
cat <<EOF | kubectl apply -f -
apiVersion: cluster.open-cluster-management.io/v1alpha1
kind: ManagedClusterSetBinding
metadata:
name: clusterset1
namespace: default
spec:
clusterSet: clusterset1
EOF
Now create a Placement
:
cat <<EOF | kubectl apply -f -
apiVersion: cluster.open-cluster-management.io/v1alpha1
kind: Placement
metadata:
name: placement1
namespace: default
spec:
predicates:
- requiredClusterSelector:
labelSelector:
matchLabels:
vendor: OpenShift
EOF
Check the PlacementDecision
created for this placement. It contains all selected clusters in status.
kubectl get placementdecisions
NAME AGE
placement1-decision-1 2m27s
kubectl describe placementdecisions placement1-decision-1
......
Status:
Decisions:
Cluster Name: cluster1
Reason:
Events: <none>
Undeploy placement controller from the cluster.
make undeploy-hub