apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaConnect
metadata:
  name: {{ include "kafka-cluster.fullname" . }}
  namespace: {{ include "kafka-cluster.namespace" . }}
  labels:
    strimzi.io/cluster: {{ include "kafka-cluster.fullname" . }}
    {{- include "kafka-cluster.labels" . | nindent 4 }}
  annotations:
    strimzi.io/use-connector-resources: "true"
spec:
  image: {{ .Values.kafkaConnect.image }}
  replicas: {{ .Values.kafkaConnect.replicas }}
  bootstrapServers: {{ include "kafka-cluster.fullname" . }}-kafka-tls-bootstrap.{{ include "kafka-cluster.namespace" . }}.svc.cluster.local:{{ .Values.listener.port }}
  config:
    group.id: {{ include "kafka-cluster.fullname" . }}-default-connect
    offset.storage.topic: {{ include "kafka-cluster.fullname" . }}.connect-offsets
    config.storage.topic: {{ include "kafka-cluster.fullname" . }}.connect-configs
    status.storage.topic: {{ include "kafka-cluster.fullname" . }}.connect-status
    key.converter: org.apache.kafka.connect.json.JsonConverter
    value.converter: org.apache.kafka.connect.json.JsonConverter
    plugin.path: /opt/kafka/plugins
    topic.creation.enable: "true"
  authentication:
    type: oauth
    tokenEndpointUri: {{ .Values.oauth.keycloakUrl }}/realms/{{ .Values.oauth.keycloakRealm }}/protocol/openid-connect/token
    clientId: {{ .Values.oauth.keycloakClientId }}-kafka-connect
    clientSecret:
      secretName: {{ .Values.kafkaConnect.oauthSecretName }}
      key: client-secret
    tlsTrustedCertificates:
      - secretName: {{ .Values.oauth.tlsSecretName }}
        pattern: {{ .Values.oauth.tlsCertificate | quote }}
  template:
    connectContainer:
      volumeMounts:
        - name: truststore-volume
          mountPath: /mnt/truststore/truststore.jks
          subPath: truststore.jks
          readOnly: true
    pod:
      volumes:
        - name: truststore-volume
          secret:
            secretName: {{ .Values.kafkaConnect.truststoreSecretName }}
  logging:
    type: inline
    loggers:
      rootLogger.level: {{ .Values.logging.connect.rootLoggerLevel }}