apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
  name: {{ .Values.cluster.name }}
spec:
  kafka:
    template:
      pod:
        metadata:
          annotations:
            backup.velero.io/backup-volumes: data-0
            sidecar.istio.io/inject: "false"
          labels:
            collect.logs: "plain-text"
        securityContext: {}
      podDisruptionBudget:
        maxUnavailable: 0
    version: 3.0.0
    replicas: {{ .Values.global.kafkaOperator.kafkaBrokers }}
    {{- if not .Values.global.disableRequestsLimits }}
    resources:
      limits:
        cpu: '2'
        memory: 4Gi
      requests:
        cpu: '1'
        memory: 2Gi
    {{- end }}
    listeners:
      - name: plain
        port: 9092
        type: internal
        tls: false
      - name: tls
        port: 9093
        type: internal
        tls: true
        authentication:
          type: tls
    config:
      transaction.state.log.replication.factor: {{ .Values.global.kafkaOperator.kafkaBrokers }}
      log.message.format.version: '3.0'
    {{- $logminisr := .Values.global.kafkaOperator.kafkaBrokers | int -}}
    {{- if lt $logminisr 2 }}
      transaction.state.log.min.isr: {{ .Values.global.kafkaOperator.kafkaBrokers }}
    {{ else }}
      transaction.state.log.min.isr: {{ sub .Values.global.kafkaOperator.kafkaBrokers 1 }}
    {{- end }}
      offsets.topic.replication.factor: {{ .Values.global.kafkaOperator.replicationFactor }}
    jvmOptions:
      "-XX":
        "UseG1GC": true
        "MaxGCPauseMillis": 20
        "InitiatingHeapOccupancyPercent": 35
        "ExplicitGCInvokesConcurrent": true
        "MetaspaceSize": "96m"
        "MinMetaspaceFreeRatio": 50
        "MaxMetaspaceFreeRatio": 80
        "G1HeapRegionSize": "16M"
    storage:
      type: jbod
      volumes:
        - id: 0
          type: persistent-claim
          size: 20Gi
          deleteClaim: false
          class: {{ .Values.storageClass }}
    metricsConfig:
      type: jmxPrometheusExporter
      valueFrom:
        configMapKeyRef:
          name: kafka-metrics
          key: kafka-metrics-config.yml
    logging:
      loggers:
        log4j.logger.kafka.network.Processor: {{ .Values.kafka.logLevel }}
        log4j.logger.org.apache.zookeeper: {{ .Values.kafka.logLevel }}
        log4j.logger.kafka.request.logger: {{ .Values.kafka.logLevel }}
        log4j.logger.kafka.authorizer.logger: {{ .Values.kafka.logLevel }}
        log4j.logger.org.I0Itec.zkclient.ZkClient: {{ .Values.kafka.logLevel }}
        log4j.logger.kafka.server.KafkaApis: {{ .Values.kafka.logLevel }}
        log4j.logger.state.change.logger: {{ .Values.kafka.logLevel }}
        log4j.logger.kafka.log.LogCleaner: {{ .Values.kafka.logLevel }}
        log4j.logger.kafka.controller: {{ .Values.kafka.logLevel }}
        log4j.logger.org.apache.kafka: {{ .Values.kafka.logLevel }}
        log4j.logger.kafka: {{ .Values.kafka.logLevel }}
      type: inline
  kafkaExporter:
    template:
      pod:
        metadata:
          labels:
            collect.logs: "plain-text"
    groupRegex: ".*"
    topicRegex: ".*"
  zookeeper:
    metricsConfig:
      type: jmxPrometheusExporter
      valueFrom:
        configMapKeyRef:
          key: zookeeper-metrics-config.yml
          name: zookeeper-metrics-config
    logging:
      loggers:
        zookeeper.root.logger: {{ .Values.kafka.logLevel }}
      type: inline
    template:
      pod:
        metadata:
          annotations:
            backup.velero.io/backup-volumes: data
            sidecar.istio.io/inject: "false"
          labels:
            collect.logs: "plain-text"
        securityContext: {}
      podDisruptionBudget:
        maxUnavailable: 0
    replicas: {{ .Values.global.kafkaOperator.zookeepers }}
    {{- if not .Values.global.disableRequestsLimits }}
    resources:
      limits:
        cpu: '1'
        memory: "1Gi"
      requests:
        cpu: '0.5'
        memory: "0.5Gi"
    {{- end }}
    storage:
      class: {{ .Values.storageClass }}
      type: persistent-claim
      size: 5Gi
      deleteClaim: false
  entityOperator:
    template:
      pod:
        metadata:
          labels:
            collect.logs: "plain-text"
    topicOperator:
      logging:
        loggers:
          rootLogger.level: {{ .Values.kafka.logLevel }}
        type: inline
    userOperator:
      logging:
        loggers:
          rootLogger.level: {{ .Values.kafka.logLevel }}
        type: inline
