Blog

launch Kubernetes cluster on AWS using KOPS

launch Kubernetes cluster on AWS using KOPS

KOPS Stands for Kubernetes Operations. On AWS Environment, you can setup Kubernetes Cluster using 2 ways. One with EKS and another with KOPS. If you want to learn kubernetes, you are begineer with Kubernetes, or you want to launch cost-friendly cluster for development or testing purpose, you can use KOPS. In this tutorial, we will show you how you can setup Kubernetes on AWS with various KOPS Commands.
When you launch kubernetes cluster using KOPS, you can manage nodes using KOPS commands. In this guide, I’ll show you how to launch kubernetes cluster on AWS using KOPS easily which is cost friendly for development and testing purposes.

Install KOPS (Linux)

sudo apt-get update

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/

To use KOPS with AWS, you also need aws-cli installed and configured

Install latest aws-cli version

apt-get install python-pip

pip install awscli

Install Kubectl

wget -O kubectl 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/kubectl

Before launching Cluster, you need to set up one S3 bucket to store the state of Kubernetes Cluster, Create an S3 bucket in the region where you are setting up a cluster (to avoid data transfer charges)

You also need 1 domain setup, Set it up Domain’s name server in AWS route53, so KOPS can edit routes when needed.

After that, Now let’s launch a cluster

kops create cluster --name=kubernetes.identicalcloud.com --state=s3://kubernetes-state-demo --zones=us-east-1a --node-count=1 --node-size=t2.micro --master-size=t2.micro --dns-zone=kubernetes.identicalcloud.com

Here,

  • you can name your cluster the same as DNS Zone name
  • State should be your previous created S3 bucket name
  • In Zones, select region and availability zone where you want to create your cluster
  • Select Node-size, based on AWS’s available instance type
  • Select Master Node Size, based on AWS’s available instance type
  • Select DNS-Zone, based on your domain’s availability

Once you run this command, it will show you everything that will be launched using this command, review all information stated and re-run command using `–yes` flag

One it’s run, it may take 15 to 60 minutes for cluster to be fully up and running.

To verify cluster’s status, run

kops validate cluster

To edit cluster setting, use below-mentioned command

kops edit cluster --name=kubernetes.identicalcloud.com

change minion node settings

To add new minion nodes, to remove minion nodes, to change instance type for nodes, use below-mentioned command

kops edit ig nodes --name=kubernetes.identicalcloud.com

change master node settings

To add new master nodes, to remove master nodes, to change instance type for nodes, use below-mentioned command

kops edit ig master-us-east-1a --name=kubernetes.identicalcloud.com

Update Cluster

For above changes to work, use rolling update

kops rolling-update cluster 

Delete Cluster

To delete cluster and all created resources, use below-mentioned command

kops delete cluster --name kubernetes.identicalcloud.com --state=s3://kubernetes-state-demo    

Please use above command with caution, it will delete cluster and all resources that are running inside cluster

Drafted On,
February 7th, 2021
DevOps @ identicalCloud.com

Leave a Comment