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:
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"
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: https://stackoverflow.com/questions/52668938/pod-has-unbound-persistentvolumeclaims
Basically (in addition to having the volume created above) I need to manually:
# 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>=value
since, 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.