// 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>
      tls:
        authentication:<7>
          type: tls
      external: <8>
        type: route
        authentication:
          type: tls
        configuration:
          brokerCertChainAndKey: <9>
            secretName: my-secret
            certificate: my-certificate.crt
            key: my-key.key
    authorization: <10>
      type: simple
    config: <11>
      auto.create.topics.enable: "false"
      offsets.topic.replication.factor: 3
      transaction.state.log.replication.factor: 3
      transaction.state.log.min.isr: 2
    storage: <12>
      type: persistent-claim <13>
      size: 10000Gi <14>
    rack: <15>
      topologyKey: failure-domain.beta.kubernetes.io/zone
    metrics: <16>
      lowercaseOutputName: true
      rules: <17>
      # 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: <18>
    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: <19>
    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: <20>
    # ...
  cruiseControl: <21>
    # ...
----

<1> Replicas xref:assembly-kafka-broker-replicas-{context}[specifies the number of broker nodes].
<2> Kafka version, link:{BookURLDeploying}#assembly-upgrade-str[which can be changed by following 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-configuring-kafka-broker-listeners-{context}[configured as `plain` (without encryption), `tls` or `external`].
<7> Listener authentication mechanisms may be configured for each listener, and xref:assembly-kafka-broker-listener-authentication-{context}[specified as mutual TLS or SCRAM-SHA].
<8> External listener configuration specifies xref:assembly-kafka-broker-external-listeners-{context}[how the Kafka cluster is exposed outside Kubernetes, such as through a `route`, `loadbalancer` or `nodeport`].
<9> 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.
<10> Authorization xref:ref-kafka-authorization-{context}[enables `simple` authorization on the Kafka broker using the `SimpleAclAuthorizer` Kafka plugin].
<11> Config specifies the broker configuration. xref:ref-kafka-broker-configuration-{context}[Standard Apache Kafka configuration may be provided, restricted to those properties not managed directly by {ProductName}].
<12> Storage is xref:assembly-storage-{context}[configured as `ephemeral`, `persistent-claim` or `jbod`].
<13> 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].
<14> Persistent storage has xref:ref-persistent-storage-{context}[additional configuration options], such as a storage `id` and `class` for dynamic volume provisioning.
<15> 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.
<16> Kafka link:{BookURLDeploying}#assembly-metrics-setup-str[metrics configuration for use with Prometheus].
<17> Kafka rules for exporting metrics to a Grafana dashboard through the JMX Exporter. A set of rules provided with {productName} may be copied to your Kafka resource configuration.
<18> xref:assembly-zookeeper-node-configuration-{context}[ZooKeeper-specific configuration], which contains properties similar to the Kafka configuration.
<19> Entity Operator configuration, which xref:assembly-kafka-entity-operator-{context}[specifies the configuration for the Topic Operator and User Operator].
<20> Kafka Exporter configuration, which is used xref:assembly-kafka-exporter-configuration-{context}[to expose data as Prometheus metrics].
<21> Cruise Control configuration, which is used xref:proc-deploying-cruise-control-str[to monitor and balance data across the Kafka cluster].
