Kubernetes on AWS Cloud

Kubernetes on AWS Cloud

In this article ‘AWS Kops Kubernetes’ , you are going to setup  Kubernetes on AWS cloud environment.For which I am going to use a tool called KOPS.

What is KOPS? kops is an opinionated provisioning system with

  • Fully automated installation
  • Uses DNS to identify clusters
  • Self-healing: everything runs in Auto-Scaling Groups
  • Limited OS support (Debian preferred, Ubuntu 16.04 supported, early support for CentOS & RHEL)
  • High-Availability support
  • Direct provision or terraform manifest generation


As a part of the setup, you would need an Ubuntu or Debian instance with latest updates and other supporting utility/tools like AWS-CLI, S3 bucket, Hosted Zone on Route 53 and a registered domain. In this article, I am going to use Ubuntu instance to launch and install kubernetes cluster.

Ubuntu EC2-instance: Will be used to install kubernetes cluster

Let me launch an AWS EC2 Ubuntu instance and update with the latest packages.

$sudo apt-get update

$sudo apt-get -y upgrade

kops installation

I have downloaded the latest version of kops and changed the permission before moving it to /usr/local/bin

$ wget -O kops https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64

$ chmod +x kops

$ sudo mv kops /usr/local/bin/

kubectl installation

I have downloaded the latest version of the kubectl and changed the permission before moving it to /usr/local/bin

$ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
$ chmod +x kubectl
$ sudo mv kubectl /usr/local/bin


I have installed AWS CLI to access the AWS instance from the command line to create Kubernetes cluster.

$ sudo apt-get install python-pip
$ pip install --upgrade pip
$ sudo pip install awscli

IAM user creation

On AWS console, I have created a new IAM user (for example kops) with full access and saved the access keys as it would be used to configure the AWS CLI. Then I have copied both AWS access key ID and AWS secret access key for later usage.

On the EC2 instance, I have configured the newly created AWS IAM user with following commands

$aws configure

AWS Access Key ID [None]:  AWS Secret Access Key [None]: Default region name [None]: < Optional : Please enter the region or blank for default>
Default output format [None]: < Optional : Please enter the output format or blank for default>

On the same the EC2 instance, I have generated a key pair for AWS EC2 user. It will be used to connect to the kubernetes cluster which I am going to create. In my case, as it is Ubuntu user the ssh keys by default are stored in .ssh folder of the user home directory.

$ ssh-keygen

Domain creation

I have created a domain for the cluster user “kops” and DNS for discovery which will be used inside the cluster and to reach the kubernetes API server from the client. It should have a valid DNS name. I recommend using a subdomain for the cluster configuration.

An existing domain or a new domain can be used. In this example, I have created a new domain and hosted it on dot.tk which is a free domain provider.

Domain registration on dot.tk / freenom.com:

I have registered a new domain on freenom.com with the name k8sclustersetup.tk which I going to use for my Kubernetes cluster.

Host Registration

Create Hosted Zone

On AWS console, I have created a new Hosted zone on router 53. I have logged into AWS console, navigate to router53 DNS management and created new Hosted Zone. It’s advisable to create a subdomain. This creates a set of name servers which can be copied for later usage. I have copied the name server details which starts with ns-xxx.awsdns-xx.com, ns-xxx.awsdns-xx.co.uk, ns-xxx.awsdns-xx.org, ns-xxx.awsdns-xx.net.

Hosted Zones

These NameServer (NS) values should be updated on the domain service provider. In this setup, I have updated the NS details on freenom.com.

Cluster Setup

S3 bucket creation

I have created a new S3 bucket with a meaningful name (for example “kopsclusterdemo”) which is used to store the cluster state. Kubernetes uses S3 to store the cluster details like configuration, keys, etc.

With this, all the pre-requisite has been setup and the environment is ready to create and launch the Kubernetes cluster.

Kubernetes cluster creation

For learning purpose, I have chosen the t2.micro which is a free EC2 instance. I have executed the below command to create the kubernetes cluster with one master and 2 worker nodes.

$ kops create cluster --name=k8sclustersetup.tk --state=s3://kopsclusterdemo --zones=eu-west-2a --node-count=2 --node-size=t2.micro --master-size=t2.micro --dns-zone=k8sclustersetup.tk

$kops update cluster k8sclustersetup.tk --yes --state=s3://kopsclusterdemo

It takes a couple of minutes for the Kubernetes cluster to get created. To confirm whether the Kubernetes cluster got created I have used the below command to list the cluster details.

$kops get cluster --state=s3://kopsclusterdemo

Cluster node details can be listed by issuing the below command.

$kubectl get node

Finally kubernetes service is up and running on aws ec2.


In this article, the details to install and configure Kubernets on AWS Cloud has been provided.

You can have a look at other importat aws services here.



Transformation consultant with a broad experience on Blockchain, Agile-DevOps, Containerisation, Cloud Architecture, Microservices.