Set up kubernetes cluster on AWS using KOPS

Ekta Garg
Ekta Garg
Apr 4 · 4 min read

Kubernetes (k8s) is an open-source system for automating deployment, scaling, and management of containerized applications.

What is Kops?

Kubernetes Operations, or Kops, is an open source project used to set up Kubernetes clusters, for deploying small production grade clusters.The project describes itself as kubectl for clusters.

kops has commands for creating clusters, updating their settings, and applying changes. It uses declarative configuration, so it’s smart enough to know how to apply infrastructure changes to existing clusters. It also has support for cluster operational tasks like scaling up nodes or horizontally scaling the cluster. Kops automates a large part of operating Kubernetes on AWS.

for installation and setup, visit:

https://github.com/kubernetes/kops and download the latest release.

Follow these steps(do it one by one, don’t skip any) to create a cluster on AWS using KOPS:

  1. Create an account on AWS.
  2. Go to Identity & Access Management (IAM), create a user and generate an access key to configure AWS on your machine. You need to give AdministratorAccess Permissions to this IAM user.
  3. Open the command line and configure AWS
aws configure

provide access key and secret you just generated, along with that provide the region you are going to deploy your cluster in. AWS recommends users to choose regions geographically close to them to reduce latency and costs.

4. Go to S3 (Simple Storage Service) Bucket, it is a public cloud storage resource. Amazon S3 buckets, which are similar to file folders, store objects, which consist of data and its descriptive metadata.

Create a bucket by giving it a name and region. Once the bucket has been created, you can select a tier for the data, with different S3 tiers having different levels of redundancy, prices and accessibility.

5. Route 53 allows you to do DNS Management. Create a subdomain in route53.

You can either register a new domain name on AWS or even somewhere cheaper. There are also free solutions, so you don’t need to spend money on a domain name.

If you have a domain name suppose “example.com”, you need to create hosted zone. click “create hosted zone” and add domain name “kubernetes.example.com”. Add all namespace values to where your hosted zone is. Like mine is hosted on “Godaddy.com” so I added nameserver like this:

ns records on godaddy.com

Now you have done all the preparation. You can start launching a kubernetes cluster using kops.

6. Before setting up cluster, you need to make sure that you have kubectl installed (https://kubernetes.io/docs/tasks/tools/install-kubectl/)

Create ssh key to access all of our EC2 instances.

ssh-keygen -f .ssh/id_rsa

7. Create your kubernetes cluster :

kops create cluster --name=kubernetes.example.com --state=s3://kops-state-example --zones=ap-south-1a --node-count=2 --node-size=t2.micro --master-size=t2.micro --dns-zone=kubernetes.example.com

This command will create 3 EC2 instances — one master node and two worker nodes. DNS Zone is the one you created in route53.

If you want to make changes to the cluster, like the size of the node or anything, run this:

kops edit cluster kubernetes.example.com --state=s3://kops-state-example

A config file will appear and make necessary changes to that file.

Now to apply the changes you made to the cluster, update the cluster:

kops update cluster kubernetes.example.com --yes

It is going to take some time to update the existing cluster.

8. To check that all k8s masters and nodes are running and have “Ready” status, all the components are healthy. All pods in the kube-system namespace are running and healthy.

Validate a cluster

  # Validate a cluster.
# This command uses the currently selected kops cluster as
# set by the kubectl config.
kops validate cluster

You have created the cluster successfully. There are multiple commands, you can use to get clusters, instances, describe, delete, upgrade etc.

So if you want to delete this cluster in one go:

Delete a cluster

kops delete cluster --name=kubernetes.example.com --state=s3://kops-state-example --yes

And using this command, you can delete the cluster you created. It will automatically delete corresponding nodes, pods, services, data in s3 bucket and (if created) load balancers in route53.


If you have any insight, respond here! Otherwise, I hope this article helped you answer how to setup a kubernetes cluster on AWS. Also, there are few more articles following this one which I’ve published. You should check those articles as well. Thanks for reading and stay tuned!

Ekta Garg

Written by

Ekta Garg

A feminist by nature, a developer by profession, and a blogger by passion. Follow me to follow my journey (only technical as of now)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade