Prometheus & Grafana Installation Using Helm Chart
To install Prometheus without persistent volume storage, you can follow these steps. This setup is suitable for testing or small-scale deployments where data persistence is not a requirement.
Step 1: Create Namespace (Optional)
kubectl create namespace prometheus
Step 2: Create ConfigMap for Prometheus Configuration
Create a ConfigMap to store the Prometheus configuration:
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
data:
prometheus.yml: |
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
Apply the ConfigMap:
kubectl apply -f prometheus-config.yaml
Step 3: Deploy Prometheus
Use the official Prometheus Helm chart to deploy Prometheus:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus prometheus-community/prometheus --namespace prometheus --set alertmanager.persistentVolume.enabled=false --set server.persistentVolume.enabled=false --set pushgateway.persistentVolume.enabled=false --set alertmanager.enabled=false --set server.service.type=LoadBalancer --set server.service.port=80 --set server.service.nodePort=30900 --set server.serviceMonitor.enabled=true --set server.serviceMonitor.namespace=monitoring --set server.serviceMonitor.selector.matchLabels.release=prometheus --set server.serviceMonitor.selector.matchLabels.app=prometheus
This command installs Prometheus using the Helm chart from the Prometheus community repository. It disables persistent volume storage for Prometheus, Alertmanager, and Pushgateway components. It also configures Prometheus to expose a NodePort service on port 30900.
Step 4: Verify Installation
Check if Prometheus pods are running:
kubectl get pods -n prometheus
Check if Prometheus service is created and note the external IP:
kubectl get svc -n prometheus
Access Prometheus Web UI using the external IP and NodePort:
http://<EXTERNAL_IP>:<NODE_PORT>
Step 5: Cleanup (Optional)
If you want to uninstall Prometheus:
helm uninstall prometheus -n prometheus
kubectl delete namespace prometheus
This setup provides a basic installation of Prometheus without persistent volume storage. Adjust configurations as needed for your specific use case.
Grafana Install using Helm
Add helm repo
helm repo add grafana
https://grafana.github.io/helm-charts
Update helm repo
helm repo update
Install helm
helm install grafana grafana/grafana
Expose Grafana Service
Exposes a service named "grafana" as a NodePort service on a dynamically allocated port, targeting port 3000 of the Grafana pods. However, there's a small mistake in the syntax. Here's the corrected version:
kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana
Subscribe to my newsletter
Read articles from ANSAR SHAIK directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
ANSAR SHAIK
ANSAR SHAIK
AWS DevOps Engineer