Categories
Kubernetes

Kubernetes: Install Grafana and Prometheus on GKE using helm

Updated: September 23, 2020

https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack

Add Repo

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm repo update

Create custom-values.yaml

GKE uses kubeDNS by default, so I enabled it. I created persistent disks and added an Internal Load Balancer by adding a google specific annotation.

cat <<EOF > custom-values.yaml
coreDns:
  enabled: false

kubeDns:
  enabled: true

prometheusOperator:
  createCustomResource: false

alertmanager:
  alertmanagerSpec:
    storage:
      volumeClaimTemplate:
        spec:
          accessModes: ["ReadWriteOnce"]
          resources:
            requests:
              storage: 200Gi

prometheus:
  prometheusSpec:
    storageSpec:
      volumeClaimTemplate:
        spec:
          accessModes: ["ReadWriteOnce"]
          resources:
            requests:
              storage: 200Gi

grafana:
  service:
    type: LoadBalancer
    annotations:
      cloud.google.com/load-balancer-type: "Internal"
  persistence:
    enabled: true
    accessModes: ["ReadWriteOnce"]
    size: 200Gi
EOF

Install

helm install grafana-prometheus \
  -n monitoring \
  -f custom-values.yaml \
  prometheus-community/kube-prometheus-stack

Access

# Grafana
kubectl port-forward service/grafana-prometheus 3000:80 -n monitoring
open http://localhost:3000/
un: admin
pw: prom-operator

# Prometheus
kubectl port-forward service/grafana-prometheus-prometh-prometheus 9090 -n monitoring
open http://localhost:9090/graph
open http://localhost:9090/alerts

# Alert Manager
kubectl port-forward service/grafana-prometheus-prometh-alertmanager 9093 -n monitoring
open http://localhost:9093/

# Metrics
kubectl port-forward service/grafana-prometheus-kube-state-metrics 3001:8080 -n monitoring
open http://localhost:3001/

Comments

By Tommy Elmesewdy

DevOps Engineer