1

I've seen this question come up often, and I've yet to find a clean, generic solution. I'm just learning Kubernetes so maybe there's something basic I'm missing. But here's what I've done:

  1. install docker-desktop with kubernetes
  2. manually create a persistent-storage volume using a yaml file (shown below)
  3. helm install redis dandydev/redis-ha

Or you can use any other helm chart, be it elasticsearch, postgres, you name it. I always get pod has unbound immediate PersistentVolumeClaims.

Also when I run: kubectl get storageclasses.storage.k8s.io I do have (default) storage:

NAME                 PROVISIONER          AGE
hostpath (default)   docker.io/hostpath   3h8m

Can anyone please help me fix this issue in a generic way? So that I can actually install helm charts and have them automatically connect to a persistent storage volume?

My volume.yaml:

kind: PersistentVolume
apiVersion: v1
metadata:
  name: redis-volume
  labels:
    type: local
    app: redis
spec:
  storageClassName: ""
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/mnt/redis"
Cosmin Atanasiu
  • 2,532
  • 3
  • 21
  • 26
  • In redis helm chart code you can see [this code](https://github.com/DandyDeveloper/charts/blob/master/charts/redis-ha/templates/redis-ha-statefulset.yaml#L286-L316) that suggests you may want to read [my other answer to simmilar question](https://stackoverflow.com/questions/62238476/how-to-extract-volumeclaimtemplates-to-a-separate-persistentvolumeclaim-yaml-fil/62263046#62263046). Let me know if it solves your issue. – Matt Jun 19 '20 at 12:06

1 Answers1

1

Ok so I looked more online among the various custom solutions, and one did work: https://github.com/helm/charts/issues/12521#issuecomment-477834805

In addition this answer provides more details into how to enable dynamic provisioning locally: pod has unbound PersistentVolumeClaims

Basically (in addition to having the volume created above) I need to manually:

  1. create a storage class, via storage-class.yaml
  2. add that storage class to helm in 'values.yaml'
# storage-class.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: data-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

In addition, some charts running locally need you to customize their config, under <your-helm>/charts/<chart-name>/<file-to-config.yaml>, or via --set <var>=valuesince, most helm charts want you to use more nodes, and running locally you might only have a single node.

Another option is to use helm install --set replicas=1 ... and some charts will work well with this.

Hope this helps someone out there.

Cosmin Atanasiu
  • 2,532
  • 3
  • 21
  • 26