Table of Contents


Prerequisites

Before you begin, ensure the following are in place:

  • Kubernetes cluster (v1.23+) with kubectl access
  • Helm (v3.8+) — Install Helm
  • Prometheus already deployed (see prometheus-helm-install.md)
  • Sufficient cluster resources (recommended: 1 CPU core, 512 MB RAM minimum)

Verify your tools:

kubectl version --client
helm version
kubectl cluster-info

1. Add the Grafana Helm Repository

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

Verify the repo was added:

helm search repo grafana/grafana

2. Create a Namespace

If you are deploying Grafana alongside Prometheus, reuse the same namespace:

kubectl create namespace monitoring
# Skip if 'monitoring' already exists

3. Install Grafana with Default Values

For a quick installation with defaults:

helm install grafana grafana/grafana \
  --namespace monitoring

4. Custom Configuration via values.yaml

Pull the default values first:

helm show values grafana/grafana > grafana-values.yaml

Key Configuration Sections

4.1 Admin Credentials

⚠️ Never hardcode passwords in values.yaml committed to version control. Use a Kubernetes Secret instead (see section 4.2).

adminUser: admin
adminPassword: "your-secure-password"   # For dev/testing only

Create the secret manually:

kubectl create secret generic grafana-admin-secret \
  --from-literal=admin-user=admin \
  --from-literal=admin-password=your-secure-password \
  --namespace monitoring

Then reference it in values.yaml:

admin:
  existingSecret: grafana-admin-secret
  userKey: admin-user
  passwordKey: admin-password

4.3 Resource Limits

resources:
  limits:
    cpu: 500m
    memory: 512Mi
  requests:
    cpu: 250m
    memory: 256Mi

4.4 Persistent Storage

persistence:
  enabled: true
  type: pvc
  size: 10Gi
  storageClassName: "standard"   # Replace with your StorageClass
  accessModes:
    - ReadWriteOnce

4.5 Replica Count

replicas: 1
# For HA, set replicas > 1 and configure a shared database backend

4.6 Configure Prometheus as a Data Source

This is the most important integration step. Grafana can auto-provision data sources on startup:

datasources:
  datasources.yaml:
    apiVersion: 1
    datasources:
      - name: Prometheus
        type: prometheus
        url: http://prometheus-server.monitoring.svc.cluster.local:80
        access: proxy
        isDefault: true
        jsonData:
          timeInterval: "15s"
          httpMethod: POST

Tip: The URL http://prometheus-server.monitoring.svc.cluster.local:80 follows the pattern http://<helm-release-name>-server.<namespace>.svc.cluster.local:80. Adjust if your Prometheus release name or namespace differs.

4.7 Auto-provision Dashboards

You can pre-load community dashboards from grafana.com/dashboards by their ID:

dashboardProviders:
  dashboardproviders.yaml:
    apiVersion: 1
    providers:
      - name: 'default'
        orgId: 1
        folder: ''
        type: file
        disableDeletion: false
        editable: true
        options:
          path: /var/lib/grafana/dashboards/default
 
dashboards:
  default:
    # Kubernetes cluster overview — Dashboard ID 7249
    kubernetes-cluster:
      gnetId: 7249
      revision: 1
      datasource: Prometheus
 
    # Node Exporter full — Dashboard ID 1860
    node-exporter:
      gnetId: 1860
      revision: 37
      datasource: Prometheus
 
    # Prometheus stats — Dashboard ID 2
    prometheus-stats:
      gnetId: 2
      revision: 2
      datasource: Prometheus

4.8 SMTP / Email Alerting

grafana.ini:
  smtp:
    enabled: true
    host: smtp.example.com:587
    user: grafana@example.com
    password: "smtp-password"
    from_address: grafana@example.com
    from_name: Grafana
    startTLS_policy: MandatoryStartTLS

4.9 Authentication (OAuth / OIDC)

Example for GitHub OAuth:

grafana.ini:
  auth.github:
    enabled: true
    allow_sign_up: true
    client_id: YOUR_GITHUB_CLIENT_ID
    client_secret: YOUR_GITHUB_CLIENT_SECRET
    scopes: user:email,read:org
    auth_url: https://github.com/login/oauth/authorize
    token_url: https://github.com/login/oauth/access_token
    api_url: https://api.github.com/user
    allowed_organizations: your-github-org

4.10 Ingress (Optional)

