apiVersion: apps/v1
kind: Deployment
metadata:
  name: home-assistant
  namespace: internet-of-things
  labels:
    app.kubernetes.io/name: home-assistant
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: home-assistant
  template:
    metadata:
      labels:
        app.kubernetes.io/name: home-assistant
    spec:
      hostNetwork: true
      containers:
        - name: nginx
          image: nginx:1.17.8-alpine
          ports:
            - name: http
              containerPort: 8123
          resources:
            limits:
              cpu: 1000m
              memory: 128Mi
            requests:
              cpu: 50m
              memory: 128Mi
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /-/status
              port: http
              scheme: HTTP
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /-/status
              port: http
              scheme: HTTP
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          volumeMounts:
          - name: nginx-config
            mountPath: /etc/nginx/nginx.conf
            subPath: nginx.conf
        - name: home-assistant
          image: "homeassistant/home-assistant:0.107.4"
          imagePullPolicy: IfNotPresent
          ports:
            - name: api
              containerPort: 8124
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: api
            initialDelaySeconds: 180
            failureThreshold: 5
            timeoutSeconds: 10
          readinessProbe:
            httpGet:
              path: /
              port: api
            initialDelaySeconds: 60
            failureThreshold: 5
            timeoutSeconds: 10
          volumeMounts:
          - mountPath: /config
            name: config-data
          resources:
            limits:
              cpu: 1000m
              memory: 512Mi
            requests:
              cpu: 100m
              memory: 512Mi
      volumes:
      - name: config-data
        persistentVolumeClaim:
          claimName: homeassistant-data-pvc
      - name: nginx-config
        configMap:
          name: home-assistant-nginx-config
          items:
          - key: nginx.conf
            path: nginx.conf
      dnsConfig:
        options:
        - name: ndots
          value: "1"
