Creating The Kubernetes Cluster On AWS EKS
This task is based on the Kubernetes service provided by AWS. The clients of AWS are provided with a service named as EKS(Elastic Kubernetes Services)
What is AWS?
AWS (Amazon Web Services) is a comprehensive, evolving cloud computing platform provided by Amazon that includes a mixture of infrastructure as a service (IaaS), platform as a service (PaaS) and packaged software as a service (SaaS) offerings. AWS services can offer an organization tools such as compute power, database storage and content delivery services.
What is Kubernetes(K8s)?
EKS stands for Elastic Kubernetes Service, which is an Amazon offering that helps in running the Kubernetes on AWS Cloud without requiring the user to maintain their own Kubernetes control plane. It is a fully managed service by Amazon. Amazon EKS runs Kubernetes control plane instances across multiple Availability Zones to ensure high availability. Amazon EKS automatically detects and replaces unhealthy control plane instances, and it provides automated version upgrades and patching for them. EKS creates master and slave nodes and set up entire Kubernetes cluster.
We can access EKS through WebUI (AWS console), CLI and Terraform. To access EKS through CLI we have 2 ways:
- using aws eks.
- using eksctl.
How does Amazon EKS works?
- First, create an Amazon EKS cluster in the AWS Management Console or with the AWS CLI or one of the AWS SDKs.
- Then, launch worker nodes that register with the Amazon EKS cluster. We provide you with an AWS CloudFormation template that automatically configures your nodes.
- When your cluster is ready, you can configure your favorite Kubernetes tools (such as kubectl) to communicate with your cluster.
- Deploy and manage applications on your Amazon EKS cluster the same way that you would with any other Kubernetes environment.
What is EKSCTL?
EKSCTL is a weave community slack command. EKSCTL is a simple CLI tool for creating clusters on EKS by just running a single command. It is a powerful program which gives us the power of customization.
What is Terraform?
Terraform is an open-source infrastructure as code software tool created by HashiCorp. It enables users to define and provision a datacenter infrastructure using a high-level configuration language known as Hashicorp Configuration Language, or optionally JSON.
👉Create a Kubernetes cluster using AWS EKS.
👉Integrate EKS with EC2, ELB, EBS, EFS.
👉Deploying WordPress & Mysql on top of AWS EKS.
- Install eksctl in your base os
- Install kubectl
- Install AWS CLI
After installing eksctl,kubectl and aws cli don’t forget to set the environment in your base os. Now we 1st configure our AWS.
For configuration provides your credentials and region where you want to launch your cluster. In my case, I am launching in ap-southeast-1
After configuration now we create the cluster where we launch our Kubernetes service. For launching the Kubernetes service we required one (.yml) file which contains the information of cluster.
for launching use following command:
eksctl create cluster -f cluster.yml
update your .kube config file
To see how many pods are running we use kubectl get pods cmd.
To see where your cluster is running we use kubectl cluster-info cmd.
Now we are here creating one separate namespace for our use.
Now we are going to launch/create one deployment where we put our PHP/HTML website.
you can scale it your pod by creating replicas.
Here our pod is running in private IP and we need to expose it then we connect to it from the outside world.so for that ppurpose we need to use expose cmd
fro running your your pod outside the network you need ip.so for getting of your pod you need to run
kubectl get service
Now use the load balancer address and put it into the web browser you will get the deployed web page.
In pods, the storage we use is a non-persistent type. It means everything we store inside will delete if any failure occurs. To make the storage permanent means persistent we mount one volume and this volume is typically known as EBS in aws. After mounting to the centralized storage out data become permanent.
here i have created mypvc.yml file for persistent storage
To create the PVC we use kubectl create -f mypvc.yml cmd.
To check the PV is created or not. For this, we use kubectl get pv.
step 2. Now Here we create the mix node group using the spot instance and deploy the WordPress and MySQL over it. For this, the services we use are ELB, EFS, EC2.
Here, I have created a mycluster.yml file that contains the instruction of the mixed node group which we are going to execute. In my case my key name ismykey1111.
Now run your mycluster.yml file using following command:
Now to check instance is launched or not we go to the Amazon console and check the ec2 instance dashboard manually by login to your AWS account.
Every time when you launch any or change anything in the cluster you need to update your Kube config file if the system.
Now we are login into all the ec2 instances with root account and install one software using yum install amazon-efs-utils cmd. Do this step for all the instances which we launch. For login, we use the above-highlighted cdm.
we are creating one EFS here. We create EFS Because EFS is centralized storage and whenever we do any changes from any region will also reflect in other associated regions. So if any client changes something from region 1a and if he/she again login with 1b region then he/she will get the same edited file.
Now select the create file system option. and select the VPC and change from default to highlighted VPC and also change the security group from default to clusterShareNodeSecurityGroup.
just click on next and you will create EFS easily.
Now time to provision our efs into our cluster. For this, we use kubectl create -f provisioner_name.yml cmd.
Now we create one RBAC which helps us to secure our namespace. From the outside world.
Now we create the 1 storage class efs. This storage class contacts the efs to provide the storage. And we create 1 pvc which creates PV and this PV contact the storage class and storage class provide the storage from efs.
for executing the kustomization we use kubectl create -k . (here dot represents the current folder) cmd.
copy the URL of the load balancer and put it into the web browser.
Finally, you will get wordpress site where yu have to enter your username and password for login to your wordpress site.
Thanks for Reading!!!!!!!
Snehal B. hingane
Under guidence of: vimal Daga sir and preeti mam