From 05d4aea3bf77616bcd24546756288139e12c7dd5 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Tue, 3 Mar 2015 23:18:29 -0500 Subject: [PATCH] Copy download-or-bust helper from gce to aws During a push, we were wget-ing to .1, .2, etc, which wasn't working --- cluster/aws/templates/common.sh | 29 ++++++++++++++++++++ cluster/aws/templates/download-release.sh | 4 +-- cluster/aws/util.sh | 32 +++++++++++++++++++++++ cluster/gce/templates/common.sh | 2 +- 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 cluster/aws/templates/common.sh diff --git a/cluster/aws/templates/common.sh b/cluster/aws/templates/common.sh new file mode 100644 index 00000000000..b26a240eb94 --- /dev/null +++ b/cluster/aws/templates/common.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright 2015 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Retry a download until we get it. +# +# $1 is the URL to download +download-or-bust() { + local -r url="$1" + local -r file="${url##*/}" + rm -f "$file" + until [[ -e "${1##*/}" ]]; do + echo "Downloading file ($1)" + curl --ipv4 -Lo "$file" --connect-timeout 20 --retry 6 --retry-delay 10 "$1" + md5sum "$file" + done +} diff --git a/cluster/aws/templates/download-release.sh b/cluster/aws/templates/download-release.sh index 9859a03f29c..553905c3935 100644 --- a/cluster/aws/templates/download-release.sh +++ b/cluster/aws/templates/download-release.sh @@ -21,10 +21,10 @@ # master and run. echo "Downloading binary release tar ($SERVER_BINARY_TAR_URL)" -wget "$SERVER_BINARY_TAR_URL" +download-or-bust "$SERVER_BINARY_TAR_URL" echo "Downloading binary release tar ($SALT_TAR_URL)" -wget "$SALT_TAR_URL" +download-or-bust "$SALT_TAR_URL" echo "Unpacking Salt tree" rm -rf kubernetes diff --git a/cluster/aws/util.sh b/cluster/aws/util.sh index 247d31ba81f..69425e063c8 100644 --- a/cluster/aws/util.sh +++ b/cluster/aws/util.sh @@ -314,6 +314,7 @@ function kube-up { echo "readonly DNS_REPLICAS='${DNS_REPLICAS:-}'" echo "readonly DNS_SERVER_IP='${DNS_SERVER_IP:-}'" echo "readonly DNS_DOMAIN='${DNS_DOMAIN:-}'" + grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/common.sh" grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/create-dynamic-salt-files.sh" grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/download-release.sh" grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/salt-master.sh" @@ -601,6 +602,37 @@ function kube-down { fi } +# Update a kubernetes cluster with latest source +function kube-push { + detect-master + + # Make sure we have the tar files staged on Google Storage + find-release-tars + upload-server-tars + + ( + echo "#! /bin/bash" + echo "mkdir -p /var/cache/kubernetes-install" + echo "cd /var/cache/kubernetes-install" + echo "readonly SERVER_BINARY_TAR_URL='https://s3-${ZONE}.amazonaws.com/${SERVER_BINARY_TAR_URL}'" + echo "readonly SALT_TAR_URL='https://s3-${ZONE}.amazonaws.com/${SALT_TAR_URL}'" + grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/common.sh" + grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/download-release.sh" + echo "echo Executing configuration" + echo "sudo salt '*' mine.update" + echo "sudo salt --force-color '*' state.highstate" + ) | ssh -oStrictHostKeyChecking=no -i ${AWS_SSH_KEY} ubuntu@${KUBE_MASTER_IP} sudo bash + + get-password + + echo + echo "Kubernetes cluster is running. The master is running at:" + echo + echo " https://${KUBE_MASTER_IP}" + echo + +} + function setup-logging-firewall { echo "TODO: setup logging" } diff --git a/cluster/gce/templates/common.sh b/cluster/gce/templates/common.sh index 43fab604343..c2b0dde76eb 100644 --- a/cluster/gce/templates/common.sh +++ b/cluster/gce/templates/common.sh @@ -22,7 +22,7 @@ download-or-bust() { local -r file="${url##*/}" rm -f "$file" until [[ -e "${1##*/}" ]]; do - echo "Downloading file ($SERVER_BINARY_TAR_URL)" + echo "Downloading file ($1)" curl --ipv4 -Lo "$file" --connect-timeout 20 --retry 6 --retry-delay 10 "$1" md5sum "$file" done