set config with a cluster name which contains 'kind' prefix. (#38)

This commit is contained in:
Hongcai Ren 2020-11-27 10:04:08 +08:00 committed by GitHub
parent b6d49901d5
commit 520b8d3397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -26,7 +26,7 @@ if [[ -z "${KUBECONFIG}" ]]; then
exit 1
fi
# TODO(RainbowMango): pin kind version and install automatically.
# TODO(RainbowMango): pin kind version(v0.9.0) and install automatically.
kind create cluster --name "${CLUSTER_NAME}" --kubeconfig="${KUBECONFIG}" --wait=120s
# Kind cluster's context name contains a "kind-" prefix by default.
@ -36,4 +36,4 @@ kubectl config rename-context "kind-${CLUSTER_NAME}" "${CLUSTER_NAME}" --kubecon
# Kind cluster uses `127.0.0.1` as kube-apiserver endpoint by default, thus kind clusters can't reach each other.
# So we need to update endpoint with container IP.
container_ip=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "${CLUSTER_NAME}-control-plane")
kubectl config set-cluster "${CLUSTER_NAME}" --server="https://${container_ip}:6443" --kubeconfig="${KUBECONFIG}"
kubectl config set-cluster "kind-${CLUSTER_NAME}" --server="https://${container_ip}:6443" --kubeconfig="${KUBECONFIG}"