Skip to content

Instantly share code, notes, and snippets.

@kimkimhun
Forked from yetanotherchris/install-kops.sh
Created February 20, 2019 13:10
Show Gist options
  • Select an option

  • Save kimkimhun/3a4714d7cbf30c86bba4d769059dd92d to your computer and use it in GitHub Desktop.

Select an option

Save kimkimhun/3a4714d7cbf30c86bba4d769059dd92d to your computer and use it in GitHub Desktop.

Revisions

  1. @yetanotherchris yetanotherchris revised this gist Jul 27, 2017. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions install-kops.sh
    Original file line number Diff line number Diff line change
    @@ -11,9 +11,10 @@ aws config

    # Pass the keys to Kops via env vars
    printf "Enter an AWS access key"
    read $accesskey
    read accesskey

    printf "Enter an AWS secret key"
    read $secretKey
    read secretKey

    export AWS_ACCESS_KEY_ID=$accessKey
    export AWS_SECRET_ACCESS_KEY=$secretKey
    @@ -32,9 +33,10 @@ aws iam add-user-to-group --user-name kops --group-name kops

    # Create an S3 bucket
    printf "Enter an S3 bucket name to create: "
    read S3_BUCKET_NAME
    export KOPS_STATE_STORE=s3://$S3_BUCKET_NAME
    aws s3api create-bucket --bucket S3_BUCKET_NAME --region eu-west-1
    read s3BucketName

    export KOPS_STATE_STORE=s3://$s3BucketName
    aws s3api create-bucket --bucket $s3BucketName --region eu-west-1

    # Example of creating a cluster
    printf "Enter a cluster name"
  2. @yetanotherchris yetanotherchris created this gist Jul 27, 2017.
    43 changes: 43 additions & 0 deletions install-kops.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    # Install AWS CLI, Kubectl, Kops
    sudo apt update
    sudo apt install -y awscli
    sudo snap install kubectl --classic
    curl -LO https://github.com/kubernetes/kops/releases/download/1.7.0/kops-linux-amd64
    chmod +x kops-linux-amd64
    mv ./kops-linux-amd64 /usr/local/bin/kops

    # Setup the AWS profile
    aws config

    # Pass the keys to Kops via env vars
    printf "Enter an AWS access key"
    read $accesskey
    printf "Enter an AWS secret key"
    read $secretKey

    export AWS_ACCESS_KEY_ID=$accessKey
    export AWS_SECRET_ACCESS_KEY=$secretKey

    # Create the IAM user, groups, roles
    aws iam create-group --group-name kops

    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess --group-name kops
    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonRoute53FullAccess --group-name kops
    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess --group-name kops
    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/IAMFullAccess --group-name kops
    aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonVPCFullAccess --group-name kops

    aws iam create-user --user-name kops
    aws iam add-user-to-group --user-name kops --group-name kops

    # Create an S3 bucket
    printf "Enter an S3 bucket name to create: "
    read S3_BUCKET_NAME
    export KOPS_STATE_STORE=s3://$S3_BUCKET_NAME
    aws s3api create-bucket --bucket S3_BUCKET_NAME --region eu-west-1

    # Example of creating a cluster
    printf "Enter a cluster name"
    read name
    export KOPS_CLUSTER_NAME=$name
    kops create cluster --name=$KOPS_CLUSTER_NAME --cloud=aws --zones=eu-west-1a --state=$KOPS_STATE_STORE