ingress:
  enabled: true
  ingressClassName: nginx
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    cert-manager.io/cluster-issuer: letsencrypt-prod   # If using cert-manager
  hosts:
    - grafana.example.com
  paths:
    - /
  tls:
    - secretName: grafana-tls
      hosts:
        - grafana.example.com

4.11 Grafana Plugins

Install plugins at startup:

plugins:
  - grafana-clock-panel
  - grafana-piechart-panel
  - grafana-worldmap-panel
  - vonage-status-panel

5. Install with Custom Values

helm install grafana grafana/grafana \
  --namespace monitoring \
  --values grafana-values.yaml

Or override individual values inline:

helm install grafana grafana/grafana \
  --namespace monitoring \
  --set persistence.enabled=true \
  --set persistence.size=10Gi \
  --set adminPassword=your-secure-password

6. Verify the Deployment

Check that the pod is running:

kubectl get pods -n monitoring -l app.kubernetes.io/name=grafana

Expected output:

NAME                       READY   STATUS    RESTARTS   AGE
grafana-6d9b8c8f7d-xxxxx   1/1     Running   0          1m

Check the service:

kubectl get svc -n monitoring -l app.kubernetes.io/name=grafana

7. Access the Grafana UI

If you did not configure an Ingress, use port-forwarding:

kubectl port-forward -n monitoring svc/grafana 3000:80

Then open your browser at: http://localhost:3000

Log in with:

  • Username: admin
  • Password: retrieved via the command below (if not set explicitly)
kubectl get secret --namespace monitoring grafana \
  -o jsonpath="{.data.admin-password}" | base64 --decode; echo

8. Upgrading Grafana

helm upgrade grafana grafana/grafana \
  --namespace monitoring \
  --values grafana-values.yaml

To upgrade to a specific chart version:

helm upgrade grafana grafana/grafana \
  --namespace monitoring \
  --values grafana-values.yaml \
  --version 7.3.9

9. Uninstalling Grafana

helm uninstall grafana --namespace monitoring

⚠️ Note: This does not delete PersistentVolumeClaims (PVCs). Delete them manually if needed:

kubectl delete pvc -n monitoring -l app.kubernetes.io/name=grafana

10. Common Troubleshooting

Pod not starting

kubectl describe pod -n monitoring -l app.kubernetes.io/name=grafana
kubectl logs -n monitoring -l app.kubernetes.io/name=grafana

Cannot connect to Prometheus data source

Inside the Grafana UI go to Connections → Data Sources → Prometheus and click Save & Test. Common causes:

  • Wrong service URL — verify with:
    kubectl get svc -n monitoring
  • Prometheus pod not running — check kubectl get pods -n monitoring
  • Network policy blocking traffic between namespaces

Dashboards not loading after provisioning

kubectl logs -n monitoring -l app.kubernetes.io/name=grafana | grep dashboard

Ensure the dashboardProviders path matches the options.path in your provider config.

Forgotten admin password

Reset it by exec-ing into the pod:

kubectl exec -it -n monitoring \
  $(kubectl get pod -n monitoring -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}') \
  -- grafana-cli admin reset-admin-password new-password

Check the Helm release status

helm status grafana -n monitoring
helm get values grafana -n monitoring

11. Complete values.yaml Example

A minimal but production-ready configuration combining all of the above:

replicas: 1
 
admin:
  existingSecret: grafana-admin-secret
  userKey: admin-user
  passwordKey: admin-password
 
resources:
  limits:
    cpu: 500m
    memory: 512Mi
  requests:
    cpu: 250m
    memory: 256Mi
 
persistence:
  enabled: true
  size: 10Gi
  storageClassName: "standard"
 
datasources:
  datasources.yaml:
    apiVersion: 1
    datasources:
      - name: Prometheus
        type: prometheus
        url: http://prometheus-server.monitoring.svc.cluster.local:80
        access: proxy
        isDefault: true
 
dashboardProviders:
  dashboardproviders.yaml:
    apiVersion: 1
    providers:
      - name: 'default'
        orgId: 1
        folder: ''
        type: file
        disableDeletion: false
        editable: true
        options:
          path: /var/lib/grafana/dashboards/default
 
dashboards:
  default:
    kubernetes-cluster:
      gnetId: 7249
      revision: 1
      datasource: Prometheus
    node-exporter:
      gnetId: 1860
      revision: 37
      datasource: Prometheus
 
plugins:
  - grafana-clock-panel
  - grafana-piechart-panel
 
ingress:
  enabled: false   # Set to true and configure hosts/tls for production

12. Useful References