// Module included in the following assemblies:
//
// assembly-deployment-configuration.adoc

[id='ref-sample-kafka-resource-config-{context}']
= Sample Kafka YAML configuration

For help in understanding the configuration options available for your Kafka deployment, refer to sample YAML file provided here.

The sample shows only some of the possible configuration options, but those that are particularly important include:

* Resource requests (CPU / Memory)
* JVM options for maximum and minimum memory allocation
* Listeners (and authentication)
* Authentication
* Storage
* Rack awareness
* Metrics

[source,shell,subs="+attributes"]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    replicas: 3 <1>
    version: {ProductVersion} <2>
    resources: <3>
      requests:
        memory: 64Gi
        cpu: "8"
      limits: <4>
        memory: 64Gi
        cpu: "12"
    jvmOptions: <5>
      -Xms: 8192m
      -Xmx: 8192m
    listeners: <6>
      - name: plain <7>
        port: 9092 <8>
        type: internal <9>
        tls: false <10>
        useServiceDnsDomain: true <11>
      - name: tls
        port: 9093
        type: internal
        tls: true
        authentication: <12>
          type: tls
      - name: external <13>
        port: 9094
        type: route
        tls: true
        configuration:
          brokerCertChainAndKey: <14>
            secretName: my-secret
            certificate: my-certificate.crt
            key: my-key.key
    authorization: <15>
      type: simple
    config: <16>
      auto.create.topics.enable: "false"
      offsets.topic.replication.factor: 3
      transaction.state.log.replication.factor: 3
      transaction.state.log.min.isr: 2
      ssl.cipher.suites: "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" <17>
      ssl.enabled.protocols: "TLSv1.2"
      ssl.protocol: "TLSv1.2"
    storage: <18>
      type: persistent-claim <19>
      size: 10000Gi <20>
    rack: <21>
      topologyKey: topology.kubernetes.io/zone
    metrics: <22>
      lowercaseOutputName: true
      rules: <23>
      # Special cases and very specific rules
      - pattern : kafka.server<type=(.+), name=(.+), clientId=(.+), topic=(.+), partition=(.*)><>Value
        name: kafka_server_$1_$2
        type: GAUGE
        labels:
          clientId: "$3"
          topic: "$4"
          partition: "$5"
        # ...
  zookeeper: <24>
    replicas: 3
    resources:
      requests:
        memory: 8Gi
        cpu: "2"
      limits:
        memory: 8Gi
        cpu: "2"
    jvmOptions:
      -Xms: 4096m
      -Xmx: 4096m
    storage:
      type: persistent-claim
      size: 1000Gi
    metrics:
      # ...
  entityOperator: <25>
    topicOperator:
      resources:
        requests:
          memory: 512Mi
          cpu: "1"
        limits:
          memory: 512Mi
          cpu: "1"
    userOperator:
      resources:
        requests:
          memory: 512Mi
          cpu: "1"
        limits:
          memory: 512Mi
          cpu: "1"
  kafkaExporter: <26>
    # ...
  cruiseControl: <27>
    # ...
----

<1> Replicas xref:assembly-kafka-broker-replicas-{context}[specifies the number of broker nodes].
<2> Kafka version, which can be changed by following link:{BookURLDeploying}#assembly-upgrade-str[the upgrade procedure].
<3> Resource requests xref:ref-resource-limits-and-requests-{context}[specify the resources to reserve for a given container].
<4> Resource limits specify the maximum resources that can be consumed by a container.
<5> JVM options can xref:ref-jvm-options-{context}[specify the minimum (`-Xms`) and maximum (`-Xmx`) memory allocation for JVM].
<6> Listeners configure how clients connect to the Kafka cluster via bootstrap addresses. Listeners are xref:assembly-securing-kafka-brokers-str[configured as _internal_ or _external_ listeners for connection inside or outside the Kubernetes cluster].
<7> Name to identify the listener. Must be unique within the Kafka cluster.
<8> Port number used by the listener inside Kafka. The port number has to be unique within a given Kafka cluster. Allowed port numbers are 9092 and higher with the exception of ports 9404 and 9999, which are already used for Prometheus and JMX. Depending on the listener type, the port number might not be the same as the port number that connects Kafka clients.
<9> Listener type specified as `internal`, or for external listeners, as `route`, `loadbalancer`, `nodeport` or `ingress`.
<10> Enables TLS encryption for each listener. Default is `false`. TLS encryption is not required for `route` listeners.
<11> Defines whether the fully-qualified DNS names including the cluster service suffix (usually `.cluster.local`) are assigned.
<12> Listener authentication mechanism xref:assembly-securing-kafka-brokers-str[specified as mutual TLS, SCRAM-SHA-512 or token-based OAuth 2.0].
<13> External listener configuration specifies xref:assembly-configuring-external-listeners-str[how the Kafka cluster is exposed outside Kubernetes, such as through a `route`, `loadbalancer` or `nodeport`].
<14> Optional configuration for a xref:kafka-listener-certificates-str[Kafka listener certificate] managed by an external Certificate Authority. The `brokerCertChainAndKey` property specifies a `Secret` that holds a server certificate and a private key. Kafka listener certificates can also be configured for TLS listeners.
<15> Authorization xref:con-securing-kafka-authorization-str[enables simple, OAUTH 2.0 or OPA authorization on the Kafka broker.] Simple authorization uses the `AclAuthorizer` Kafka plugin.
<16> Config specifies the broker configuration. xref:type-KafkaClusterSpec-reference[Standard Apache Kafka configuration may be provided, restricted to those properties not managed directly by Strimzi].
<17> xref:type-KafkaClusterSpec-reference[SSL properties for external listeners to run with a specific _cipher suite_ for a TLS version].
<18> Storage is xref:assembly-storage-{context}[configured as `ephemeral`, `persistent-claim` or `jbod`].
<19> Storage size for xref:proc-resizing-persistent-volumes-{context}[persistent volumes may be increased] and additional xref:proc-adding-volumes-to-jbod-storage-{context}[volumes may be added to JBOD storage].
<20> Persistent storage has xref:ref-persistent-storage-{context}[additional configuration options], such as a storage `id` and `class` for dynamic volume provisioning.
<21> Rack awareness is configured to xref:assembly-kafka-rack-{context}[spread replicas across different racks]. A `topology` key must match the label of a cluster node.
<22> Kafka link:{BookURLDeploying}#assembly-metrics-setup-str[metrics configuration for use with Prometheus].
<23> Kafka rules for exporting metrics to a Grafana dashboard through the JMX Exporter. A set of rules provided with Strimzi may be copied to your Kafka resource configuration.
<24> xref:assembly-zookeeper-node-configuration-{context}[ZooKeeper-specific configuration], which contains properties similar to the Kafka configuration.
<25> Entity Operator configuration, which xref:assembly-kafka-entity-operator-{context}[specifies the configuration for the Topic Operator and User Operator].
<26> Kafka Exporter configuration, which is used xref:assembly-kafka-exporter-configuration-{context}[to expose data as Prometheus metrics].
<27> Cruise Control configuration, which is used xref:cruise-control-concepts-str[to rebalance the Kafka cluster].
