Skip to content

Instantly share code, notes, and snippets.

@surajmandalcell
Last active August 4, 2023 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surajmandalcell/3bfe1189442b55417fd00e837f80f38f to your computer and use it in GitHub Desktop.
Save surajmandalcell/3bfe1189442b55417fd00e837f80f38f to your computer and use it in GitHub Desktop.

AWS EKS Prometheus Grafana Demo by Suraj Mandal

Use these commands during the demo

Note Please make sure the eks kubernetes version you are using is 1.23 I had issues with the latest one(1.27)

Install aws cli

brew install awscli

Temporarily change editor (optional)

export EDITOR=nano

Edit aws lab config

subl ~/.aws/credentials

Then go to awsacademy account and copy the credentials to this file(replace all there is by default)

Connect to the cluster

aws eks --region us-west-2 update-kubeconfig --name eks1

Create a namespace

k create ns ns1

Set default namespace

k config set-context --current --namespace=ns1

Create a deployment

k apply -f file1.yaml
k apply -f file2.yaml

Create prometheus

k apply -f monitoring.yaml

Show prometheus stuff

k get all -n kube-system

DO the same for two deployments

k get pods -o wide -l app=app1
k get pods -o wide -l app=app2
k get nodes
k get pods -o wide
k get pods -o wide | grep <node-name>

Delete all in namespace command, DO NOT USE THIS, THIS IS JUST FO REFERANCE!!

k delete daemonsets,replicasets,services,deployments,pods,rc,ingress,statefulset --all -n prometheus

k delete clusterrole prometheus-kube-state-metrics prometheus-alertmanager prometheus-pushgateway prometheus-server system:prometheus

Do grafana and prometheus stuff

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

helm install my-kube-prometheus-stack prometheus-community/kube-prometheus-stack \
  --create-namespace --namespace prometheus \
  --set prometheus.service.type=LoadBalancer \
  --set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false \
  --set grafana.service.type=LoadBalancer \
  --set grafana.adminpassword=password


k get all -n prometheus

Open prometheus & grafana locally

k port-forward my-kube-prometheus-stack-grafana -n prometheus 4002:80
k port-forward svc/prometheus-operated -n prometheus 4001:9090

Edit prometheus config

k edit svc my-kube-prometheus-stack-prometheus -n prometheus

Change "port: 9090" to "port: 80" in http-web block

Get grafana password

k get secret my-kube-prometheus-stack-grafana -n prometheus -o jsonpath="{.data.admin-user}" | base64 --decode ; echo

k get secret my-kube-prometheus-stack-grafana -n prometheus -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment