Kops (Kubernetes Operations): The Ultimate Guide for DevOps Engineers


Introduction
Kubernetes has become the go-to solution for container orchestration, enabling DevOps teams to manage applications efficiently. However, setting up and managing a Kubernetes cluster can be challenging. This is where Kops (Kubernetes Operations) comes into play. Kops simplifies the process of deploying, maintaining, and upgrading Kubernetes clusters, especially on cloud platforms like AWS.
In this blog, we’ll cover what Kops is, its benefits, installation steps, how to create a Kubernetes cluster using Kops, and best practices for managing production-ready clusters.
What is Kops?
Kops is an open-source tool that automates the deployment and management of Kubernetes clusters. It provides a CLI-based solution to set up highly available, scalable clusters primarily on AWS.
Key Features of Kops:
Automated Cluster Provisioning – Easily create and manage Kubernetes clusters.
Highly Available Clusters – Supports multi-master configurations for resilience.
Rolling Updates & Upgrades – Ensures zero-downtime updates.
Infrastructure as Code – Clusters can be defined in YAML, enabling GitOps practices.
Built-in Add-ons – Comes with networking, monitoring, and logging integrations.
Prerequisites
Before installing Kops, ensure you have the following:
AWS Account with IAM permissions to create EC2 instances, S3 buckets, and Route 53 DNS records.
kubectl installed to interact with the Kubernetes cluster.
AWS CLI configured with necessary credentials.
Kops installed on your EC2 system.
STEPS TO CREATE CLUSTER USING KOPS:
STEP-1: LAUCH EC2 INSTANCE
AMI : Amazon Linux Kernel 5.10
Instance Type: t2.micro
EBS : 20GB
IAM ROLE : admin permissions
STEP-2: SET THE DEFAULT PATH
Open .bashrc file using vi editor (vi .bashrc)
add this line on the end of the file : export PATH=$PATH:/usr/local/bin/
exit from the file
make this path as source : source .bashrc
STEP-3: INSTALL AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
STEP-4: INSTALL KUBECTL
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin/
STEP-5: INSTALL KOPS
wget https://github.com/kubernetes/kops/releases/download/v1.24.1/kops-linux-amd64
chmod +x kops-linux-amd64
mv kops-linux-amd64 /usr/local/bin/kops
STEP-6: CHECK VERSION
kops version
kubectl version
STEP-7: CREATE S3 BUCKET & ENABLE VERSION
aws s3api create-bucket --bucket <bucket-name> #bucket name should be unique
aws s3api put-bucket-versioning --bucket <bucket-name> --versioning-configuration Status=Enabled
STEP-8 : EXPORT THE CLUSTER STATE
export KOPS_STATE_STORE=<bucket-name>
STEP-9 : CREATE A CLUSTER
kops create cluster --name <cluster-name> --zones us-east-1a --master-size t2.medium --master-count 1 --master-volume-size 20 --node-size t2.micro --node-count 2 --node-volume-size 20
STEP-10 : UPDATE THE CLUSTER
kops update cluster --name <cluster-name> --yes --admin
Now wait for 5 mins until the cluster is ready. After 5 mins check with the nodes kubectl get no to get the nodes from cluster.
How to delete a cluster:
EXPORT THE CLUSTER STATE : export KOPS_STATE_STORE=<bucket-name>
TO GET THE CLUSTER : kops get cluster
TO DELETE THE CLUSTER : kops delete cluster --name <cluster-name> --yes
Conclusion
Kops is a powerful tool for deploying and managing Kubernetes clusters efficiently. It simplifies infrastructure management, supports automation, and ensures high availability, making it an ideal choice for DevOps engineers working with AWS. By following the steps outlined in this guide, you can set up a production-ready Kubernetes cluster using Kops.
Subscribe to my newsletter
Read articles from Shaik Mustafa directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
