From c47b53648b169245c267dee0463bcd94e26d2bb2 Mon Sep 17 00:00:00 2001 From: helen Date: Wed, 14 Dec 2022 01:16:02 +0800 Subject: [PATCH] Karmadactl join: default use current context Signed-off-by: helen --- hack/local-up-karmada.sh | 4 ++-- pkg/karmadactl/join/join.go | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/hack/local-up-karmada.sh b/hack/local-up-karmada.sh index 407ef3e17..73ef9ec62 100755 --- a/hack/local-up-karmada.sh +++ b/hack/local-up-karmada.sh @@ -128,9 +128,9 @@ echo "cluster networks connected" #join push mode member clusters export KUBECONFIG="${MAIN_KUBECONFIG}" -${KARMADACTL_BIN} join --karmada-context="${KARMADA_APISERVER_CLUSTER_NAME}" ${MEMBER_CLUSTER_1_NAME} --cluster-kubeconfig="${MEMBER_CLUSTER_KUBECONFIG}" +${KARMADACTL_BIN} join --karmada-context="${KARMADA_APISERVER_CLUSTER_NAME}" ${MEMBER_CLUSTER_1_NAME} --cluster-kubeconfig="${MEMBER_CLUSTER_KUBECONFIG}" --cluster-context="${MEMBER_CLUSTER_1_NAME}" "${REPO_ROOT}"/hack/deploy-scheduler-estimator.sh "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}" "${MEMBER_CLUSTER_KUBECONFIG}" "${MEMBER_CLUSTER_1_NAME}" -${KARMADACTL_BIN} join --karmada-context="${KARMADA_APISERVER_CLUSTER_NAME}" ${MEMBER_CLUSTER_2_NAME} --cluster-kubeconfig="${MEMBER_CLUSTER_KUBECONFIG}" +${KARMADACTL_BIN} join --karmada-context="${KARMADA_APISERVER_CLUSTER_NAME}" ${MEMBER_CLUSTER_2_NAME} --cluster-kubeconfig="${MEMBER_CLUSTER_KUBECONFIG}" --cluster-context="${MEMBER_CLUSTER_2_NAME}" "${REPO_ROOT}"/hack/deploy-scheduler-estimator.sh "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}" "${MEMBER_CLUSTER_KUBECONFIG}" "${MEMBER_CLUSTER_2_NAME}" # wait until the pull mode cluster ready diff --git a/pkg/karmadactl/join/join.go b/pkg/karmadactl/join/join.go index c759c0b7d..d7f873ae3 100644 --- a/pkg/karmadactl/join/join.go +++ b/pkg/karmadactl/join/join.go @@ -98,11 +98,6 @@ func (j *CommandJoinOption) Complete(args []string) error { j.ClusterName = args[0] } - // If '--cluster-context' not specified, take the cluster name as the context. - if len(j.ClusterContext) == 0 { - j.ClusterContext = j.ClusterName - } - return nil } @@ -127,9 +122,8 @@ func (j *CommandJoinOption) Validate(args []string) error { // AddFlags adds flags to the specified FlagSet. func (j *CommandJoinOption) AddFlags(flags *pflag.FlagSet) { flags.StringVar(&j.ClusterNamespace, "cluster-namespace", options.DefaultKarmadaClusterNamespace, "Namespace in the control plane where member cluster secrets are stored.") - flags.StringVar(&j.ClusterContext, "cluster-context", "", - "Context name of cluster in kubeconfig. Only works when there are multiple contexts in the kubeconfig.") + "Name of cluster context in kubeconfig. The current context is used by default.") flags.StringVar(&j.ClusterKubeConfig, "cluster-kubeconfig", "", "Path of the cluster's kubeconfig.") flags.StringVar(&j.ClusterProvider, "cluster-provider", "", "Provider of the joining cluster. The Karmada scheduler can use this information to spread workloads across providers for higher availability.")