apiVersion: apps/v1
kind: Deployment
metadata:
  name: eclipse-mosquitto
  namespace: internet-of-things
  labels:
    app.kubernetes.io/name: eclipse-mosquitto
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: eclipse-mosquitto
  template:
    metadata:
      labels:
        app.kubernetes.io/name: eclipse-mosquitto
    spec:
      containers:
        - name: mosquitto-exporter
          image: "rascal/mosquitto-exporter:v0.6.0"
          resources:
            limits:
              cpu: 100m
              memory: 64Mi
            requests:
              cpu: 50m
              memory: 64Mi
          env:
          - name: MQTT_USER
            valueFrom:
              secretKeyRef:
                name: eclipse-mosquitto-mon-creds
                key: username
          - name: MQTT_PASS
            valueFrom:
              secretKeyRef:
                name: eclipse-mosquitto-mon-creds
                key: password
          ports:
            - containerPort: 9234
              name: http
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /
              port: 9234
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /
              port: 9234
              scheme: HTTP
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
        - name: eclipse-mosquitto
          image: "eclipse-mosquitto:1.6.9"
          resources:
            limits:
              cpu: 250m
              memory: 128Mi
            requests:
              cpu: 50m
              memory: 128Mi
          ports:
            - containerPort: 1883
              name: mqtt
          volumeMounts:
            - mountPath: /mosquitto/config
              name: eclipse-mosquitto-config
              readOnly: true
            - mountPath: /mosquitto/data
              name: eclipse-mosquitto-data
      volumes:
        - name: eclipse-mosquitto-config
          secret:
            secretName: eclipse-mosquitto-config
        - name: eclipse-mosquitto-data
          persistentVolumeClaim:
            claimName: eclipse-mosquitto-data-pvc
