Hands-On: Deploying Prometheus on Kubernetes

Hands-On: Deploying Prometheus on Kubernetes

ยท

2 min read

Follow these steps to deploy Prometheus in an Amazon EKS cluster using the kube-prometheus-stack Helm chart.

Step 1: Create an EKS Cluster

Prerequisites

Commands to Create the Cluster

eksctl create cluster --name observability \
                      --region us-east-1 \
                      --zones us-east-1a,us-east-1b \
                      --without-nodegroup
eksctl utils associate-iam-oidc-provider \
    --region us-east-1 \
    --cluster observability \
    --approve
eksctl create nodegroup --cluster observability \
                        --region us-east-1 \
                        --name observability-ng-private \
                        --node-type t3.medium \
                        --nodes-min 2 \
                        --nodes-max 3 \
                        --node-volume-size 20 \
                        --managed \
                        --node-private-networking

Update your kubeconfig file to interact with the cluster:

aws eks update-kubeconfig --name observability

Step 2: Install Kube-Prometheus-Stack

Add the Prometheus Helm chart repository:

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

Create a dedicated namespace for monitoring:

kubectl create ns monitoring

Install the Helm chart:

helm install monitoring prometheus-community/kube-prometheus-stack \
-n monitoring \
-f ./custom_kube_prometheus_stack.yml

Step 3: Verify the Installation

Check if the resources are running:

kubectl get all -n monitoring

Access Prometheus UI

Forward Prometheus service to your local machine:

kubectl port-forward service/prometheus-operated -n monitoring 9090:9090

Visit http://localhost:9090.

Access Grafana UI

Grafana credentials: username admin, password prom-operator.

kubectl port-forward service/monitoring-grafana -n monitoring 8080:80

Visit http://localhost:8080.

Alertmanager UI:

kubectl port-forward service/alertmanager-operated -n monitoring 9093:9093

Visit http://localhost:9093


Step 4: Cleanup

To remove the setup:

  • Uninstall the Helm chart:
helm uninstall monitoring -n monitoring
  • Delete the namespace:
kubectl delete ns monitoring
  • Delete the EKS cluster:
eksctl delete cluster --name observability

Conclusion

Prometheus is a powerful tool for monitoring modern cloud-native systems, offering flexibility and integration with dynamic environments like Kubernetes. With Grafana, you can create stunning visualizations and dashboards to keep your infrastructure healthy and performant.

By following the steps in this blog, you now have a hands-on understanding of how to deploy and manage Prometheus on EKS. Monitoring your applications has never been easier!

ย