Introduction
Kops (Kubernetes Operations) is a command-line tool that simplifies the deployment, upgrade, and management of Kubernetes clusters. It is often considered the “kubectl” equivalent for cluster operations and is best suited for production-grade clusters.
This guide walks you through the process of creating a Kubernetes cluster using Kops.
Step 1: Prerequisites
Install AWS CLI
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
Configure it:
aws configure
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
sudo mv kubectl /usr/local/bin/
Install Kops
curl -LO https://github.com/kubernetes/kops/releases/download/v1.28.0/kops-linux-amd64
chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops
Set up an S3 bucket for Kops state storage
aws s3api create-bucket --bucket <your-kops-state-store> --region <region> --create-bucket-configuration LocationConstraint=<region>
Enable versioning
aws s3api put-bucket-versioning --bucket <your-kops-state-store> --versioning-configuration Status=Enabled
Set environment variables
Define the Kops state store
export KOPS_STATE_STORE=s3://<your-kops-state-store>
Step 2: Create a Cluster
kops create cluster \
--name=<cluster-name> \
--state=$KOPS_STATE_STORE \
--zones=<availability-zones> \
--node-count=<number-of-nodes> \
--node-size=<instance-type> \
--master-size=<instance-type> \
--dns-zone=<hosted-zone-name>
Validate the configuration
Ensure the cluster configuration is correct:
kops update cluster --name <cluster-name> --yes
Access the cluster
Retrieve the Kubernetes config and interact with the cluster:
kubectl get nodes
Clean Up
To delete the cluster when it is no longer needed:
kops delete cluster --name <cluster-name> --yes
Happy Learning
Prithiviraj Rengarajan
DevOps Engineer