Hello Everyone,
I am writing a multi-cluster application and exploring the use of KCP in that context.
Specifically, I would like to understand whether KCP can support the following behavior.
- I have 2 workspaces where workspace workspace-1 maps to workload cluster cluster-1 and workspace workspace-2 maps to workload cluster cluster-2.
- cluster-1 has k8s operator operator-1 that acts on an input custom resource CR-1 of type CRD-1 and generates a custom resource CR-2 of type CRD-2.
- Cluster-2 has a k8s operator operator-2 that in turn acts on CR-2 of type CRD-2.
I want to know if there is any way for CR-2 to be shared from workspace-1 (cluster-1) to workspace-2 (cluster-2) via KCP transparent multi-cluster capabilities i.e. is it possible for KCP to be set up such that it can automatically share/sync CR-2 from workspace-1 (cluster-1) to workspace-2 (cluster-2)?
KCP steps envisaged are as follow:
1. Create 2 clusters in kind i.e. cluster-1 and cluster-2
$ kind create cluster -n cluster-1
$ kind create cluster -n cluster-2
$ kubectl config get-clusters
NAME
kind-cluster-1
kind-cluster-2
2. Create 2 workspaces, where workspace-1 maps to cluster-1 and workspace-2 maps to cluster-2
$ kubectl ws ..
$ kubectl config use-context kind-cluster-1
$ kubectl ws create workspace-1
$ kubectl ws use workspace-1
$ kubectl kcp workload sync cluster-1 --syncer-image ghcr.io/kcp-dev/kcp/syncer:v0.10.0 -o cluster-1.yaml
$ KUBECONFIG=.kube/config kubectl apply -f cluster-1.yaml
$ kubectl ws ..
$ kubectl config use-context kind-cluster-2
$ kubectl ws create workspace-2
$ kubectl ws use workspace-2
$ kubectl kcp workload sync cluster-2 --syncer-image ghcr.io/kcp-dev/kcp/syncer:v0.10.0 -o cluster-2.yaml
$ KUBECONFIG=.kube/config kubectl apply -f cluster-2.yaml
3. Deploy k8s operators operator-1 in cluster-1 and operator-2 in cluster-2
On cluster-1
$ kubectl create -f deploy/operator-1.yaml
On cluster-2
$ kubectl create -f deploy/operator-2.yaml
4. KCP applies CR-1 in the cluster-1 (mapping to workspace-1), which triggers the business logic of operator-1 running in the cluster-1 to generate a new CR CR-2 on the cluster-1, which is getting synced back to the KCP in workspace-1 (we can check this by using kubectl get at the KCP host)
$ kubectl get CR-2
NAME AGE
CR-2 45s
Is there any way to enable KCP to automatically deploy the CR object CR-2 on the workspace-2 (Cluster-2)?
Thank you very much in advance.
Regards,
Pankaj Thorat