<p>This is my <a href="https://kafka.js.org/docs/getting-started" rel="nofollow noreferrer">KafkaJs</a> based publisher client. I created a container image and submitted a <code>Pod</code> YAML to Strimzi broker.</p>
<pre class="lang-js prettyprint-override"><code>const { Kafka } = require('kafkajs')

async function clients() {
const kafka = new Kafka({
  clientId: 'my-app',
  brokers: ['test-kafka-bootstrap.strimzi.svc.cluster.local:9092']
})

const producer = kafka.producer()

await producer.connect()
await producer.send({
  topic: 'clients',
  messages: [
    { value: 'Hello KafkaJS user!' },
  ],
})

await producer.disconnect()
}

clients()
</code></pre>
<p>My <code>Dockerfile</code>.</p>
<pre><code>FROM node:14 as build_app

WORKDIR /

WORKDIR /app
COPY app .
COPY package.json .
COPY package-lock.json .
RUN npm i
CMD [&quot;node&quot;, &quot;index.js&quot;]
</code></pre>
<p>My <code>pod</code> YAML.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: clients
spec:
  containers:
  - name: clients
    image: ghcr.io/org/clients:v0.0.0
    imagePullPolicy: Always
</code></pre>
<p>The <code>Pod</code> keeps crashing and <code>kubectl logs</code> does not show anything - its empty. A <code>kubectl describe</code> didnt' reveal anything either.</p>
<p>What am I missing?</p>

<p>The logs show nothing because 1) Your code has no log output 2) Your code only send a single record, and then stops, so the container exits cleanly; it is not a long-running service. You'd have the same issues with a simple <code>docker run</code> command.</p>
<p>If you wanted a long-running service, you'd need to wrap your code in a web-service (NextJS, Express, Hapi, etc), and then add a health check probe for the k8s Service.</p>
