apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-consumer
  labels:
    app: kafka-consumer
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka-consumer
  template:
    metadata:
      labels:
        app: kafka-consumer
    spec:
      containers:
        - name: kafka-consumer
          image: quay.io/fvaleri/kafka-client:latest
          imagePullPolicy: Always
          env:
            - name: KAFKA_OPTS
              value: "-Dcom.redhat.fips=false"
            - name: CLIENT_TYPE
              value: "consumer"
            - name: BOOTSTRAP_SERVERS
              value: "my-cluster-kafka-bootstrap:9092"
            - name: SECURITY_PROTOCOL
              value: "PLAINTEXT"
            - name: TOPIC_NAME
              value: "my-topic"
            - name: NUM_MESSAGES
              value: "100"
            - name: PROC_DELAY_MS
              value: "1000"
          resources:
            limits:
              cpu: 200m
              memory: 200Mi
            requests:
              cpu: 100m
              memory: 100Mi
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: app
                      operator: In
                      values:
                        - kafka-consumer
                topologyKey: kubernetes.io/hostname
