title: Pod has unbound PersistentVolumeClaims but volume claims is bounded
body: <p>I want to create a statefulset elasticsearch in kubernetes on virtualbox. I'm not using cloud provider so i create two persistent volume localy for my two replicas of my statefulset :</p>
  
  <p>pv0:</p>
  
  <pre><code>kind: PersistentVolume
  apiVersion: v1
  metadata:
    name: pv-elk-0
    namespace: elk
    labels:
      type: local
  spec:
    storageClassName: gp2
    capacity:
      storage: 5Gi
    accessModes:
      - ReadWriteOnce
    hostPath:
      path: "/mnt/data/pv0"
  </code></pre>
  
  <p>pv1:</p>
  
  <pre><code>kind: PersistentVolume
  apiVersion: v1
  metadata:
    name: pv-elk-1
    namespace: elk
    labels:
      type: local
  spec:
    storageClassName: gp2
    capacity:
      storage: 5Gi
    accessModes:
      - ReadWriteOnce
    hostPath:
      path: "/mnt/data/pv1"
  </code></pre>
  
  <p>Statefulset :</p>
  
  <pre><code>apiVersion: apps/v1beta1
  kind: StatefulSet
  metadata:
    name: elasticsearch-logging
    namespace: elk
    labels:
      k8s-app: elasticsearch-logging
      version: v5.6.2
      kubernetes.io/cluster-service: "true"
      addonmanager.kubernetes.io/mode: Reconcile
  spec:
    serviceName: elasticsearch-logging
    replicas: 2
    selector:
      matchLabels:
        k8s-app: elasticsearch-logging
        version: v5.6.2
    template:
      metadata:
        labels:
          k8s-app: elasticsearch-logging
          version: v5.6.2
          kubernetes.io/cluster-service: "true"
      spec:
        serviceAccountName: elasticsearch-logging
        containers:
        - image: gcr.io/google-containers/elasticsearch:v5.6.2
          name: elasticsearch-logging
          ports:
          - containerPort: 9200
            name: db
            protocol: TCP
          - containerPort: 9300
            name: transport
            protocol: TCP
          resources:
            limits:
              cpu: 0.1
          volumeMounts:
          - name: elasticsearch-logging
            mountPath: /data
          env:
          - name: "NAMESPACE"
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
        initContainers:
        - image: alpine:3.6
          command: ["/sbin/sysctl", "-w", "vm.max_map_count=262144"]
          name: elasticsearch-logging-init
          securityContext:
            privileged: true
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-logging
      spec:
        accessModes: ["ReadWriteOnce"]
        storageClassName: gp2
        resources:
          requests:
            storage: 5Gi
  </code></pre>
  
  <p>It seems like the persistant volume is correctly bounced but the pod are always in crash loop and restart every time. It's it because of the use of the initContainer or something wrong with my yaml ?</p>
  
  <p><a href="https://i.stack.imgur.com/Y0zZg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Y0zZg.png" alt="Statefulset"></a></p>
  
  <p><a href="https://i.stack.imgur.com/MJL5F.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MJL5F.png" alt="pv,pvc"></a></p>