kind: Deployment
apiVersion: apps/v1
metadata:
  name: zigbee2mqttassistant
  namespace: zigbee2mqtt
  labels:
    app: zigbee2mqttassistant
spec:
  replicas: 1
  selector:
    matchLabels:
      app: zigbee2mqttassistant
  template:
    metadata:
      labels:
        app: zigbee2mqttassistant
    spec:
      volumes:
        - name: secrets-volume
          emptyDir: {}
      initContainers:
        - name: init-secrets
          image: busybox:1.28
          volumeMounts:
            - name: secrets-volume
              mountPath: /tmp/secrets
          env:
            - name: APPSETTINGS
              valueFrom:
                secretKeyRef:
                  name: zigbee2mqtt
                  key: appsettings.json
          command: ['sh', '-c', "echo $APPSETTINGS > /tmp/secrets/appsettings.json"]
      containers:
        - name: zigbee2mqttassistant
          image: 'carldebilly/zigbee2mqttassistant'
          env:
            - name: TZ
              value: 'Asia/Jerusalem'
            - name: Z2MA_SETTINGS__MQTTSECURE
              value: 'false'
            - name: ASPNETCORE_URLS
              value: 'http://*:8888'
          resources:
            limits:
              cpu: 200m
              memory: 100Mi
          volumeMounts:
            - name: secrets-volume
              readOnly: true
              mountPath: /app/appsettings.json
              subPath: appsettings.json
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
