How to setup Kubernetes cluster on AWS Cloud


In this article, I am going to setup a Kubernetes cluster on AWS cloud environment up 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, I 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 my cluster.

Ubuntu EC2-instance

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$(curl -s | 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$(curl -s
$ 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 which is a free domain provider.

Domain registration on /

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

alt text

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,,,

alt text


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


alt text



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 --state=s3://kopsclusterdemo --zones=eu-west-2a --node-count=2 --node-size=t2.micro --master-size=t2.micro

$kops update cluster --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


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



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

Leave a Reply

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