apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: StatefulSet
metadata:
  name: kafka
  namespace: obbaa
spec:
  selector:
    matchLabels:
      app: kafka
  replicas: 1 # tells deployment to run 1 pods matching the template
  serviceName: kafka
  template:
    metadata:
      labels:
        app: kafka
    spec:
      enableServiceLinks: false             #workaround to avoid some kafka errors
      containers:
        - name: kafka
          image: confluentinc/cp-kafka:5.5.0
          command: ["bash", "-c", "unset KAFKA_REST_PORT; /etc/confluent/docker/run"]
          ports:
            - containerPort: 9092
          env:
            - name: KAFKA_BROKER_ID
              value: "1"
            - name: KAFKA_ZOOKEEPER_CONNECT
              value: "zookeeper:2181"
            - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
              value: "PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT"
            - name: KAFKA_ADVERTISED_LISTENERS
              value: "PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092"
            - name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
              value: "1"
            - name: KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS
              value: "0"