Gupta Aditya
6 min readJan 11, 2023

Hi guys Today we are going to see how Eks work and how can we launch our own Kubernetes cluster in just a few clicks on aws.

  • Prerequisite aws account, basic knowledge of how Kubernetes work, basics of aws.
  • So first of all create the IAM role on aws with admin access and configure aws cli we are going to launch all the things using aws cli we can launch with help of GUI also but GUI is not accessible all the time so its good to practice from cli.
  • Once IAM is created and aws cli is configured download kubectl from the below link (https://kubernetes.io/docs/tasks/tools/install-kubectl/) and eksctl(https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html) once this is download make sure to add them in environment variable so that it can be accessed from anywhere and once it’s done we are all set to launch our own Kubernetes cluster.
  • First clone the below git repo files and open cluster.YAML file and there you can change things according to your need such as cluster name and there is one term called node group in which we have to give information of the type of node we want here I use t2.micro because they are free you can set ng according to you need to Remember that eks is not free you have to pay something check pricing before doing anything once you cluster file is ready to save it and close it.
  • run the following command (“eksctl create cluster -f filename”) its time to take grab a coffee :) it will take around 10 to 15 min.
  • Now we have to make or upgrade the Kube-config file so for that just run the following command (“aws eks update-kubeconfig — name cluster name”).
  • Once this is done now we are all set to use k8s as it is we use in our own cluster or in minikube today in k8s we are going to launch WordPress and MySQL and we have designed this in such a way that DB will not expose to anyone means it will use internal IP and wp is work as the front end so that will be using load balancer service and guys here they use ELB service of AWS for load balancing and for storage they by default use EBS but you can launch on EFS so that all node save data to one place.
  • For running this setup you have to run the following command (“kubectl create -k .) here we are saying Kubernetes to run kuztamization.yml file its one file which contains secrets for database and here we set which file to run and we never want that first our WordPress is created and then Mysql what we want is fist MySQL DB is created and then WordPress deploy on it so kuztamization file will take care of it.
  • Once pod is deployed you can see service by(“ kubectl get svc”) and take the domain of WordPress and can see your WordPress site.
  • Here you can also use Helm to install helm run following cmnd:-
  • (“helm repo add stable https://kubernetes-charts.storage.googleapis.com/
  • helm repo list
  • helm repo update)
  • Once this is done we have to set tiller run the following cmnd:-
  • -(“kubectl -n Kube-system create service account tiller

kubectl create clusterrolebinding tiller — clusterrole cluster-admin — serviceaccount=kube-system:tiller

helm init — service-account tiller

kubectl get pods — namespace Kube-system

helm init — service-account tiller — upgrade”)

  • In my previous article, I have shown how to launch Prometheus and grafana from the YAML file if not see chek this out https://www.linkedin.com/pulse/prometheus-grafana-on-kubernetes-aditya-gupta.
  • Today we are going to use helm package to launch Prometheus and grafana to do so run the following commands.
  • For Prometheus run following command (“ kubectl create namespace prometheus

helm install stable/prometheus — namespace prometheus — set alertmanager.persistentVolume.storageClass=”gp2" — set server.persistentVolume.storageClass=”gp2"

kubectl get svc -n prometheus

kubectl -n prometheus port-forward svc/whimsical-markhor-prometheus-server 8888:80").

  • For grafana run following command (“kubectl create namespace grafana

helm install stable/grafana — namespace grafana — set persistence.storageClassName=”gp2" — set adminPassword=’GrafanaAdm!n’ — set datasources.”datasources.yaml”.apiVersion=1 — set datasources.”datasources.yaml”.datasources[0].name=Prometheus — set datasources.”datasources.yaml”.datasources[0].type=prometheus — set datasources.”datasources.yaml”.datasources[0].url=http://prometheus-server.prometheus.svc.cluster.local — set datasources.”datasources.yaml”.datasources[0].access=proxy — set datasources.”datasources.yaml”.datasources[0].isDefault=true — set service.type=LoadBalancer

kubectl get secret fair-numbat-grafana — namespace grafana -o yaml”)

  • This is how you can launch launch prometheus and grafana using helm and you can also lauch jenkins service on k8s same as i discuss this in my article https://www.linkedin.com/pulse/jenkins-on-kubernetes-aditya-gupta.
  • Now we have seen there is one manual thing that we have to do is setting node groups we sometimes don’t have much knowledge which node is required when or sometime we need more from that we plan so for that there is one service called fargat cluster and it will handle all the things by himself even node also controlled by this service only thing you have to create fargat cluster and you are done rest other things will be taken care by fargat service ( this service is sub-service of ECS in aws).
  • To launch fargat cluster open fcluster .yml file and then you can set the name of cluster and namespace you want to use and once done save it and close it once this is done we are ready to launch fargat cluster run the following command(“eksctl create cluster -f filename) o it will take time to launch the cluster you can check cluster is created or not by (“eksctl get cluster — region you region”)
  • once fargat cluster is created now we have to update Kube config for that run the following command (“ aws eks — region your region update-kubeconfig — name cluster name “) after this you can use kubectl get nodes to check nodes launched by fargat cluster internally.

Github repo