---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: iot-core-bridge
  labels:
    app: iot-core-bridge
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: iot-core-bridge
  template:
    metadata:
      labels:
        app: iot-core-bridge
    spec:
      shareProcessNamespace: true
      containers:
      - name: refresher
        image: gcr.io/iot-mqtt-bridge/refresher
        envFrom:
        - configMapRef:
            name: device-config
        securityContext:
          capabilities:
            add: ["SYS_PTRACE"]
        resources:
          limits:
            cpu: "1"
            memory: "200Mi"
          requests:
            cpu: "0.2"
        volumeMounts:
        - name: mqtt-conf
          mountPath: /etc/mqtt 
        - name: mosquitto-conf
          mountPath: /mosquitto/config
      - name: mosquitto
        image: eclipse-mosquitto
        securityContext:
          capabilities:
            add: ["SYS_PTRACE"]
        resources:
          limits:
            cpu: "1"
            memory: "200Mi"
          requests:
            cpu: "0.1"   
        ports:
          - name: mqtt
            containerPort: 1883
        volumeMounts:
        - name: mqtt-conf
          mountPath: /etc/mqtt 
        - name: mosquitto-conf
          mountPath: /mosquitto/config
        - name: mosquitto-persist
          mountPath: /tmp/mosquitto
      volumes:
            - name: mqtt-conf
              configMap:
                name: mqtt-conf
            - name: mosquitto-conf
              emptyDir: {}
            - name: mosquitto-persist
              emptyDir: {}
