<p>I am trying to deploy elastic on kubernetes <a href="https://www.elastic.co/guide/en/cloud-on-k8s/current/index.html" rel="noreferrer">https://www.elastic.co/guide/en/cloud-on-k8s/current/index.html</a> on a local minikube cluster. I have already installed the operator.</p>
<p>When i apply the elasticsearch cluster below, i get the following pod error:</p>
<blockquote>
<p>running &quot;VolumeBinding&quot; filter plugin for pod &quot;data-es-es-default-0&quot;:
pod has unbound immediate PersistentVolumeClaims</p>
</blockquote>
<p><strong>volume/claim:</strong></p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: elasticsearch-data
  labels:
    type: local
spec:
  storageClassName: standard
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/mnt/data&quot;
</code></pre>
<p>--</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: elasticsearch-data
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
</code></pre>
<p><strong>elastic.yml</strong></p>
<pre><code>apiVersion: elasticsearch.k8s.elastic.co/v1beta1
kind: Elasticsearch
metadata:
  name: data-es
spec:
  version: 7.4.2
  nodeSets:
  - name: default
    count: 2
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        accessModes:
        - ReadWriteOnce
        storageClassName: standard
        resources:
          requests:
            storage: 10Gi
    config:
      node.master: true
      node.data: true
      node.ingest: true
      node.store.allow_mmap: false
      xpack.security.authc.realms:
        native:
          native1: 
            order: 1
---
apiVersion: kibana.k8s.elastic.co/v1beta1
kind: Kibana
metadata:
  name: data-kibana
spec:
  version: 7.4.2
  count: 1
  elasticsearchRef:
    name: data-es
</code></pre>
<p><strong>kubectl get pvc</strong></p>
<p><a href="https://i.stack.imgur.com/XdzQU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XdzQU.png" alt="NAME                                      STATUS    VOLUME             CAPACITY   ACCESS MODES   STORAGECLASS   AGE elasticsearch-data        Bound     elasticsearch-data   10Gi       RWO            standard      8m45s elasticsearch-data-data-es-es-default-0   Pending                standard       7m40s elasticsearch-data-data-es-es-default-1   Pending standard       7m39s" /></a></p>

Kay
<blockquote>
<p>pod has unbound immediate PersistentVolumeClaims</p>
</blockquote>
<p>Above error means there is no <code>persistentVolume</code> that can be bound to the <code>PersistentVolumeClaim</code>. By default <code>local-storage</code> does not really create a <code>persistentVolume</code> dynamically.</p>
<p>To use dynamic provisioning mechanism of <code>local-storage</code> storage class you need to configure the <code>local-storage</code> class so that it can provision the <code>persistentVolume</code>. Check this discussion <a href="https://stackoverflow.com/questions/62739026/kubernetes-what-is-the-best-practice-for-create-dynamic-local-volume-to-auto-as/62740063#62740063">Kubernetes: What is the best practice for create dynamic local volume to auto assign PVs for PVCs?</a>.</p>
<p>Alternatively without using dynamic provisioning mechanism of a storageclass you need to create a <code>persistentVolume</code> using <code>hostPath</code> which can be bound to the <code>PersistentVolumeClaim</code>.But this is not a recommended solution for production usage. Check this guide <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="noreferrer">here</a>.</p>
<p><code>PersistentVolumeClaim</code> will be automatically created based on <code>volumeClaimTemplates</code> in the elastic yaml. Hence you should not create a
<code>PersistentVolumeClaim</code>.</p>
<p>Since <code>nodeSets</code> count is 2 two <code>PersistentVolumeClaim</code> is created. So you need to create two <code>persistentVolume</code>.</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: elasticsearch-data1
  labels:
    type: local
spec:
  storageClassName: standard
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/mnt/data&quot;
---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: elasticsearch-data2
  labels:
    type: local
spec:
  storageClassName: standard
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/mnt/data&quot;
</code></pre>
