Kops is a tool for building a Kubernetes cluster in Amazon Web Services. Here is what my experience was and how I got started.

First thing to understand when starting out is the difference between kops and kubectl.

kops is the tool to create the objects in AWS in order to setup a kubernetes cluster. It is not responsible for deploying your containers or setting up any of your services, it just gets the cluster up and running. I'm sure it does more, but thats all i've used it for.

kubectl is the command to configure and control your cluster. It is used to deploy to update and to delete your docker containers. Essentially it is responsible for what happens within your cluster.


So, lets get started. Firstly you will need to setup an S3 Bucket to store your cluster configuration.

aws s3 mb s3://my-cluster.mydomain.com  
export KOPS_STATE_STORE=s3://my-cluster.mydomain.com  

This bucket will be used to store keys and configuration in order to connect to your cluster and we store the bucket in an environment variable that kops will automatically pickup, next step is to install kops, you'll also need to have installed kubectl, see more at Installing kubectl

brew update && brew install kops  

Ok, kops uses DNS for cluster discovery, meaning it will modify the DNS records of a domain with updates to the cluster environment. This allows all the services running to use DNS to find other services. In order for this to happen, the custer name needs to be a fully qualified domain name and we need to setup AWS Route53 as the name server in order for awscli to modify the records.

Kops runs in read only mode by default, and only enters write mode when you add a --yes parameter on the command line. So lets setup a cluster. Run the following to setup the configuration

kops create cluster --zones=us-east-1a my-cluster.mydomain.com  

This will have added the configuration to the bucket we created, you can take a look in there to see what its done. Next we'll actually create the cluster, this will start up boxes on your EC2, so the money starts ticking from this point,

kops update cluster my-cluster.mydomain.com --yes  

This will take a wee bit to start up the master and nodes configured, once its done, you should have boxes up and running on EC2 talking to each other. You also should have a .kube folder in your home folder containing kubectl config to talk to your cluster. So, if your dashboard is up and running you should be able to run:

kubectl proxy  

and then access http://localhost:8001/ui and you will see your new cluster's dashboard.

Other useful commands are:

kubectl get pods
kubectl get services

Some useful resources are:

https://github.com/kubernetes/kops
https://kubernetes.io/docs/getting-started-guides/kops/