Skip to content

Commit

Permalink
Merge pull request kubernetes#5014 from justinsb/aws_cluster_push
Browse files Browse the repository at this point in the history
Copy download-or-bust helper from gce to aws
  • Loading branch information
roberthbailey committed Mar 5, 2015
2 parents e4bdfd0 + 05d4aea commit 83c3c53
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 3 deletions.
29 changes: 29 additions & 0 deletions cluster/aws/templates/common.sh
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 2 additions & 2 deletions cluster/aws/templates/download-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions cluster/aws/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/gce/templates/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 83c3c53

Please sign in to comment.