kube-prometheus-stack is using as EmptyDir as storage even after specifying VolumeClaimTemplate

12/12/2020

I'm trying to install kube-prometheus-stack using helm and trying to use persistent volume with hospath even after specifying VolumeClaimTemplate the emptyDir is getting created is storage type.

These are steps i followed:

  1. Created a PV
kind: PersistentVolume
metadata:
  name: prometheus-pv
  labels:
    app: prometheus
spec:
  capacity:
    storage: 50Gi
  hostPath:
    path: /data/prometheus/pv4
    type: ''
  accessModes:
    - ReadWriteOnce
  1. Modified default Values file in storage section :
    resources: {}
    # requests:
    #   memory: 400Mi

    ## Prometheus StorageSpec for persistent data
    ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/user-guides/storage.md
    ##
    storageSpec:
    ## Using PersistentVolumeClaim
    ##
    volumeClaimTemplate:
      spec:
        storageClassName: ""
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 50Gi
      selector:
          matchLabels:
            app: prometheus
  1. Installed kube-prometheus-stack using helm
helm install  --values Prometheus.yaml promethes  prometheus-community/kube-prometheus-stack --namespace prometheusstack
  1. Deployment is successful but the storage is created as emptyDir pod storage snippet
spec:
  volumes:
    - name: config
      secret:
        secretName: prometheus-promethes-kube-prometheus-prometheus
        defaultMode: 420
    - name: tls-assets
      secret:
        secretName: prometheus-promethes-kube-prometheus-prometheus-tls-assets
        defaultMode: 420
    - name: config-out
      emptyDir: {}
    - name: prometheus-promethes-kube-prometheus-prometheus-rulefiles-0
      configMap:
        name: prometheus-promethes-kube-prometheus-prometheus-rulefiles-0
        defaultMode: 420
    - name: prometheus-promethes-kube-prometheus-prometheus-db
      emptyDir: {}
    - name: promethes-kube-prometheus-prometheus-token-nwwxv
      secret:
        secretName: promethes-kube-prometheus-prometheus-token-nwwxv
        defaultMode: 420
-- Santhosh reddy
kubernetes
kubernetes-helm
prometheus-operator

1 Answer

12/13/2020

You missing identation. The correct values should be:

    storageSpec:
      ## Using PersistentVolumeClaim
      ##
      volumeClaimTemplate:
        spec:
          storageClassName: ""
          accessModes: ["ReadWriteOnce"]
          resources:
            requests:
              storage: 50Gi
        selector:
          matchLabels:
            app: prometheus
-- Shai Katz
Source: StackOverflow