Kubernetes: First steps on Amazon AWS

Start a new Amazon Linux instance. For example a t3.medium. Log-in and configure the aws tools. Best practice is to create a new IAM user, assign permissions (PowerUserAccess + iam:PassRole), and use these access keys.

Create new IAM role 'kubernetes'. This role prevents exchanging aws keys with the Minions.

$ aws configure
AWS Access Key ID [None]: {ACCESS_KEY}  
AWS Secret Access Key [None]: {SECRET_ACCESS_KEY}  
Default region name [None]: eu-west-1  
Default output format [None]:  

Download and extract kubernetes.

$ cd /usr/local/src
$ wget https://github.com/GoogleCloudPlatform/kubernetes/releases/download/v0.5/kubernetes.tar.gz
$ tar -xzf kubernetes.tar.gz; cd kubernetes
$ export PATH=$PATH:$PWD/platforms/<os>/<platform>

Update cluster/aws/config-default.sh with correct ami and instance type. You can look up the correct AMI here: http://cloud-images.ubuntu.com/releases/14.04/release/.

For the eu-west-1 region and the t2.medium image you can use ami-823686f5.

Update the configuration config-default.sh.

ZONE=eu-west-1  
MASTER_SIZE=t2.medium  
MINION_SIZE=t2.medium  
NUM_MINIONS=4

IMAGE=ami-823686f5  

I've made some small improvements to util.sh to improve stability and fix some issues. These are not pulled yet.

curl https://github.com/dutchcoders/kubernetes/blob/master/cluster/aws/util.sh > cluster/aws/util.sh  

Export environment variables. Currently the AWSACCESSKEYID and AWSSECRETACCESSKEY are both necessary as environment and in the configuration. Due to being used by different processes.

export KUBERNETES_PROVIDER=aws  
export AWS_ACCESS_KEY_ID={}  
export AWS_SECRET_ACCESS_KEY={}  

Start the cluster.

cluster/kube-up.sh  
[root@ip-172-31-11-76 kubernetes]# cluster/kube-up.sh
Starting cluster using provider: aws  
Uploading to Amazon S3  
+++ Staging server tars to S3 Storage: kubernetes-staging-f85be33c333c39423e7cda6e959bfc7e/devel
upload: server/kubernetes-server-linux-amd64.tar.gz to s3://kubernetes-staging-f85be33c333c39423e7cda6e959bfc7e/devel/kubernetes-server-linux-amd64.tar.gz  
upload: server/kubernetes-salt.tar.gz to s3://kubernetes-staging-f85be33c333c39423e7cda6e959bfc7e/devel/kubernetes-salt.tar.gz  
Waiting for minion ip-172-20-0-10.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-10.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-10.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Minion ip-172-20-0-10.eu-west-1.compute.internal running  
Waiting for minion ip-172-20-0-11.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-11.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-11.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-11.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Minion ip-172-20-0-11.eu-west-1.compute.internal running  
Waiting for minion ip-172-20-0-12.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-12.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-12.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-12.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Minion ip-172-20-0-12.eu-west-1.compute.internal running  
Waiting for minion ip-172-20-0-13.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-13.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-13.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Waiting for minion ip-172-20-0-13.eu-west-1.compute.internal to spawn  
Sleeping for 3 seconds...  
Minion ip-172-20-0-13.eu-west-1.compute.internal running  
Waiting for cluster to settle  
..

Wait for the cluster to be started. This can take a while.

Stop the cluster

This will clean-up the VPC and shutdown all started Kubernetes instances.

cluster/kube-down.sh

Debugging:

When having issues while starting the cluster, you can login to the master, and check the /var/log/cloud-init-output.log for error. You can also check the state of the configuration using:

sudo salt '*' state.highstate

Issues

When having less then 4 minions, the master is still working on cloudinit. The scripts should wait and check if the cloud-init-output.log contains the message "Cloud-init v. 0.7.5 finished at Wed, 26 Nov 2014 15:30:58 +0000. Datasource DataSourceEc2. Up 128.01 seconds" before proceeding.

The current control manager version checks for config file, and --cloudprovider aws and --cloudconfig are missing. This have been corrected in the pull request.

References