Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose AWS image by region #5382

Merged
merged 1 commit into from
Mar 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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=t2.micro
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=t2.micro
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 @@ -237,6 +298,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 @@ -323,7 +386,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 @@ -396,7 +459,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