---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: home-assistant
  labels:
    app: home-assistant
spec:
  replicas: 1
  selector:
    matchLabels:
      app: home-assistant
  template:
    metadata:
      labels:
        app: home-assistant
    spec:
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
        - name: home-assistant
          image: homeassistant/home-assistant:0.116.2
          ports:
            - containerPort: 8123
          volumeMounts:
            - name: home-assistant-config
              mountPath: /config
            - name: home-assistant-secrets
              mountPath: /root/.gcs_key.json
              subPath: gcs_key.json
            - name: localtime
              mountPath: /etc/localtime
              readOnly: true
          env:
            - name: HTTP_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: http_password
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: db_url
            - name: VACUUM_TOKEN
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: vacuum_token
            - name: MQTT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: mqtt_password
            - name: SPOTIFY_ID
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: spotify_id
            - name: SPOTIFY_SECRET
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: spotify_secret
            - name: INFLUXDB_USERNAME
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: influxdb_username
            - name: INFLUXDB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: influxdb_password
            - name: AQICN_API_TOKEN
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: aqicn_api_token
            - name: HOME_CONNECT_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: home_connect_client_id
            - name: HOME_CONNECT_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: home-assistant-secrets
                  key: home_connect_client_secret
      volumes:
        - name: home-assistant-config
          hostPath:
            path: /home/felix/home-assistant-config
        - name: localtime
          hostPath:
            path: /etc/localtime
        - name: home-assistant-secrets
          secret:
            secretName: home-assistant-secrets
