apiVersion: v1
kind: Service
metadata:
  name: homeassistant
  namespace: homeassistant
  labels:
    app: homeassistant
spec:
  type: NodePort
  ports:
    - port: 8123
      nodePort: 30097
      targetPort: homeassistant
  selector:
    app: homeassistant
    tier: frontend
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ha-pv-claim
  namespace: homeassistant
  labels:
    app: homeassistant
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ""
  resources:
    requests:
      storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: homeassistant
  namespace: homeassistant
  labels:
    app: homeassistant
spec:
  selector:
    matchLabels:
      app: homeassistant
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: homeassistant
        tier: frontend
    spec:
      containers:
      - image: ghcr.io/home-assistant/home-assistant:stable
        name: homeassistant
        ports:
        - containerPort: 8123
          name: homeassistant
        volumeMounts:
        - name: homeassistant-persistent-storage
          mountPath: /config
      imagePullSecrets:
      - name: reg-cred-secret
      volumes:
      - name: homeassistant-persistent-storage
        persistentVolumeClaim:
          claimName: ha-pv-claim
