apiVersion: apps/v1
kind: Deployment
#make sure to update the name and namespace if you have a different one then I am using. 
metadata:
  name: home-assistant
  namespace: smart-home
  labels:
    app: home-assistant
spec:
  replicas: 1
  selector:
    matchLabels:
      app: home-assistant
  template:
    metadata:
      labels:
        app: home-assistant
    spec:
      containers:
      - name: home-assistant
        imagePullPolicy: Always
#This is where you put the image you're pulling from, usually you'll see this format for where the image lives
        image:         ghcr.io/home-assistant/home-assistant:stable
        env:
          - name: TZ
#This is where you change your timezone.  Format is usually Country/City no spaces!
            value: America/New_York
        ports:
          - containerPort: 80
        volumeMounts:
        #NOTE this is a different name then the others because this is for the configureation files.  Make sure to include config in the name so it's easy to remember what this is later
        - name: home-assistant-config
          mountPath: /config
        - name: shm
          mountPath: /dev/shm
      volumes:
      - name: shm
        emptyDir:
          medium: Memory
      - name: home-assistant-config
        persistentVolumeClaim:
          claimName: home-assistant-config
---
apiVersion: v1
kind: Service
metadata:
  name: home-assistant
  namespace: smart-home-testing
spec:
  ports:
  #must use this port to start
    - port: 8123
      targetPort: 8123
      protocol: TCP
  selector:
    app: home-assistant
  type: LoadBalancer
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
#NOTE this is the config name again, not the regular name because this is part of the persistant volumns
  name: home-assistant-config
  namespace: smart-home
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 500Mi
---
apiVersion: v1
kind: PersistentVolume
metadata:
#NOTE this is the config name again, not the regular name because this is part of the persistant volumns
   name: home-assistant-config
   namespace: smart-home
spec:
   capacity:
     storage: 500Mi
   accessModes:
     - ReadWriteOnce
   hostPath:
   #NOTE:  your path IS NOT my path.  you MUST update this to be your path. You should already have a spot on the server with your kubernetes data, just put in a folder for the homeassistant configs there. 
     path: /YOUR_PATH/config

