title: Running local development kafka in kubernetes with Kind and persisting volumes
body: <p>I am running a Dev Linux machine and setting up a local Kafka for development on Kubernetes(moving from docker-compose for learning and practicing pourposes) with <a href="https://kind.sigs.k8s.io/" rel="nofollow noreferrer">Kind</a> and everything works fine but I am now trying to map volumes from Kafka and Zookeeper to the host but I am only able to for the Kafka volume.
  For zookeeper I configure and map the data and log paths to a volume but the internal directories are not being exposed on the host(which happens with the kafka mapping), it only shows the data and log folders but no content is actually present on the host so restarting zookeeper resets state.</p>
  <p>I am wondering if there's a limitation or a different approach when using Kind and mapping multiples directories from different pods, what am I missing? Why only Kafka volumes are successfully persisted on host.</p>
  <p>The full setup with a readme on how to run it's <a href="https://github.com/mmaia/kafka-local-kubernetes" rel="nofollow noreferrer">on Github</a> under <code>pv-pvc-setup</code> folder.</p>
  <p>Zookeeper meaningful configuration, Deployment:</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    labels:
      service: zookeeper
    name: zookeeper
  spec:
    replicas: 1
    selector:
      matchLabels:
        service: zookeeper
    strategy: {}
    template:
      metadata:
        labels:
          network/kafka-network: &quot;true&quot;
          service: zookeeper
      spec:
        containers:
          - env:
              - name: TZ
              - name: ZOOKEEPER_CLIENT_PORT
                value: &quot;2181&quot;
              - name: ZOOKEEPER_DATA_DIR
                value: &quot;/var/lib/zookeeper/data&quot;
              - name: ZOOKEEPER_LOG_DIR
                value: &quot;/var/lib/zookeeper/log&quot;
              - name: ZOOKEEPER_SERVER_ID
                value: &quot;1&quot;
            image: confluentinc/cp-zookeeper:7.0.1
            name: zookeeper
            ports:
              - containerPort: 2181
            resources: {}
            volumeMounts:
              - mountPath: /var/lib/zookeeper
                name: zookeeper-data
        hostname: zookeeper
        restartPolicy: Always
        volumes:
          - name: zookeeper-data
            persistentVolumeClaim:
              claimName: zookeeper-pvc
  </code></pre>
  <p>Persistent volume claim:</p>
  <pre><code>apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: zookeeper-pvc
  spec:
    accessModes:
      - ReadWriteOnce
    storageClassName: zookeeper-local-storage
    resources:
      requests:
        storage: 5Gi
  </code></pre>
  <p>Persistent volume:</p>
  <pre><code>apiVersion: v1
  kind: PersistentVolume
  metadata:
    name: zookeeper-pv
  spec:
    accessModes:
      - ReadWriteOnce
    storageClassName: zookeeper-local-storage
    capacity:
      storage: 5Gi
    persistentVolumeReclaimPolicy: Retain
    hostPath:
      path: /var/lib/zookeeper
  </code></pre>
  <p>kind-config:</p>
  <pre><code>apiVersion: kind.x-k8s.io/v1alpha4
  kind: Cluster
  nodes:
    - role: control-plane
    - role: worker
      extraPortMappings:
        - containerPort: 30092 # internal kafka nodeport
          hostPort: 9092 # port exposed on &quot;host&quot; machine for kafka
        - containerPort: 30081 # internal schema-registry nodeport
          hostPort: 8081 # port exposed on &quot;host&quot; machine for schema-registry
      extraMounts:
        - hostPath: ./tmp/kafka-data
          containerPath: /var/lib/kafka/data
          readOnly: false
          selinuxRelabel: false
          propagation: Bidirectional
        - hostPath: ./tmp/zookeeper-data
          containerPath: /var/lib/zookeeper
          readOnly: false
          selinuxRelabel: false
          propagation: Bidirectional
  </code></pre>
  <p>As I mentioned the setup works, I am now just trying to make sure relevant kafka and zookeeper volumes are mapped to persistent external storage(in this case a local disk).</p>