Skip to content

Commit

Permalink
Merge pull request kubernetes#5382 from justinsb/aws_image_by_region
Browse files Browse the repository at this point in the history
Choose AWS image by region
  • Loading branch information
a-robinson committed Mar 12, 2015
2 parents 2939abb + 70b448b commit 55ed70f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 10 deletions.
4 changes: 0 additions & 4 deletions cluster/aws/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ MASTER_SIZE=${MASTER_SIZE:-t2.micro}
MINION_SIZE=${MINION_SIZE:-t2.micro}
NUM_MINIONS=${NUM_MINIONS:-4}

# This is the ubuntu 14.04 image for us-west-2 + ebs
# See here: http://cloud-images.ubuntu.com/locator/ec2/ for other images
# This will need to be updated from time to time as amis are deprecated
IMAGE=ami-39501209
INSTANCE_PREFIX="${KUBE_AWS_INSTANCE_PREFIX:-kubernetes}"
AWS_SSH_KEY=${AWS_SSH_KEY:-$HOME/.ssh/kube_aws_rsa}
IAM_PROFILE="kubernetes"
Expand Down
4 changes: 0 additions & 4 deletions cluster/aws/config-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ MASTER_SIZE=${MASTER_SIZE:-t2.micro}
MINION_SIZE=${MINION_SIZE:-t2.micro}
NUM_MINIONS=${NUM_MINIONS:-2}

# This is the ubuntu 14.04 image for us-west-2 + ebs
# See here: http://cloud-images.ubuntu.com/locator/ec2/ for other images
# This will need to be updated from time to time as amis are deprecated
IMAGE=ami-39501209
INSTANCE_PREFIX="${KUBE_AWS_INSTANCE_PREFIX:-e2e-test-${USER}}"
AWS_SSH_KEY=${AWS_SSH_KEY:-$HOME/.ssh/kube_aws_rsa}
IAM_PROFILE="kubernetes"
Expand Down
67 changes: 65 additions & 2 deletions cluster/aws/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,67 @@ function detect-minions () {
fi
}

# Detects the AMI to use (considering the region)
#
# Vars set:
# AWS_IMAGE
function detect-image () {
# This is the ubuntu 14.04 image for <region>, amd64, hvm:ebs-ssd
# See here: http://cloud-images.ubuntu.com/locator/ec2/ for other images
# This will need to be updated from time to time as amis are deprecated
if [[ -z "${AWS_IMAGE-}" ]]; then
case "${ZONE}" in
ap-northeast-1)
AWS_IMAGE=ami-93876e93
;;

ap-southeast-1)
AWS_IMAGE=ami-66546234
;;

eu-central-1)
AWS_IMAGE=ami-e2a694ff
;;

eu-west-1)
AWS_IMAGE=ami-d7fd6ea0
;;

sa-east-1)
AWS_IMAGE=ami-a357eebe
;;

us-east-1)
AWS_IMAGE=ami-6089d208
;;

us-west-1)
AWS_IMAGE=ami-cf7d998b
;;

cn-north-1)
AWS_IMAGE=ami-d436a4ed
;;

us-gov-west-1)
AWS_IMAGE=ami-01523322
;;

ap-southeast-2)
AWS_IMAGE=ami-cd4e3ff7
;;

us-west-2)
AWS_IMAGE=ami-3b14370b
;;

*)
echo "Please specify AWS_IMAGE directly (region not recognized)"
exit 1
esac
fi
}

# Verify prereqs
function verify-prereqs {
if [ "$(which aws)" == "" ]; then
Expand Down Expand Up @@ -235,6 +296,8 @@ function kube-up {
ssh-keygen -f $AWS_SSH_KEY -N ''
fi

detect-image

aws iam get-instance-profile --instance-profile-name ${IAM_PROFILE} || {
echo "You need to set up an IAM profile and role for kubernetes"
exit 1
Expand Down Expand Up @@ -321,7 +384,7 @@ function kube-up {

echo "Starting Master"
master_id=$($AWS_CMD run-instances \
--image-id $IMAGE \
--image-id $AWS_IMAGE \
--iam-instance-profile Name=$IAM_PROFILE \
--instance-type $MASTER_SIZE \
--subnet-id $SUBNET_ID \
Expand Down Expand Up @@ -394,7 +457,7 @@ function kube-up {
grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/salt-minion.sh"
) > "${KUBE_TEMP}/minion-start-${i}.sh"
minion_id=$($AWS_CMD run-instances \
--image-id $IMAGE \
--image-id $AWS_IMAGE \
--iam-instance-profile Name=$IAM_PROFILE \
--instance-type $MINION_SIZE \
--subnet-id $SUBNET_ID \
Expand Down

0 comments on commit 55ed70f

Please sign in to comment.