---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: simulator
  annotations:
    reloader.stakater.com/auto: "true"
spec:
  revisionHistoryLimit: 0
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      component: simulator
  template:
    metadata:
      labels:
        component: simulator
    spec:
      containers:
        - name: simulator
          image: docker.io/cyrilix/robocar-simulator
          args:
          - "-simulator-address=$(SIMULATOR_ADDRESS)"
          - "-car-style=donkey"
          - "-car-name=Satanas"
          - "-car-color=100,0,255"
          - "-camera-img-h=$(CAMERA_HEIGHT)"
          - "-camera-img-w=$(CAMERA_WIDTH)"
          - "-log=info"
          securityContext:
            runAsUser: 1234
            runAsGroup: 1234
          env:
          - name: MQTT_BROKER
            valueFrom:
              configMapKeyRef:
                key: MQTT_BROKER
                name: robocar
          - name: MQTT_USERNAME
            valueFrom:
              secretKeyRef:
                key: MQTT_USERNAME
                name: mqtt-credentials
          - name: MQTT_PASSWORD
            valueFrom:
              secretKeyRef:
                key: MQTT_PASSWORD
                name: mqtt-credentials
          - name: MQTT_CLIENT_ID
            value: rc-simulator
          - name: MQTT_TOPIC_CAMERA
            valueFrom:
              configMapKeyRef:
                key: MQTT_TOPIC_CAMERA
                name: robocar
          - name: CAMERA_WIDTH
            valueFrom:
              configMapKeyRef:
                key: CAMERA_WIDTH
                name: robocar-camera
          - name: CAMERA_HEIGHT
            valueFrom:
              configMapKeyRef:
                key: CAMERA_HEIGHT
                name: robocar-camera
          - name: MQTT_TOPIC_STEERING
            valueFrom:
              configMapKeyRef:
                key: MQTT_TOPIC_SIMULATOR_STEERING
                name: robocar-simulator
          - name: MQTT_TOPIC_THROTTLE
            valueFrom:
              configMapKeyRef:
                key: MQTT_TOPIC_SIMULATOR_THROTTLE
                name: robocar-simulator
          - name: MQTT_TOPIC_STEERING_CTRL
            valueFrom:
              configMapKeyRef:
                key: MQTT_TOPIC_STEERING
                name: robocar
          - name: MQTT_TOPIC_THROTTLE_CTRL
            valueFrom:
              configMapKeyRef:
                key: MQTT_TOPIC_THROTTLE
                name: robocar
          - name: SIMULATOR_ADDRESS
            valueFrom:
              configMapKeyRef:
                key: SIMULATOR_ADDRESS
                name: robocar-simulator
          - name: MQTT_QOS
            value: "0"
          - name: TZ
            value: "Europe/Paris"
