
Hereβs a Terraform + Kubernetes setup to add monitoring and logging to your Graviton-based AWS EKS cluster using Prometheus & Grafana π
πΉ Step 1: Install helm
and kubectl
# Install Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
# Verify Helm installation
helm version
# Ensure `kubectl` is configured
aws eks --region us-east-1 update-kubeconfig --name graviton-eks-cluster
kubectl get nodes
πΉ Step 2: Deploy Prometheus & Grafana using Helm
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
# Install Prometheus stack
helm install prometheus-stack prometheus-community/kube-prometheus-stack --namespace monitoring --create-namespace
# Check status
kubectl get pods -n monitoring
πΉ Step 3: Expose Grafana for External Access
Create a LoadBalancer service for Grafana (grafana-service.yaml
):
apiVersion: v1
kind: Service
metadata:
name: grafana
namespace: monitoring
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: "alb"
spec:
selector:
app.kubernetes.io/name: grafana
ports:
- protocol: TCP
port: 80
targetPort: 3000
type: LoadBalancer
Apply the service:
kubectl apply -f grafana-service.yaml
Check the external URL:
kubectl get svc -n monitoring
Look for EXTERNAL-IP
under the grafana
service.
πΉ Step 4: Get Grafana Admin Password
kubectl get secret -n monitoring prometheus-stack-grafana -o jsonpath="{.data.admin-password}" | base64 --decode
Login to Grafana using:
- URL:
http://<EXTERNAL-IP>
- Username:
admin
- Password:
<output from command above>
πΉ Step 5: Configure Prometheus as a Data Source in Grafana
- Go to Grafana β Settings β Data Sources
- Add a new data source β Select Prometheus
- Enter URL:
http://prometheus-stack-kube-p-prometheus.monitoring.svc:9090
- Save & Test
πΉ Step 6: Import Kubernetes Dashboards
- Go to Grafana β Dashboards β Import
- Enter Dashboard ID:
3119
(Kubernetes Cluster Monitoring) - Click Load and select Prometheus as the data source
π Now you have a fully monitored Graviton-based Kubernetes cluster! π
Would you like to enable centralized logging with Loki & Fluentd? π