title: Kafka Kraft replication factor of 3
body: <p>I tried to run Kafka in Raft mode (zookeeper-less) in Kubernetes and everything worked fine with this configuration:</p>
  <p>I am curious about how to change the provided configuration to run with a replication factor of 3 for instance?</p>
  <p>The fruitful topic was <a href="https://github.com/bitnami/bitnami-docker-kafka/issues/159" rel="nofollow noreferrer">on the github</a> but no one provided Kafka Kraft mode with replication set up.</p>
  <p>Statefulset</p>
  <pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
  kind: StatefulSet
  metadata:
    name: kafka-statefulset
    namespace: kafka
    labels:
      app: kafka-cluster
  spec:
    serviceName: kafka-svc
    replicas: 1
    selector:
      matchLabels:
        app: kafka-cluster
    template:
      metadata:
        labels:
          app: kafka-cluster
      spec:
        containers:
          - name: kafka-container
            image: 'bitnami/kafka:latest'
            ports:
              - containerPort: 9092
              - containerPort: 9093
            env:
              - name: KAFKA_BROKER_ID
                value: &quot;1&quot;
              - name: KAFKA_CFG_NODE_ID
                value: &quot;1&quot;
              - name: KAFKA_ENABLE_KRAFT
                value: &quot;yes&quot;
              - name: KAFKA_CFG_PROCESS_ROLES
                value: &quot;broker,controller&quot;
              - name: KAFKA_CFG_CONTROLLER_LISTENER_NAMES
                value: &quot;CONTROLLER&quot;
              - name: KAFKA_CFG_LISTENERS
                value: &quot;CLIENT://:9092,CONTROLLER://:9093,EXTERNAL://0.0.0.0:9094&quot;
              - name: KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP
                value: &quot;CONTROLLER:PLAINTEXT,CLIENT:PLAINTEXT,EXTERNAL:PLAINTEXT&quot;
              - name: KAFKA_CFG_INTER_BROKER_LISTENER_NAME
                value: &quot;CLIENT&quot;
              - name: KAFKA_CFG_ADVERTISED_LISTENERS
                value: &quot;CLIENT://kafka-statefulset-0.kafka-svc.kafka.svc.cluster.local:9092,EXTERNAL://127.0.0.1:9094&quot;
              - name: KAFKA_CFG_CONTROLLER_QUORUM_VOTERS
                value: &quot;1@127.0.0.1:9093&quot;
              - name: KAFKA_AUTO_CREATE_TOPICS_ENABLE
                value: &quot;false&quot;
              - name: KAFKA_DEFAULT_REPLICATION_FACTOR
                value: &quot;1&quot;
              - name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
                value: &quot;1&quot;
              - name: ALLOW_PLAINTEXT_LISTENER
                value: &quot;yes&quot;
  
  </code></pre>
  <p>Headless service:</p>
  <pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
  kind: Service
  metadata:
    name: kafka-svc
    labels:
      app: kafka-cluster
  spec:
    clusterIP: None
    ports:
      - name: '9092'
        port: 9092
        protocol: TCP
        targetPort: 9092
    selector:
      app: kafka-cluster
  </code></pre>