Skip to content

Instantly share code, notes, and snippets.

@Warns
Last active May 25, 2023 10:52
Show Gist options
  • Save Warns/4e9845d2b70d370fbd82cfa02ec39b5c to your computer and use it in GitHub Desktop.
Save Warns/4e9845d2b70d370fbd82cfa02ec39b5c to your computer and use it in GitHub Desktop.
Install Prometheus and Grafana on Kubernetes cluster along with data source and persistent storage.

Installing Prometheus and Grafana

Add and update repos to fetch charts

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

Create monitoring namespace

kubectl create namespace monitoring

Install Prometheus service and define storage

helm install prometheus prometheus-community/prometheus \
--namespace monitoring \
--set alertmanager.persistentVolume.storageClass="standard" \
--set server.persistentVolume.storageClass="standard"

Create grafana.yaml

mkdir ${HOME}/environment/grafana

cat << EoF > ${HOME}/environment/grafana/grafana.yaml
datasources:
  datasources.yaml:
    apiVersion: 1
    datasources:
    - name: Prometheus
      type: prometheus
      url: http://prometheus-server.monitoring.svc.cluster.local
      access: proxy
      isDefault: true
EoF

Install grafana and allocate storage and user pass

helm install grafana grafana/grafana \
    --namespace monitoring \
    --set persistence.storageClassName="standard" \
    --set persistence.enabled=true \
    --set adminPassword='subje' \
    --values ${HOME}/Documents/monitoring/grafana.yaml \
    --set service.type=LoadBalancer

Import a predefined template within Grafana:

For example template ID: 6417 https://grafana.com/grafana/dashboards/6417

@Warns
Copy link
Author

Warns commented Oct 3, 2021

@prashantkalwani1 indeed if you want to point out to default it should either be set to standard or left out as an empty string to select the default which is standard. Thanks for bringing this up, I updated it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment