apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-2
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka-2
  template:
    metadata:
      labels:
        app: kafka-2
    spec:
      hostNetwork: true
      containers:
        - env:
            - name: MY_POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: KUBE_CLUSTER_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP          
            - name: KAFKA_ADVERTISED_LISTENERS
              value: PLAINTEXT://$(MY_POD_IP):9093,PLAINTEXT_INTERNAL://$(KUBE_CLUSTER_IP):29093
            - name: KAFKA_BROKER_ID
              value: "2"
            - name: KAFKA_CREATE_TOPICS
              value: dmpAPI:2:2,sentiment:2:2
            - name: KAFKA_DEFAULT_REPLICATION_FACTOR
              value: "2"
            - name: KAFKA_INTER_BROKER_LISTENER_NAME
              value: PLAINTEXT_INTERNAL
            - name: KAFKA_LISTENERS
              value: PLAINTEXT://:9093,PLAINTEXT_INTERNAL://:29093
            - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
              value: PLAINTEXT_INTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
            - name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
              value: "2"
            - name: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR
              value: "2"
            - name: KAFKA_ZOOKEEPER_CONNECT
              value: "$(KUBE_CLUSTER_IP):30181"
          image: wurstmeister/kafka
          name: kafka-2
          ports:
            - containerPort: 9093
      restartPolicy: Always
      # nodeSelector:
      #   type: master



