<p>I have tried to deploy Kafka in k8s, so I need to persist its volume with hostpath, but when the volume configuration adds to the deployment file, this error shows in Kafka pod, and the pod state becomes Crashloopbackoff:</p>
<pre><code>mkdir: cannot create directory ‘/bitnami/config’: Permission denied
</code></pre>
<p>I think I have to change permission so the pod can create this file.</p>
<p>Deployment.yml:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: kafka-broker
  name: kafka-broker
  namespace: kafka
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka-broker
  template:
    metadata:
      labels:
        app: kafka-broker
    spec:
      containers:
      - env:
        - name: ALLOW_PLAINTEXT_LISTENER
          value: "yes"
        - name: KAFKA_BROKER_ID
          value: "1"
        - name: KAFKA_ZOOKEEPER_CONNECT
          value: zookeeper-service:2181
        - name: KAFKA_LISTENERS
          value: PLAINTEXT://:9092
        - name: KAFKA_ADVERTISED_LISTENERS
          value: PLAINTEXT://:9092
        image: bitnami/kafka
        imagePullPolicy: IfNotPresent
        name: kafka-broker
        ports:
        - containerPort: 9092
        volumeMounts:
        - name: kafka-data
          readOnly: false
          mountPath: "/bitnami/kafka"
      volumes:
      - name: kafka-data
        hostPath:
          path: /data/kafka-data</code></pre>
</div>
</div>
</p>

mona moghadampanah
<p>I have solved the problem by changing the path (where I mount the pod data )ownership on the worker servers  with this command:</p>
<pre><code>sudo chown -R 1001:1001 /data/kafka-data
</code></pre>
<p>But I think this solution is not bestpractice.</p>
