Search code examples
amazon-web-servicesazurekubernetesprometheusprometheus-operator

Using prometheus with volume to store data


We are using prometheus-operator with the for several month which working great. Now we need to add persistent volume to save the data for 3 month and we use the following.

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

I've added the following: (we have gp2 storage class)

storageSpec:
  volumeClaimTemplate:
    spec:
      storageClassName: gp2
      accessModes: ["ReadWriteOnce"]
      resources:
        requests:
          storage: 50Gi

https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/values.yaml#L1969

And I got error:

persistentvolumeclaim "prometheus-po-kube-prometheus-stack-prometheus-db-prometheus-po-kube-prometheus-stack-prometheus-0" not found,

should I add something in addition to the values.yaml?


Solution

  • You are missing components reference, you have to specify for which component you define storage - prometheus.prometheusSpec

    Try this:

    prometheus:
      prometheusSpec:
        storageSpec:
          volumeClaimTemplate:
            spec:
              accessModes: [ "ReadWriteOnce" ]
              resources:
                requests:
                  storage: 50Gi
              storageClassName: gp2
    

    You can find more in values.yaml