From eca1fb627b3d81e2020ea84a838083d27faf9e50 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Sat, 9 May 2026 10:16:45 +0900 Subject: [PATCH] Register hub as local-cluster in local-up (#1515) Signed-off-by: kahirokunn --- solutions/setup-dev-environment/README.md | 15 ++++++++------- solutions/setup-dev-environment/local-up.sh | 13 ++++++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/solutions/setup-dev-environment/README.md b/solutions/setup-dev-environment/README.md index 6efa7c6f5..f6d756bdf 100644 --- a/solutions/setup-dev-environment/README.md +++ b/solutions/setup-dev-environment/README.md @@ -1,6 +1,6 @@ # Setup dev environment by kind -This scripts is to setup an OCM developer environment in your local machine with 3 kind clusters. The script will bootstrap 3 kind clusters on your local machine: hub, cluster1, and cluster2. The hub is used as the control plane of the OCM, and the other two clusters are registered on the hub as the managed clusters. +This script sets up an OCM developer environment on your local machine with three kind clusters: hub, cluster1, and cluster2. The hub is used as the control plane of the OCM and is also registered as a managed cluster named local-cluster. The other two clusters are registered on the hub as managed clusters. ## Prerequisite @@ -16,12 +16,13 @@ sudo chmod +x /usr/local/bin/clusteradm ## Setup the clusters -Run `./local-up.sh`, you will see two clusters registered on the hub cluster. +Run `./local-up.sh`, you will see three clusters registered on the hub cluster. -``` -NAME HUB ACCEPTED MANAGED CLUSTER URLS JOINED AVAILABLE AGE -cluster1 true https://127.0.0.1:45325 True True 116s -cluster2 true https://127.0.0.1:45325 True True 98s +```text +NAME HUB ACCEPTED MANAGED CLUSTER URLS JOINED AVAILABLE AGE +cluster1 true https://127.0.0.1:45325 True True 116s +cluster2 true https://127.0.0.1:45325 True True 98s +local-cluster true https://127.0.0.1:45325 True True 78s ```
@@ -61,4 +62,4 @@ $ ./local-up.sh ``` -
\ No newline at end of file + diff --git a/solutions/setup-dev-environment/local-up.sh b/solutions/setup-dev-environment/local-up.sh index dbb18cba3..c14418e97 100755 --- a/solutions/setup-dev-environment/local-up.sh +++ b/solutions/setup-dev-environment/local-up.sh @@ -4,9 +4,10 @@ cd $(dirname ${BASH_SOURCE}) set -e -hub=${CLUSTER1:-hub} +hub=${HUB:-hub} c1=${CLUSTER1:-cluster1} c2=${CLUSTER2:-cluster2} +local_cluster=local-cluster hubctx="kind-${hub}" c1ctx="kind-${c1}" @@ -26,7 +27,13 @@ $(echo ${joincmd} --force-internal-endpoint-lookup --wait --context ${c1ctx} | s echo -e "Join cluster2 to hub\n" $(echo ${joincmd} --force-internal-endpoint-lookup --wait --context ${c2ctx} | sed "s//$c2/g") -echo -e "Accept join of cluster1 and cluster2\n" -clusteradm accept --context ${hubctx} --clusters ${c1},${c2} --wait +echo -e "Join hub to itself as ${local_cluster}\n" +$(echo ${joincmd} --force-internal-endpoint-lookup --wait --context ${hubctx} | sed "s//${local_cluster}/g") + +managed_clusters="${c1},${c2},${local_cluster}" +echo -e "Accept join of ${managed_clusters}\n" +clusteradm accept --context ${hubctx} --clusters ${managed_clusters} --wait + +kubectl label managedcluster "${local_cluster}" local-cluster=true --overwrite --context ${hubctx} kubectl get managedclusters --all-namespaces --context ${hubctx}