<p>I want to deploy a kafka in k8s cluster.I have a zookeeper which is deploy without any issue but for deploying the kafka it doesnot become running and stuck in crashloopbackoff.I check it logs and here is its log:</p>
<pre><code>===&gt; User uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)
===&gt; Configuring ...
===&gt; Running preflight checks ...
===&gt; Check if /var/lib/kafka/data is writable ...
Command [/usr/local/bin/dub path /var/lib/kafka/data writable] FAILED !
</code></pre>
<p>And here is my deployment file :</p>
<pre><code>kind: Deployment
apiVersion: apps/v1
metadata:
  name: kafka-broker0
spec:
  replicas: 2
  selector:
    matchLabels:
        app: kafka
        id: &quot;0&quot;
  template:
    metadata:
      labels:
        app: kafka
        id: &quot;0&quot;
    spec:
      containers:
      - name: kafka
        image: confluentinc/cp-kafka:6.2.2
        ports:
        - containerPort: 9092
        env:
        - name: KAFKA_ADVERTISED_LISTENERS
          value: PLAINTEXT://127.0.0.1:9092
        - name: KAFKA_ZOOKEEPER_CONNECT
          value: zoo1:2181
        - name: KAFKA_BROKER_ID
          value: &quot;0&quot;
        - name: KAFKA_CREATE_TOPICS
          value: input:1:1, output:1:1
        volumeMounts:
        - mountPath: /var/lib/kafka/data
          name: kafka-data
      volumes:
      - name: kafka-data
        persistentVolumeClaim:
          claimName: kafka-data
</code></pre>
<p>I find this <a href="https://github.com/confluentinc/kafka-images/issues/127" rel="nofollow noreferrer">link</a> but in all sulotions the talk about deploy with docker and there isn't any solution for kubernetes.Also I try to add <code>user: root</code> or <code>user: &quot;0:0&quot;</code> but I couldn't find out how to add it.</p>

mona moghadampanah
<p>I had the same problem and I found a way to do a similar thing to the <a href="https://github.com/confluentinc/kafka-images/issues/127" rel="nofollow noreferrer">link you are talking about</a> but using Kubernetes.</p>
<p>In the pod configuration you can add:</p>
<pre><code>spec:
      containers:
      - name: kafka
        image: confluentinc/cp-kafka:6.2.2
        securityContext:
          runAsUser: 0
          runAsGroup: 0
</code></pre>
<p>I'm not sure whether it's the proper solution but it should work.
In my case I cannot use it as a solution because my cluster configuration does not allow me to run the pod as root.</p>
<p>Perhaps you can try to set <code>runAsUser: 1000</code> and <code>runAsGroup: 1000</code>. That's the ID I see when I run the image via docker. Although not sure if that's gonna work because I can see that the ID in your logs is the same.</p>
<pre><code>===&gt; User
uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)
</code></pre>
