From e550999db58f148fa238e9eb63190c722bd5ded0 Mon Sep 17 00:00:00 2001 From: yingjinhui Date: Wed, 22 Mar 2023 17:59:11 +0800 Subject: [PATCH] correct context name. Signed-off-by: yingjinhui --- hack/create-cluster.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hack/create-cluster.sh b/hack/create-cluster.sh index edc32e32c580..b94706cf35e1 100755 --- a/hack/create-cluster.sh +++ b/hack/create-cluster.sh @@ -79,7 +79,13 @@ cp -rf "${REPO_ROOT}"/artifacts/kindClusterConfig/general-config.yaml "${TEMP_PA sed -i'' -e "s#{{pod_cidr}}#${POD_CIDR}#g" "${TEMP_PATH}"/"${CLUSTER_NAME}"-config.yaml sed -i'' -e "s#{{service_cidr}}#${SERVICE_CIDR}#g" "${TEMP_PATH}"/"${CLUSTER_NAME}"-config.yaml -kind create cluster --name "${CLUSTER_NAME}" --kubeconfig="${KUBECONFIG}" --image="${CLUSTER_VERSION}" --config="${TEMP_PATH}"/"${CLUSTER_NAME}"-config.yaml +kind_log="$(mktemp --suffix=-kind.log)" +echo "Creating cluster \"${CLUSTER_NAME}\" ..." +kind create cluster --name "${CLUSTER_NAME}" --kubeconfig="${KUBECONFIG}" --image="${CLUSTER_VERSION}" --config="${TEMP_PATH}"/"${CLUSTER_NAME}"-config.yaml > ${kind_log} 2>&1 || ( + echo "Creating cluster ${CLUSTER_NAME} failed, see detail log in ${kind_log}." + exit 1 +) +rm -rf "${kind_log}" # Kind cluster's context name contains a "kind-" prefix by default. # Change context name to cluster name. @@ -91,3 +97,5 @@ container_ip=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IP kubectl config set-cluster "kind-${CLUSTER_NAME}" --server="https://${container_ip}:6443" --kubeconfig="${KUBECONFIG}" echo "cluster \"${CLUSTER_NAME}\" is created successfully!" +echo "You can now use your cluster with:" +echo kubectl cluster-info --context "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}"