<p>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:</p>

<ol>
<li>install docker-desktop with kubernetes</li>
<li>manually create a persistent-storage volume using a yaml file (shown below)</li>
<li><code>helm install redis dandydev/redis-ha</code></li>
</ol>

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

<p>Also when I run: <code>kubectl get storageclasses.storage.k8s.io</code>
I do have (default) storage:</p>

<pre><code>NAME                 PROVISIONER          AGE
hostpath (default)   docker.io/hostpath   3h8m
</code></pre>

<p>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?</p>

<p>My volume.yaml:</p>

<pre class="lang-yaml prettyprint-override"><code>kind: PersistentVolume
apiVersion: v1
metadata:
  name: redis-volume
  labels:
    type: local
    app: redis
spec:
  storageClassName: ""
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/mnt/redis"
</code></pre>

<p>Ok so I looked more online among the various custom solutions, and one did work:
<a href="https://github.com/helm/charts/issues/12521#issuecomment-477834805" rel="nofollow noreferrer">https://github.com/helm/charts/issues/12521#issuecomment-477834805</a></p>
<p>In addition this answer provides more details into how to enable dynamic provisioning locally:
<a href="https://stackoverflow.com/questions/52668938/pod-has-unbound-persistentvolumeclaims">pod has unbound PersistentVolumeClaims</a></p>
<p>Basically (in addition to having the volume created above) I need to manually:</p>
<ol>
<li>create a storage class, via storage-class.yaml</li>
<li>add that storage class to helm in 'values.yaml'</li>
</ol>
<pre class="lang-yaml prettyprint-override"><code># storage-class.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: data-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
</code></pre>
<p>In addition, some charts running locally need you to customize their config, under <code>&lt;your-helm&gt;/charts/&lt;chart-name&gt;/&lt;file-to-config.yaml&gt;</code>, or via <code>--set &lt;var&gt;=value</code>since, most helm charts want you to use more nodes, and running locally you might only have a single node.</p>
<p>Another option is to use <code>helm install --set replicas=1 ...</code> and some charts will work well with this.</p>
<p>Hope this helps someone out there.</p>
