---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kan-kafka-1
  labels:
    app: kan-kafka
    kanBrokerId: "1"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kan-kafka
      kanBrokerId: "1"
  template:
    metadata:
      labels:
        app: kan-kafka
        kanBrokerId: "1"
    spec:
      containers:
        - name: kafka
          image: kafkanetes/minikan-kafka:0.1.0_2.13_2.5.0
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9092
          env:
          - name: POD_IP
            valueFrom:
              fieldRef:
                fieldPath: status.podIP
          - name: HOST_IP
            valueFrom:
              fieldRef:
                fieldPath: status.hostIP
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: KAFKA_BROKER_ID
            value: "1"
          - name: KAFKA_ZOOKEEPER_CONNECT
            value: kan-zk-1:2181
          command:
          - sh
          - -exc
          - |
            export KAFKA_LISTENERS=PLAINTEXT://${POD_IP}:9092 && \
            export KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kan-kafka-${KAFKA_BROKER_ID}.${POD_NAMESPACE}:9092 && \
            exec start-kafka.sh
