-
-
Save adamcousins/ac10555b1963012a968260f62ad7c4a4 to your computer and use it in GitHub Desktop.
kops - kubernetes 1.9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export CLUSTER_NAME=${CLUSTER_NAME:-example.cluster.k8s.local} | |
export KUBERNETES_VERSION=${KUBERNETES_VERSION:-https://storage.googleapis.com/kubernetes-release/release/v1.9.0/} | |
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-us-west-2} | |
# Get all available AZs | |
export AWS_AVAILABILITY_ZONES="$(aws ec2 describe-availability-zones --query 'AvailabilityZones[].ZoneName' --output text | awk -v OFS="," '$1=$1')" | |
# Create a unique s3 bucket name, or use an existing S3_BUCKET environment variable | |
export S3_BUCKET=${S3_BUCKET:-kops-state-store-$(cat /dev/random | LC_ALL=C tr -dc "[:alpha:]" | tr '[:upper:]' '[:lower:]' | head -c 32)} | |
export KOPS_STATE_STORE=s3://$S3_BUCKET | |
echo "Using S3 bucket $S3_BUCKET: to use with kops run" | |
echo " export KOPS_STATE_STORE=s3://$S3_BUCKET" | |
# Create the bucket if it doesn't exist | |
_bucket_name=$(aws s3api list-buckets --query "Buckets[?Name=='$S3_BUCKET'].Name | [0]" --out text) | |
if [ $_bucket_name == "None" ]; then | |
aws s3api create-bucket --bucket $S3_BUCKET --create-bucket-configuration LocationConstraint=$AWS_DEFAULT_REGION | |
fi | |
kops create cluster --name $CLUSTER_NAME --zones $AWS_AVAILABILITY_ZONES --kubernetes-version $KUBERNETES_VERSION --yes | |
# To delete and cleanup | |
#kops delete cluster --name $CLUSTER_NAME --yes | |
#aws s3api delete-bucket --bucket $S3_BUCKET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment