상세 컨텐츠

본문 제목

Persisting Grafana and Prometheus Configuration Data - Kubernetes

본문

If you install Grafana in Kubernetes, you may see that the config data in Grafana may be reset (such as admin password and dashboard configuration) when Grafana pod resets.  This is because you have not set up a persistent disk attached to the Grafana during the installation.  
 
I will go over the steps to add a persistent disk to the Grafana during the installation.
 

728x90

Prerequisites

  • Kubenetes environment
  • Install kubernetes-helm

1. Install "nginx ingress controller"

If you use the command below, it will install the controller in "ingress-nginx" namespace.  This takes an important role in the SSL integration (next article).

helm upgrade ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx --namespace ingress-nginx --create-namespace --set controller.metrics.enabled=true --set-string controller.podAnnotations."prometheus\.io/scrape"="true" --set-string controller.podAnnotations."prometheus\.io/port"="10254"

2. Add Prometheus and Grafana helm repo's for installation later

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

 

반응형

3. Add a namespace

The command below will add a new namespace, "monitoring".

kubectl create namespace monitoring

4. Install Prometheus with a Persistent Volume

The command below will install Prometheus with a persistent volume called "default" in the "monitoring" namespace.

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

5. Install Grafana with a Persistent Volume and Set Admin Password

The command below will install Grafana with a persistent volume called "default" in the "monitoring" namespace.  Also, this command will set the admin password.

helm install grafana grafana/grafana --namespace monitoring --set persistence.storageClassName="default" --set persistence.enabled=true --set adminPassword='<new admin password, without brackets>'

 


That's it.  You have aded a persistent disk volume in Grafana.  Try resetting the pod and it will persist the new admin password.


 

728x90
반응형

관련글 더보기