This repository contains a Kustomize setup for deploying Home Assistant on Kubernetes. Kustomize is used to manage and configure the Kubernetes resources needed for Home Assistant. This guide provides instructions on how to deploy Home Assistant using Kustomize with FluxCD.
- A Kubernetes cluster (tested with k0s, k3s, and microk8s)
- Kustomize installed (installation guide)
- FluxCD installed and configured for GitOps (Flux installation guide) (optional)
The setup includes:
- A Kubernetes Deployment for Home Assistant
- Service definitions
Clone this repository to your local machine:
git clone https://github.com/turbo5000c/home-assistant-kustomize.git
cd home-assistant-kustomize
The following configuration files may need to be adjusted based on your environment and requirements:
- kustomization.yaml: Uncomment namespace.yaml
- statefulset.yaml: Modify Home Assistant deployment as needed.
- service.yaml Modify the Service as needed.
- ingressroute.yaml Fix to your traefik ingress if using traefik.
To apply the configuration with Kustomize, use the following command:
kubectl apply -k .
This command applies the resources in the current directory, using Kustomize to manage overlays and configurations.
If using FluxCD:
- Ensure your FluxCD setup is configured to watch this repository or a specific directory in it.
- Add the repository to your Flux configuration by referencing it in your
kustomization.yaml
under the FluxCD setup. - Flux will automatically detect changes and apply them to your cluster.
Clone this repository to your local machine:
cd your/fluxcd/apps/base
git clone https://github.com/turbo5000c/home-assistant-kustomize.git
cd home-assistant-kustomize
kustomization.yaml:
apiVersion: kustomize.config.k8s.io/v1beta1
namespace: home-assistant
kind: Kustomization
resources:
- namespace.yaml
- home-assistant-kustomize.yaml
# - ingressroute.yaml #traefik ingressroute
home-assistant-kustomize.yaml:
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: home-assistant
spec:
interval: 2h
ref:
semver: '>=2024.1.1'
url: https://github.com/turbo5000c/home-assistant-kustomize.git
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: home-assistant
spec:
interval: 4h
path: "./"
prune: true
sourceRef:
kind: GitRepository
name: home-assistant
namespace: home-assistant
targetNamespace: home-assistant
# To use hostpath storage uncomment the line below
# Also is an example to mount the host bluetooth
# patches:
# - patch: |
# - op: add
# path: /spec/template/spec/volumes/-
# value:
# name: home-assistant
# hostPath:
# path: /config
# - op: add
# path: /spec/template/spec/containers/0/volumeMounts/-
# value:
# name: home-assistant
# mountPath: /data/home-assistant/
# type: DirectoryOrCreate
# - op: add # bluetooth Start
# path: /spec/template/spec/volumes/-
# value:
# name: bluetooth
# hostPath:
# path: /run/dbus
# - op: add
# path: /spec/template/spec/containers/0/volumeMounts/-
# value:
# name: bluetooth
# mountPath: /run/dbus
# readOnly: true # bluetooth End
# target:
# kind: StatefulSet
# name: home-assistant
By default, this setup deploys all resources into the home-assistant
namespace. If you need to use a different namespace, adjust the metadata.namespace
field in the kustomization.yaml
file and make sure the namespace exists on your cluster:
kubectl create namespace your-namespace
The Persistent Volume Claim (PVC) is configured directly in the StatefulSet manifest. Ensure that the storage class aligns with your cluster’s setup. If necessary, modify the storageClassName
field in the StatefulSet file to match a compatible storage class available on your cluster.
Additionally, review the storage size in the StatefulSet manifest to make sure it meets your storage requirements. Adjust it by updating the resources.requests.storage
field in the manifest as needed.
For example, to update the storage class and size, locate the following section in the StatefulSet file:
volumeClaimTemplates:
- metadata:
name: home-assistant
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 5Gi
After deployment, Home Assistant should be accessible through the configured Service. By default, the service.yaml
file is set up with a ClusterIP service type. Modify it to NodePort
or LoadBalancer
depending on your access needs.
To access Home Assistant via NodePort:
- Retrieve the assigned port:
kubectl get svc -n home-assistant
- Open a browser and navigate to
http://<NODE_IP>:<PORT>
For LoadBalancer setups, use the external IP provided by your cloud provider.
To remove the Home Assistant deployment and its associated resources, run:
kubectl delete -k .
Or, if using FluxCD, remove the repository or folder from your Flux configuration, and Flux will delete the resources on the cluster.
- Logging: To view logs for Home Assistant, use:
kubectl logs -f <pod-name> -n home-assistant
Replace <pod-name>
with the name of the running Home Assistant pod.
This repository is open-source and available under the MIT License.