'helm install prometheus pvc not able to claim from pv

I created 2 pv on a usb drive with:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: prometheus-alertmanager
spec:
  capacity:
    storage: 4Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  storageClassName: prometheus-alertmanager
  hostPath:
    path: /mnt/tinkerext/Prometheus
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: prometheus-server
spec:
  capacity:
    storage: 14Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  storageClassName: prometheus-server
  hostPath:
    path: /mnt/tinkerext/Prometheus
---

after that, i tried to use helm to install prometheus in the default namespace with helm install prometheus prometheus-community/prometheus --version 15.5.4 as mentioned in helm prometheus

immediately after a successful install, i am met with issues with prometheus-alertmanager and prometheus-server. I checked that it was because of unbound persistentvolumeclaim.

My question is, I have been trying to get prometheus to claim the pv that i have created, but no luck there.

I even inspected prometheus values with helm get values prometheus > helm-prometheus.yaml and made changes to the below: (by adding storageClassName)

---
# Source: prometheus/templates/alertmanager/pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    component: "alertmanager"
    app: prometheus
    release: release-name
    chart: prometheus-15.5.4
    heritage: Helm
  name: release-name-prometheus-alertmanager
  namespace: default
spec:      
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: "2Gi"
  storageClassName: prometheus-alertmanager
---
# Source: prometheus/templates/server/pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    component: "server"
    app: prometheus
    release: release-name
    chart: prometheus-15.5.4
    heritage: Helm
  name: release-name-prometheus-server
  namespace: default
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: "8Gi"
  storageClassName: prometheus-server

But this still doesn't work. How should I be correctly specifying for prometheus to claim the PV that I have created?

Note: I updated my helm after editing it with helm upgrade -f helm-prometheus.yaml prometheus prometheus-community/prometheus



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source