# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    version: 3.6.0
    replicas: 3
    template:
      pod:
        tolerations:
        - key: "app.stateful/component"
          operator: "Equal"
          value: "kafka-broker"
          effect: NoSchedule
        affinity:
          nodeAffinity:
            preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 1
              preference:
                matchExpressions:
                - key: "app.stateful/component"
                  operator: In
                  values:
                  - "kafka-broker"
        topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: "topology.kubernetes.io/zone"
          whenUnsatisfiable: DoNotSchedule
          labelSelector:
            matchLabels:
              app.kubernetes.io/name: kafka
              strimzi.io/cluster: my-cluster
              strimzi.io/component-type: kafka
    resources:
      requests:
        memory: 5Gi
        cpu: "1"
      limits:
        memory: 5Gi
        cpu: "2"
    jvmOptions:
      -Xms: 4096m
      -Xmx: 4096m
    listeners:
      - name: plain
        port: 9092
        type: internal
        tls: false
      - name: tls
        port: 9093
        type: internal
        tls: true
    config:
      offsets.topic.replication.factor: 3
      transaction.state.log.replication.factor: 3
      transaction.state.log.min.isr: 2
      default.replication.factor: 3
      min.insync.replicas: 2
      inter.broker.protocol.version: "3.4"
    storage:
      type: jbod
      volumes:
      - id: 0
        type: persistent-claim
        size: 100Gi
        class: premium-rwo
        deleteClaim: false
    metricsConfig:
      type: jmxPrometheusExporter
      valueFrom:
        configMapKeyRef:
          name: metrics-config
          key: kafka-metrics-config.yml
  zookeeper:
    template:
      pod:
        affinity:
          nodeAffinity:
            preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 1
              preference:
                matchExpressions:
                - key: "app.stateful/component"
                  operator: In
                  values:
                  - "zookeeper"
        topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: "topology.kubernetes.io/zone"
          whenUnsatisfiable: DoNotSchedule
          labelSelector:
            matchLabels:
              app.kubernetes.io/name: zookeeper
              strimzi.io/cluster: my-cluster
              strimzi.io/component-type: zookeeper
    replicas: 3
    resources:
      requests:
        memory: 2560Mi
        cpu: 1000m
      limits:
        memory: 2560Mi
        cpu: 2000m
    jvmOptions:
      -Xms: 2048m
      -Xmx: 2048m
    storage:
      type: persistent-claim
      size: 100Gi
      class: premium-rwo
      deleteClaim: false
    metricsConfig:
      type: jmxPrometheusExporter
      valueFrom:
        configMapKeyRef:
          name: metrics-config
          key: zookeeper-metrics-config.yml
  entityOperator:
    tlsSidecar:
      resources:
        requests:
          cpu: 100m
          memory: 128Mi
        limits:
          cpu: 500m
          memory: 128Mi
    topicOperator:
      resources:
        requests:
          cpu: 100m
          memory: 512Mi
        limits:
          cpu: 500m
          memory: 512Mi
    userOperator:
      resources:
        requests:
          cpu: 500m
          ephemeral-storage: 1Gi
          memory: 2Gi
        limits:
          cpu: 500m
          ephemeral-storage: 1Gi
          memory: 2Gi
