Step 1.1 – Create the IAM role having full access
Go to IAM -> Create role -> Select EC2 -> Give Full admin access
Step 1.2 – Attach the IAM role having full access
Go to EC2 -> Click on Actions on the left hands ide -> Security -> Modify IAM role
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo apt install unzip
unzip awscliv2.zip
sudo ./aws/install
sudo apt update
sudo apt install curl -y
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
kubectl version
kubectl version --short
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl version
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm version
-
Name of the cluster: --eks2
-
Version of Kubernetes: --version1.24
-
Region: --region us-east-1
-
Nodegroupname/workernodes: --nodegroup-nameworker-nodes
-
NodeType: -- nodegroup-typet2.medium
-
Numberofnodes: --nodes2
-
MinimumNumberofnodes: --nodes-min2
-
MaximumNumberofnodes: --nodes-max3
eksctl create cluster --name monitor --version 1.24 --region ap-south-1 --nodegroup-name worker-nodes --node-type t2.medium --nodes 2 --nodes-min 2 --nodes-max 3
aws eks update-kubeconfig --region <region-code> --name <cluster-name>
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
Step 7.1 - Verify that the metrics-server deployment is running the desired number of pods with the following command
kubectl get deployment metrics-server -n kube-system
Now install the Prometheus using the helm chart. Add Prometheus helm chart repository
helm repo add prometheus-community
https://prometheus-community.github.io/helm-charts
helm repo update
helm repo list
kubectl create namespace prometheus
helm install prometheus prometheus-community/prometheus --namespaceprometheus --set alertmanager.persistentVolume.storageClass="gp2" --set
server.persistentVolume.storageClass="gp2"
Your cluster has an Open IDConnect(OIDC) issuer URL associated with it. To use AWS Identity and Access Management (IAM) roles for service accounts, an IAMOIDC provider must exist for your cluster's OIDC issuer URL.
oidc_id=$(aws eks describe-cluster --name moniter --region ap-south-1 --query "cluster.identity.oidc.issuer" --output text | cut -d '/' -f 5)
aws iam list-open-id-connect-providers | grep $oidc_id | cut -d "/" -f4
eksctl utils associate-iam-oidc-provider --cluster moniter --approve --region ap-south-1
eksctl create iamserviceaccount --name ebs-csi-controller-sa --namespace kube-system --cluster monitor --attach-policy-arn arn:aws:iam::aws:policy/service-
role/AmazonEBSCSIDriverPolicy --approve --role-only --role-name AmazonEKS_EBS_CSI_DriverRole --region ap-south-1
Enter your account ID and cluster name.
eksctl create addon --name aws-ebs-csi-driver --cluster monitor1 --service-account-role-arn arn:aws:iam::141936385254:role/AmazonEKS_EBS_CSI_DriverRole --force --region ap-south-1
kubectl port-forward deployment/prometheus-server9090:9090 -n prometheus
curl localhost:9090/graph
helm repo add grafana
https://grafana.github.io/helm-chart
helm repo update
kubectl create namespace grafana
helm install grafana grafana/grafana --namespacegrafana --setpersistence.storageClassName="gp2" --setpersistence.enabled=true --setadminPassword='EKS!sAWSome' --
setservice.type=LoadBalancer
This command will create the Grafana service with an external load balancer to get the public view.
kubectl get pods -n grafana
kubectl get service -n grafana
Password you mentioned as EKS!sAWSome while creating Grafana
Go to Grafana Dashboard -> Add the Data source -> Select the Prometheus
URL- http://prometheus-server.prometheus.svc.cluster.local
Now we have setup everything in terms of Prometheus and Grafana. For the custom Grafana Dashboard, we are going to use the open source grafana dashboard. For this session, Iam going to import a dashboard 6417
Go to left side -> click on dashboards -> Click on New -> Import
Load and select the source as Prometheus
git clone https://github.com/tohidhanfi20/kubernetes_java_deployment
cd /kubernetes_java_deployment/Kubernetes/
kubectl apply -f shopfront-service.yaml
kubectl get deployment
kubectl get pods
eksctl delete cluster --nameeks2 --region ap-south-1