apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: kafka
  labels:
    app: kafka
spec:
  serviceName: kafka
  replicas: 3
  selector:
    matchLabels:
      app: kafka
  template:
    metadata:
      labels:
        app: kafka
    spec:
      terminationGracePeriodSeconds: 1800
      containers:
      - name: kafka
        image: docker.io/wurstmeister/kafka
        imagePullPolicy: Always
        ports:
        - containerPort: 9092
          name: kafka2
          protocol: TCP
        - containerPort: 9094
          name: kafka4
          protocol: TCP
        env:
          - name: KAFKA_ZOOKEEPER_CONNECT
            value: "zookeeper-0.zookeeper.default.svc.cluster.local:2181"
          - name: KAFKA_POD_IP
            valueFrom:
              fieldRef:
                fieldPath: status.podIP
          - name: KAFKA_ADVERTISED_PORT
            value: "9092"
          - name: KAFKA_ADVERTISED_HOST_NAME
            value: $(KAFKA_POD_IP)
      nodeSelector:
        worker: "true"
