Skip to content

Commit

Permalink
Merge pull request #3320 from ikaven1024/context-name
Browse files Browse the repository at this point in the history
correct context name.
  • Loading branch information
karmada-bot authored Mar 23, 2023
2 parents 861bc7a + e550999 commit a902d8a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hack/create-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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}"

0 comments on commit a902d8a

Please sign in to comment.