From b31b633f85b06e4a661dc7fa16d5c4f3d9d62123 Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Tue, 10 Mar 2015 08:59:19 -0700 Subject: [PATCH] One additional cleanup: Send only the master name, rather the internal IP address. The configure-vm script can resolve this relatively easily on the node. This is less painful for GKE, which creates all the resources in parallel. --- cluster/gce/configure-vm.sh | 10 ++++++++-- cluster/gce/util.sh | 8 +++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cluster/gce/configure-vm.sh b/cluster/gce/configure-vm.sh index 47a1140b31..18e51c53ed 100644 --- a/cluster/gce/configure-vm.sh +++ b/cluster/gce/configure-vm.sh @@ -302,9 +302,15 @@ EOF } function salt-set-apiserver() { + local kube_master_ip + until kube_master_ip=$(getent hosts ${KUBERNETES_MASTER_NAME} | cut -f1 -d\ ); do + echo 'Waiting for DNS resolution of ${KUBERNETES_MASTER_NAME}...' + sleep 3 + done + cat <>/etc/salt/minion.d/grains.conf - api_servers: '${KUBERNETES_MASTER_IP}' - apiservers: '${KUBERNETES_MASTER_IP}' + api_servers: '${kube_master_ip}' + apiservers: '${kube_master_ip}' EOF } diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index d29364e1d6..77f668be46 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -216,9 +216,6 @@ function detect-master () { KUBE_MASTER_IP=$(gcloud compute instances describe --project "${PROJECT}" --zone "${ZONE}" \ "${MASTER_NAME}" --fields networkInterfaces[0].accessConfigs[0].natIP \ --format=text | awk '{ print $2 }') - KUBE_MASTER_IP_INTERNAL=$(gcloud compute instances describe --project "${PROJECT}" --zone "${ZONE}" \ - "${MASTER_NAME}" --fields networkInterfaces[0].networkIP \ - --format=text | awk '{ print $2 }') fi if [[ -z "${KUBE_MASTER_IP-}" ]]; then echo "Could not detect Kubernetes master node. Make sure you've launched a cluster with 'kube-up.sh'" >&2 @@ -455,7 +452,7 @@ function build-kube-env { add-to-env ${file} DNS_DOMAIN "${DNS_DOMAIN:-}" add-to-env ${file} MASTER_HTPASSWD "${MASTER_HTPASSWD}" if [[ "${master}" != "true" ]]; then - add-to-env ${file} KUBERNETES_MASTER_IP "${KUBE_MASTER_IP_INTERNAL}" + add-to-env ${file} KUBERNETES_MASTER_NAME "${MASTER_NAME}" add-to-env ${file} ZONE "${ZONE}" add-to-env ${file} EXTRA_DOCKER_OPTS "${EXTRA_DOCKER_OPTS}" add-to-env ${file} ENABLE_DOCKER_REGISTRY_CACHE "${ENABLE_DOCKER_REGISTRY_CACHE:-false}" @@ -558,7 +555,6 @@ function kube-up { # Wait for last batch of jobs wait-for-jobs - detect-master # We need the KUBE_MASTER_IP_INTERNAL for the node startup script add-instance-metadata "${MASTER_NAME}" "kube-token=${KUBELET_TOKEN}" echo "Creating minions." @@ -614,6 +610,8 @@ function kube-up { # Wait for last batch of jobs. wait-for-jobs + detect-master + # Reserve the master's IP so that it can later be transferred to another VM # without disrupting the kubelets. IPs are associated with regions, not zones, # so extract the region name, which is the same as the zone but with the final