HOW TO INSTALL KUBERNETES USING KOPS ON AWS
INTRODUCTION:
Kops is an open-source tool designed to simplify the process of creating, managing, and maintaining Kubernetes clusters on AWS. It automates the entire lifecycle of a Kubernetes cluster, from initial setup to upgrades and ongoing maintenance. we will walk you through the step-by-step process of installing Kubernetes using Kops on AWS. We will cover the necessary prerequisites, detailed installation steps, and best practices to ensure a smooth and successful deployment. This tutorial will provide you with the knowledge and tools to get your Kubernetes cluster up and running efficiently on AWS.
KOPS REQUIREMENTS:
- Linux(machine) Ubuntu-2 cpu, 4GB RAM
- AWS Account
-IAM user
-S3 bucket to store the kops state - KOPS binary
- Kubectl binary
- Generate SSH key
STEP 1:
Kops binary setup:
curl -Lo kops https://github.com/kubernetes/kops/releases/latest/download/kops-linux-amd64 chmod +x ./kops sudo mv ./kops /usr/local/bin/ |
STEP 2:
Kubectl binary setup:
curl -LO “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/ |
STEP 3:
Setup IAM user:
To securely manage your Kubernetes clusters on AWS using Kops, it’s essential to create a dedicated IAM user with the appropriate permissions. The kops user will require the necessary permission to function properly.
AmazonEC2FullAccess AmazonRoute53FullAccess AmazonS3FullAccess IAMFullAccess AmazonVPCFullAccess AmazonSQSFullAccess AmazonEventBridgeFullAccess |
STEP 4:
We need to create an IAM user and configure the aws to your New IAM user.
Install AWS CLI:
sudo apt update sudo apt install awscli -y |
Configure AWS CLI:
aws configure |
Enter the Access Key ID and Secret Access Key of the IAM user you created. Also, specify the default region name (eg: us-east-1) and the output format (eg: json).
AWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: Default output format [None]: json |
STEP 5:
Add the AWS Access Key ID and AWS Secret Access Key as env variables.
export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id) export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key) |
STEP 6:
We need to create the S3 buckets to store the Kops state.
The bucket name must be unique.
STEP 7:
Generate SSH Keys
ssh-keygen |
STEP 8:
Creating your first cluster. Prepare the local environment.
We need to set up some env variables to make this process easier.
We need to mention the name of the cluster and the name of the s3 bucket. The cluster name should end with k8s.local. For example:
export NAME=naveen.k8s.local export KOPS_STATE_STORE=s3://newbucket2024 |
STEP 9:
The below command is to create the cluster.
kops create cluster –zones ap-south-1 ${NAME} |
If choose multiple availability zones
kops create cluster –zones ap-south-1,east-1b ${NAME} |
STEP 10:
Using the below command to edit your node instance group.
kops edit ig –name=Naveen.k8s.local nodes-ap-south-1 |
Using the below command to edit your master instance group.
kops edit ig –name=Naveen.k8s.local master-ap-south-1 |
STEP 11:
Finally, configure your cluster.
kops update cluster –name naveen.k8s.local –yes –admin |
STEP 12:
We need to validate the cluster using the below command.
kops validate cluster |
STEP 13:
We can use the below command to delete the cluster.
kops delete cluster –name=naveen.k8s.local –state=s3://newbucket2024 –yes |
CONCLUSION:
Setting up Kubernetes on AWS using Kops is a powerful way to manage your containerized applications with ease and efficiency. Through this guide, we have walked through the essential steps
By following these steps, you have set up a robust Kubernetes cluster on AWS, capable of supporting your development and production workloads. This setup not only simplifies cluster management but also provides the scalability and reliability needed for modern applications.