diff --git a/cluster/gce/debian/helper.sh b/cluster/gce/debian/helper.sh index e24a1b0900c..ad1ac797b1c 100755 --- a/cluster/gce/debian/helper.sh +++ b/cluster/gce/debian/helper.sh @@ -39,6 +39,7 @@ function create-master-instance { fi write-master-env + prepare-startup-script gcloud compute instances create "${MASTER_NAME}" \ ${address_opt} \ --project "${PROJECT}" \ @@ -51,7 +52,7 @@ function create-master-instance { --scopes "storage-ro,compute-rw,monitoring,logging-write" \ --can-ip-forward \ --metadata-from-file \ - "startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh,kube-env=${KUBE_TEMP}/master-kube-env.yaml,cluster-name=${KUBE_TEMP}/cluster-name.txt" \ + "startup-script=${KUBE_TEMP}/configure-vm.sh,kube-env=${KUBE_TEMP}/master-kube-env.yaml,cluster-name=${KUBE_TEMP}/cluster-name.txt" \ --disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no" \ ${preemptible_master} } @@ -59,8 +60,9 @@ function create-master-instance { # $1: template name (required) function create-node-instance-template { local template_name="$1" + prepare-startup-script create-node-template "$template_name" "${scope_flags}" \ - "startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh" \ + "startup-script=${KUBE_TEMP}/configure-vm.sh" \ "kube-env=${KUBE_TEMP}/node-kube-env.yaml" \ "cluster-name=${KUBE_TEMP}/cluster-name.txt" } diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index bdd22b1c696..ab43491bd7e 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -1185,10 +1185,11 @@ function prepare-push() { function push-master { echo "Updating master metadata ..." write-master-env - add-instance-metadata-from-file "${KUBE_MASTER}" "kube-env=${KUBE_TEMP}/master-kube-env.yaml" "startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh" + prepare-startup-script + add-instance-metadata-from-file "${KUBE_MASTER}" "kube-env=${KUBE_TEMP}/master-kube-env.yaml" "startup-script=${KUBE_TEMP}/configure-vm.sh" echo "Pushing to master (log at ${OUTPUT}/push-${KUBE_MASTER}.log) ..." - cat ${KUBE_ROOT}/cluster/gce/configure-vm.sh | gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --project "${PROJECT}" --zone "${ZONE}" "${KUBE_MASTER}" --command "sudo bash -s -- --push" &> ${OUTPUT}/push-"${KUBE_MASTER}".log + cat ${KUBE_TEMP}/configure-vm.sh | gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --project "${PROJECT}" --zone "${ZONE}" "${KUBE_MASTER}" --command "sudo bash -s -- --push" &> ${OUTPUT}/push-"${KUBE_MASTER}".log } # Push binaries to kubernetes node @@ -1196,10 +1197,11 @@ function push-node() { node=${1} echo "Updating node ${node} metadata... " - add-instance-metadata-from-file "${node}" "kube-env=${KUBE_TEMP}/node-kube-env.yaml" "startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh" + prepare-startup-script + add-instance-metadata-from-file "${node}" "kube-env=${KUBE_TEMP}/node-kube-env.yaml" "startup-script=${KUBE_TEMP}/configure-vm.sh" echo "Start upgrading node ${node} (log at ${OUTPUT}/push-${node}.log) ..." - cat ${KUBE_ROOT}/cluster/gce/configure-vm.sh | gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --project "${PROJECT}" --zone "${ZONE}" "${node}" --command "sudo bash -s -- --push" &> ${OUTPUT}/push-"${node}".log + cat ${KUBE_TEMP}/configure-vm.sh | gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --project "${PROJECT}" --zone "${ZONE}" "${node}" --command "sudo bash -s -- --push" &> ${OUTPUT}/push-"${node}".log } # Push binaries to kubernetes cluster @@ -1354,3 +1356,8 @@ function ssh-to-node { function prepare-e2e() { detect-project } + +# Writes configure-vm.sh to a temporary location with comments stripped. +function prepare-startup-script() { + sed '/^\s*#\([^!].*\)*$/ d' ${KUBE_ROOT}/cluster/gce/configure-vm.sh > ${KUBE_TEMP}/configure-vm.sh +}