apiVersion: apps/v1
kind: Deployment
metadata:
  name: mqtt-publisher-deployment
  labels:
    app: mqtt-publisher
spec:
  replicas: 2
  selector:
    matchLabels:
      app: mqtt-publisher
  template:
    metadata:
      labels:
        app: mqtt-publisher
    spec:
      containers:
      - name: mqtt-publisher-container
        image: usman476/mqtt-kafka-faust:latest
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: MQTT_BROKER
          value: "mqtt-mosquitto.uc0.svc.cluster.local"
        - name: MQTT_BROKER_PORT
          value: "1883"
        - name: SENSORS
          value: "2"
        - name: MESSAGE_DELAY
          value: "0.5"
        - name: MQTT_TOPIC
          value: "mqtt/temperature/readings"
        - name: VALUE_TYPE
          value: "float"
        - name: START_VALUE
          value: "1.0"
        - name: END_VALUE
          value: "99.99"
        - name: INVALID_VALUE_OCCURRENCE
          value: "5"
        - name: INVALID_VALUE
          value: "200.0"
        - name: INPUT_FILE
          value: "generated_values.csv"
        command: ["python3"]
        args: ["publisher.py"]
        imagePullPolicy: "IfNotPresent"
        volumeMounts:
        - mountPath: /data
          name: data-volume
      restartPolicy: Always
      nodeSelector:
        kubernetes.io/hostname: worker-vm-1
      volumes:
      - name: data-volume
        hostPath:
          # directory location on host
          path: /opt/data
          # this field is optional
          type: Directory
