Files
k3s-cluster/homeassistant/homeassistant.yaml
Hermes Platform Engineer 2f1ae311f7 fix(homeassistant): reduce memory requests to 256Mi, add node affinity for raspberrypi
Node roger-nucbox-evo-x2 is at 3.78% memory free causing home-assistant
pods to flap Pending/Running. Reduce resource requests to fit within
cluster capacity and prefer scheduling on raspberrypi (63% mem free).
2026-07-28 12:58:19 +00:00

143 lines
3.5 KiB
YAML

---
apiVersion: v1
kind: Namespace
metadata:
name: home-assistant
---
apiVersion: v1
kind: Service
metadata:
namespace: home-assistant
name: home-assistant
spec:
selector:
app: home-assistant
type: ClusterIP
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8123
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: home-assistant
name: home-assistant-config
data:
configuration.yaml: |
# Loads default set of integrations
default_config:
http:
use_x_forwarded_for: true
trusted_proxies:
- 10.42.0.0/16 # k3s pod CIDR (Traefik pod lives here)
- 10.43.0.0/16 # k3s service CIDR
- 10.88.20.0/24 # node subnet (Traefik runs hostNetwork-ish, forwards from 10.88.20.11)
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: home-assistant
name: home-assistant
labels:
app: home-assistant
spec:
replicas: 1
selector:
matchLabels:
app: home-assistant
template:
metadata:
labels:
app: home-assistant
spec:
containers:
- name: home-assistant
image: ghcr.io/home-assistant/home-assistant:2026.7.4
resources:
requests:
memory: "256Mi"
limits:
memory: "512Mi"
ports:
- containerPort: 8123
volumeMounts:
- name: config
mountPath: /config
- name: localtime
mountPath: /etc/localtime
readOnly: true
- name: dbus
mountPath: /run/dbus
readOnly: true
securityContext:
privileged: true
capabilities:
add:
- NET_ADMIN
- NET_RAW
- SYS_ADMIN
# Seed configuration.yaml from the ConfigMap onto the writable PVC so that
# Home Assistant has a writable configuration.yaml (required for the UI to
# create/save scripts, helpers, reloads, etc.). The ConfigMap stays the
# GitOps source of truth: it is re-copied on every pod start. UI-managed
# entities (scripts, automations, integrations) live in /config/.storage
# on the PVC and are never overwritten by this step.
initContainers:
- name: seed-config
image: busybox:1.36
command: ["/bin/sh", "-c"]
args:
- |
set -e
echo "Seeding /config/configuration.yaml from ConfigMap..."
cp /config-cm/configuration.yaml /config/configuration.yaml
echo "Done."
volumeMounts:
- name: config
mountPath: /config
- name: configuration
mountPath: /config-cm
readOnly: true
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- raspberrypi
hostNetwork: true
volumes:
- name: config
persistentVolumeClaim:
claimName: home-assistant-config
- name: configuration
configMap:
name: home-assistant-config
- name: localtime
hostPath:
path: /etc/localtime
type: File
- name: dbus
hostPath:
path: /run/dbus
type: Directory
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: home-assistant
name: home-assistant-config
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---