Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akshayithape-devops/5f9b6206f77757fd7343d68cabd48cbd to your computer and use it in GitHub Desktop.
Save akshayithape-devops/5f9b6206f77757fd7343d68cabd48cbd to your computer and use it in GitHub Desktop.
๐—ž8๐˜€ ๐—–๐—น๐˜‚๐˜€๐˜๐—ฒ๐—ฟ(EKS) ๐— ๐—ผ๐—ป๐—ถ๐˜๐—ผ๐—ฟ๐—ถ๐—ป๐—ด ๐˜‚๐˜€๐—ถ๐—ป๐—ด ๐—ฃ๐—ฟ๐—ผ๐—บ๐—ฒ๐˜๐—ต๐—ฒ๐˜‚๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—š๐—ฟ๐—ฎ๐—ณ๐—ฎ๐—ป๐—ฎ

๐—ž8๐˜€ ๐—–๐—น๐˜‚๐˜€๐˜๐—ฒ๐—ฟ(EKS) ๐— ๐—ผ๐—ป๐—ถ๐˜๐—ผ๐—ฟ๐—ถ๐—ป๐—ด ๐˜‚๐˜€๐—ถ๐—ป๐—ด ๐—ฃ๐—ฟ๐—ผ๐—บ๐—ฒ๐˜๐—ต๐—ฒ๐˜‚๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—š๐—ฟ๐—ฎ๐—ณ๐—ฎ๐—ป๐—ฎ

Prerequisites

  1. An AWS Account
  2. IAM credentials and programmatic access.
  3. AWS credentials that are set up locally with aws configure.
  4. Ubuntu 22.04 LTS

Steps

Step - #01 : Install and Setup kubectl on Ubuntu

Installing and setting up kubectl configures the command-line interface essential for managing Kubernetes clusters

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

kubectl version --client

Step - #02 : Install and Setup eksctl on Ubuntu

Installing and setting up eksctl simplifies the process of creating and managing Amazon EKS clusters with its command-line utility.

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

Step - #03 : Install Helm Chart on Ubuntu

Installing Helm Charts involves deploying pre-configured packages onto Kubernetes clusters.

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

Step - #04 : Creating an Amazon EKS Cluster using eksctl

Creating an Amazon EKS Cluster using eksctl streamlines the process of setting up and managing Kubernetes clusters on AWS. It provides a simplified command-line interface for creating EKS clusters with predefined configurations, ensuring efficient cluster deployment.

eksctl create cluster --name=eks-monitoring-demo --region=us-east-1 --version=1.29 --nodegroup-name=my-nodes --node-type=t3.medium --managed --nodes=2 --nodes-min=2 --nodes-max=3 --profile=akshay-test

Kindly note that it would take 15โ€“20 minutes for this installation to complete.

eksctl get cluster --name=eks-monitoring-demo --region=us-east-1 --profile=akshay-test

This should confirm that EKS cluster is up and running.

Update Kube config by entering below command:

aws eks update-kubeconfig --name=eks-monitoring-demo --region=us-east-1 --profile=akshay-test

Connect to EKS cluster using kubectl commands

To view the list of worker nodes as part of EKS cluster.

kubectl get nodes
kubectl get ns

Step - #05 : Add Helm Stable Charts for Your Local Client

We need to add the Helm Stable Charts for your local client.

helm repo add stable https://charts.helm.sh/stable

Step - #06 : Add Prometheus Helm Repository

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

Step - #07 : Create Prometheus Namespace

kubectl create namespace prometheus

kubectl get ns

Step - #08 : Install Prometheus using Helm

Using below command, We install kube-Prometheus-stack. The helm repo kube-stack-Prometheus comes with a Grafana deployment embedded ( as the default one ).

helm install stable prometheus-community/kube-prometheus-stack -n prometheus

kubectl get pods -n prometheus

kubectl get svc -n prometheus

Step - #09 : Expose Prometheus to the external world

Using LoadBalancer Service

kubectl edit svc stable-kube-prometheus-sta-prometheus -n prometheus

change it from Cluster IP to LoadBalancer after changing make sure you save the file

kubectl get svc -n prometheus

A load balancer has been provisioned for Prometheus, allowing access via the link provided on port 9090.

Step - #10 : Expose Grafana to the external world

Using LoadBalancer Service

kubectl edit svc stable-grafana -n prometheus

change it from Cluster IP to LoadBalancer after changing make sure you save the file

kubectl get svc -n prometheus

use the link of the LoadBalancer of grafana and access from the Browser

Grafana user is Admin and to get the grafana password run below commandm,

kubectl get secret --namespace prometheus stable-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

Step - #11 : Clean up/Deprovision-Deleting the Cluster

Now we will delete all our resources.

eksctl delete cluster --name=eks-monitoring-demo --profile=akshay-test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment