Home Assistant Setup on Kubernetes

Install the k8s cluster if not alreadly installed

1
2
microk8s enable dns storage helm3
microk8s status

Add the helm Repo

1
microk8s helm repo add alekc-charts https://charts.alekc.dev/

Install the helm chart

1
microk8s helm install home-assistant alekc-charts/home-assistant

Check the status of the installed application.

1
2
microk8s status
microk8s kubectl describe pods

Service yaml file

We need to expose the service to the outside world.
Thankfully microk8s has a built in loadbalancer called metallb

1
nano home-assistant-service.yaml

Replace port_number with the real port number

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
apiVersion: v1
kind: Service
metadata:
name: home-assistant-service
spec:
type: LoadBalancer
selector:
app.kubernetes.io/name: home-assistant
ports:
- name: webportal
protocol: TCP
port: port_number
targetPort: port_number
externalIPs:
- A.B.C.D

Apply the service

1
microk8s kubectl apply -f ./home-assistant-service.yaml

Confirm the service is active

1
microk8s kubectl describe services home-assistant-service

Firewall Rules

This assumes you are using ufw.
ufw is bascally a wrapper for IPTABLES. If you have ever used IPTABLES before you understand why ufw exists.
Replace port_number with the real port number

1
2
3
4
sudo ufw default allow routed 
sudo ufw allow from A.B.C.0/24 to any port port_number proto tcp
sudo ufw allow from D.E.F.0/24 to any port port_number proto tcp
sudo ufw status