The Ultimate Guide to Setting Up a Self-Managed Kubernetes Cluster on AWS in India
"Discover how to establish a self-managed Kubernetes cluster on AWS in India with Cpluz's expert guide. Learn step-by-step setup & deployment for seamless operations."
3 min readCpluz
The Ultimate Guide to Setting Up a Self-Managed Kubernetes Cluster on AWS in India
With the exponential rise in containerized applications, Kubernetes has become the de-facto standard for container orchestration. Setting up a Kubernetes cluster, however, can be a daunting task, especially in a cloud environment like Amazon Web Services (AWS). In this comprehensive guide, we will walk you through the process of setting up a self-managed Kubernetes cluster on AWS in India, ensuring seamless deployment and management of your containerized applications.
Prerequisites
To kickstart your journey, ensure you have the following prerequisites:
- AWS account
- Familiarity with AWS CLI
- AWS IAM user with necessary policy permissions
- Kubectl installed and configured
Create an EC2 Key Pair
First, log into your AWS management console and create an EC2 key pair for managing your cluster. This key pair is used to authenticate SSH connections to your EC2 instances:
Navigate to the EC2 dashboard
Click on "Key Pairs" under the "Network & Security" section
Click on "Create key pair"
Name your key pair and save it as a .pem file
Create a VPC and Subnet
Next, create a VPC and subnet for your Kubernetes cluster. This VPC will serve as the network environment for your cluster:
- Create a new VPC by clicking on "VPC" under the "Network & Security" section
- Name your VPC and choose the default Amazon VPC settings
- Create a new subnet by clicking on "Subnets" under the "Network & Security" section
- Name your subnet and choose the "Availability Zone" and "VPC" accordingly
Launch Master and Worker Nodes
Launch EC2 instances for your Kubernetes cluster by using the AWS CLI. This will include the master node, worker nodes, and an optional etcd node:
- Run the command
aws ec2 run-instances --image-id ami-0c55b159cbfafe1f0 --instance-type t2.medium --key-name your-key-pair --security-group-ids sg-11111111 --count 3- replace "ami-0c55b159cbfafe1f0" with the official AWS Amazon Linux 2 AMI and "sg-11111111" with your security group ID - Wait for the instances to start and reach ready status
Install kubeadm and Docker
Once the instances are running, SSH into the master node and install kubeadm and Docker:
- Run the command
sudo yum install -y docker - Run the command
sudo systemctl start docker - Run the command
sudo kubeadm init --pod-network-cidr 10.244.0.0/16
Download and Configure Calico
- Run the command
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.18.1/manifests/calico.yaml
Add Worker Nodes
Add the worker nodes to your Kubernetes cluster:
- Run the command
kubectl get nodesto check the status of your worker nodes - Run the command
kubectl drain --delete-local-data --force --ignore-daemonsetsto drain the node of pods - Run the command
kubeadm join your-master-node-ip:8443 –discovery-token-ca-cert-hash sha256:discovery_token_hash_hereto add the worker node to the cluster
Verify your Kubernetes Cluster
Verify your Kubernetes cluster by checking the node status and running a simple application deployment:
Run the command
kubectl get nodesto check the status of your nodesRun the command
kubectl run -i --tty busybox --image=busybox --restart=Never -- /bin/shto run a busybox container
Conclusion
By following this guide, you have successfully set up a self-managed Kubernetes cluster on AWS in India. This setup allows you to manage your containerized applications with flexibility and scalability. Cpluz can provide further assistance and ensure seamless Kubernetes deployment and management for your applications.
Contact us at info@cpluz.com or visit cpluz.com for professional design and hosting solutions.
