AWS and Kubernetes

AWS and Kubernetes (simple setup using kops)

kops is a command line tool that helps you create Kubernetes clusters. AWS (Amazon Web Services) is currently officially supported, with GCE in beta support. The following instructions are for installing and running kops on a Linux box. It assumes you have an AWS account and credentials (Access Key and Secret Key).

Installing kops

Install kops cli

wget -O kops$(curl -s | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
chmod +x ./kops
sudo mv ./kops /usr/local/bin/

Install aws cli

pip install awscli
aws configure

Setup variables for an AWS bucket name and region

Change the values below to meet your criteria

export BUCKETNAME=YOUR_BUCKET_NAME # examples: my-kops-system-state or kops-cluster-state, etc...
export REGION=YOUR_REGION_NAME # examples: us-east-2, or us-west-1, etc...

Install kubectl

wget -O kubectl$(curl -s
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

Create a bucket first

aws mb s3://${BUCKETNAME} --region ${REGION}

Setup env variables (probably should add theses to your .bash_profile)

export NAME=myfisrtcluster.k8s.local # gossip based (ends in k8s.local)

Create a keypair for login to the cluster

ssh-keygen -t rsa

Get AZ info

aws ec2 describe-availability-zones --region ${REGION}


Choose Availability Zones from the REGION you want the cluster deployed into – change the sizes, number of nodes, etc… The --target is optional, you will get a CloudFormation template placed into the out/ directory

Create the cluster and send output to CF file in out/ dir

kops create cluster --zones=us-east-2a,us-east-2b ${NAME} --node-count=2 --node-size=t2.small --master-zones=us-east-2a --master-size=t2.medium --target=cloudformation

Run the CloudFormation stack or just proceed to the edit command

Nothing is deployed until you edit the config

kops edit cluster ${NAME}

Build the cluster

kops update cluster ${NAME} --yes

Cluster should be up

kubectl get nodes
kops validate cluster
kubectl -n kube-system get pods


Installing the dashboard

The dashboard provides a GUI interface into the cluster

kubectl apply -f

Get username and password

kubectl config view

Run the cluster-info command to get the cluster url

kubectl cluster-info

Login with username and password found when you ran the kubectl config view command

Get a token so you can authenticate with the dashboard

kubectl get secrets

Find the default secret

kubectl describe secret PAST_YOUR_SECRET_VALUE

Copy secret token value and enter it in the dashboard


Cleanup by deleting the cluster

kops delete cluster --name ${NAME}

Review resources to be deleted

kops delete cluster --name ${NAME} --yes

Removes resources, cleans the bucket, but does not delete it


Michael Hayslip


Leave a Reply

Your email address will not be published. Required fields are marked *