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}"