---
    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      name: kafka
      namespace: kafka-ca1
    spec:
      selector:
        matchLabels:
          app: kafka
      serviceName: "kafka"
      replicas: 3
      podManagementPolicy: OrderedReady
      template:
        metadata:
          labels:
            app: kafka # has to match .spec.selector.matchLabels
        spec:
          containers:
          - name: kafka
            image: wurstmeister/kafka:2.11-2.0.0
            imagePullPolicy: IfNotPresent
            ports:
            - containerPort: 9092
              name: plaintext
            - containerPort: 9999
              name: jmx
            env:
              - name: KAFKA_ADVERTISED_PORT
                value: "9092"
              - name: BROKER_ID_COMMAND
                value: "hostname | cut -d'-' -f2"
              - name: KAFKA_ZOOKEEPER_CONNECT
                value: "zookeeper-service:2181"
              - name: KAFKA_LISTENERS
                value: "PLAINTEXT://:9092"
              - name: KAFKA_JMX_OPTS
                value: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.rmi.port=9999 -Djava.rmi.server.hostname=127.0.0.1"
              - name: JMX_PORT
                value: "9999"