2021-07-20 18:44:14 +08:00
2021-07-20 18:44:14 +08:00
2021-06-22 14:15:31 +08:00
2021-07-27 11:05:48 +08:00
2021-06-22 14:15:31 +08:00
2021-07-27 11:05:48 +08:00
2021-06-22 14:15:31 +08:00
2021-06-22 14:15:31 +08:00
2021-06-25 18:07:06 +08:00
2021-04-23 17:21:06 +08:00
2021-07-26 14:19:46 +08:00
2021-06-22 14:15:31 +08:00
2021-06-22 14:15:31 +08:00
2021-04-22 16:40:47 +08:00
2021-06-25 18:07:06 +08:00
2021-04-23 17:21:06 +08:00
2021-06-22 14:15:31 +08:00

Placement

With Placement, you can select a set of ManagedClusters from the ManagedClusterSets bound to the placement namespace.

Community, discussion, contribution, and support

Check the CONTRIBUTING Doc for how to contribute to the repo.


Getting Started

Prerequisites

You have at least one running kubernetes cluster;

Clone this repo

git clone https://github.com/open-cluster-management-io/placement.git
cd placement

Deploy the placement controller

Set environment variables.

export KUBECONFIG=</path/to/kubeconfig>

Build the docker image to run the placement controller.

go install github.com/openshift/imagebuilder/cmd/imagebuilder@v1.2.1
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 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 cluster

make deploy-hub

What is next

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   14s

Clean up

Undeploy placement controller from the cluster.

make undeploy-hub
Description
Core components in the OCM project. Report here if you found any issues in OCM.
Readme Apache-2.0 131 MiB
Languages
Go 98.8%
Makefile 0.5%
Shell 0.5%
Python 0.1%