Kubernetes Installation
This guide covers deploying Grafana on Kubernetes using Kubernetes manifests or Helm charts.Before You Begin
Ensure you have:- A Kubernetes cluster (local or cloud-based)
- Local: minikube, kind, or Docker Desktop
- Cloud: GKE, EKS, or AKS
kubectlCLI configured to access your cluster- For Helm installation: Helm 3.x installed
System Requirements
Minimum hardware requirements per pod:- CPU: 250m (0.25 cores)
- Memory: 750 MiB
- Disk: 1 GB persistent storage
Ensure port 3000 is accessible in your network environment.
Installation with Kubernetes Manifests
Deploy Grafana using native Kubernetes manifests for full control over the deployment.---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: grafana-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: grafana
name: grafana
spec:
selector:
matchLabels:
app: grafana
template:
metadata:
labels:
app: grafana
spec:
securityContext:
fsGroup: 472
supplementalGroups:
- 0
containers:
- name: grafana
image: grafana/grafana:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3000
name: http-grafana
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /robots.txt
port: 3000
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 2
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 3000
timeoutSeconds: 1
resources:
requests:
cpu: 250m
memory: 750Mi
volumeMounts:
- mountPath: /var/lib/grafana
name: grafana-pv
volumes:
- name: grafana-pv
persistentVolumeClaim:
claimName: grafana-pvc
---
apiVersion: v1
kind: Service
metadata:
name: grafana
spec:
ports:
- port: 3000
protocol: TCP
targetPort: http-grafana
selector:
app: grafana
sessionAffinity: None
type: LoadBalancer
For cloud providers with LoadBalancer support, find the EXTERNAL-IP and access Grafana at
http://<EXTERNAL-IP>:3000.Installation with Helm
Helm simplifies Kubernetes deployments using packaged charts.kubectl get secret --namespace monitoring my-grafana \
-o jsonpath="{.data.admin-password}" | base64 --decode ; echo
export POD_NAME=$(kubectl get pods --namespace monitoring \
-l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=my-grafana" \
-o jsonpath="{.items[0].metadata.name}")
kubectl --namespace monitoring port-forward $POD_NAME 3000
Helm Configuration
Enable Persistent Storage
Create or download thevalues.yaml file from the Grafana Helm Charts repository.
Edit values.yaml to enable persistence:
Install Plugins
Add plugins tovalues.yaml:
Custom Admin Password
Set a custom admin password invalues.yaml:
Deploy Grafana Enterprise
To deploy Grafana Enterprise on Kubernetes:kubectl create secret generic ge-license \
--from-file=/path/to/your/license.jwt \
--namespace=my-grafana
[enterprise]
license_path = /etc/grafana/license/license.jwt
[server]
root_url = /your/license/root/url
kubectl create configmap ge-config \
--from-file=/path/to/your/grafana.ini \
--namespace=my-grafana
containers:
- image: grafana/grafana-enterprise:latest
name: grafana
volumeMounts:
- mountPath: /var/lib/grafana
name: grafana-pv
- mountPath: /etc/grafana
name: ge-config
- mountPath: /etc/grafana/license
name: ge-license
volumes:
- name: grafana-pv
persistentVolumeClaim:
claimName: grafana-pvc
- name: ge-config
configMap:
name: ge-config
- name: ge-license
secret:
secretName: ge-license
Update Deployment
Perform rolling updates to change the Grafana version:Rollback Deployment
View rollout history:Troubleshooting
View logs
Enable debug logging
Create a ConfigMap with custom configuration:Cleanup
Remove the Grafana deployment:Next Steps
- Configure data sources using provisioning
- Set up persistent storage for production
- Configure high availability with multiple replicas
- Integrate with ingress controllers for external access