apiVersion: v1
kind: Template
metadata:
  name: strimzi-connect
  annotations:
    openshift.io/display-name: "Apache Kafka Connect"
    description: >-
      This template installes Apache Kafka Connect in distributed mode. For more information
      about using this template see https://github.com/strimzi/strimzi
    tags: "messaging"
    iconClass: "fa pficon-topology"
    template.openshift.io/documentation-url: "https://github.com/strimzi/strimzi"
message: "Use 'kafka-connect:8083' to access Kafka Connect REST API."
parameters:
- description: Specifies the number of Kafka Connect instances to be started by default.
  displayName: Number of Kafka connect instances
  name: INSTANCES
  required: true
  value: "1"
- description: A list of host:port pairs to use for establishing the initial connection to the Kafka cluster.
  displayName: Kafka bootstrap servers
  name: KAFKA_CONNECT_BOOTSTRAP_SERVERS
  required: true
  value: kafka:9092
- description: A unique string that identifies the Connect cluster group this worker belongs to. Note this must not conflict with any consumer group IDs.
  displayName: Group ID
  name: KAFKA_CONNECT_GROUP_ID
  required: true
  value: connect-cluster
- description: Converter class used to convert between Kafka Connect format and the serialized form that is written to Kafka.
  displayName: Key Converter
  name: KAFKA_CONNECT_KEY_CONVERTER
  required: true
  value: org.apache.kafka.connect.json.JsonConverter
- description: Set to false to use schemaless format
  displayName: Enable schemas for key converters
  name: KAFKA_CONNECT_KEY_CONVERTER_SCHEMAS_ENABLE
  value: "true"
- description: Converter class used to convert between Kafka Connect format and the serialized form that is written to Kafka.
  displayName: Value Converter
  name: KAFKA_CONNECT_VALUE_CONVERTER
  required: true
  value: org.apache.kafka.connect.json.JsonConverter
- description: Set to false to use schemaless format
  displayName: Enable schemas for value converters
  name: KAFKA_CONNECT_VALUE_CONVERTER_SCHEMAS_ENABLE
  value: "true"
- description: Replication factor for config storage topic
  displayName: Config replication factor
  name: KAFKA_CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR
  value: "3"
- description: Replication factor for offset storage topic
  displayName: Offset replication factor
  name: KAFKA_CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR
  value: "3"
- description: Replication factor for status storage topic
  displayName: Status replication factor
  name: KAFKA_CONNECT_STATUS_STORAGE_REPLICATION_FACTOR
  value: "3"
- description: Image repository name
  displayName: Repository Name
  name: IMAGE_REPO_NAME
  value: strimzi
- description: Image name
  displayName: Image Name
  name: IMAGE_NAME
  value: kafka-connect
- description: Image tag
  displayName: Image tag
  name: IMAGE_TAG
  value: 0.1.0
objects:
- apiVersion: v1
  kind: Service
  metadata:
    name: kafka-connect
  spec:
    ports:
      - name: rest-api
        port: 8083
        targetPort: 8083
        protocol: TCP
    selector:
      name: kafka-connect
    type: ClusterIP
- apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: kafka-connect
  spec:
    replicas: ${INSTANCES}
    template:
      metadata:
        labels:
          name: kafka-connect
      spec:
        containers:
          - name: kafka-connect
            image: ${IMAGE_REPO_NAME}/${IMAGE_NAME}:${IMAGE_TAG}
            ports:
              - name: rest-api
                containerPort: 8083
                protocol: TCP
            env:
              - name: KAFKA_CONNECT_BOOTSTRAP_SERVERS
                value: "${KAFKA_CONNECT_BOOTSTRAP_SERVERS}"
              - name: KAFKA_CONNECT_GROUP_ID
                value: "${KAFKA_CONNECT_GROUP_ID}"
              - name: KAFKA_CONNECT_KEY_CONVERTER
                value: "${KAFKA_CONNECT_KEY_CONVERTER}"
              - name: KAFKA_CONNECT_KEY_CONVERTER_SCHEMAS_ENABLE
                value: "${KAFKA_CONNECT_KEY_CONVERTER_SCHEMAS_ENABLE}"
              - name: KAFKA_CONNECT_VALUE_CONVERTER
                value: "${KAFKA_CONNECT_VALUE_CONVERTER}"
              - name: KAFKA_CONNECT_VALUE_CONVERTER_SCHEMAS_ENABLE
                value: "${KAFKA_CONNECT_VALUE_CONVERTER_SCHEMAS_ENABLE}"
              - name: KAFKA_CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR
                value: "${KAFKA_CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR}"
              - name: KAFKA_CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR
                value: "${KAFKA_CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR}"
              - name: KAFKA_CONNECT_STATUS_STORAGE_REPLICATION_FACTOR
                value: "${KAFKA_CONNECT_STATUS_STORAGE_REPLICATION_FACTOR}"
            livenessProbe:
              httpGet:
                path: /
                port: rest-api
              initialDelaySeconds: 60
