Home Assistant Helm Chart

repository·main·Indexed 43 days ago

https://github.com/pajikos/home-assistant-helm-chart

A Helm chart to bootstrap and manage Home Assistant deployments on Kubernetes. Supports StatefulSet and Deployment controllers, persistent storage via PVCs, Ingress and Gateway API (HTTPRoute) integration, Prometheus ServiceMonitor, and optional addons like code-server.

Tokens
7.4K
Snippets
18
Records
21
Agent score
6%

What's inside Home Assistant Helm Chart

  1. How controller types (StatefulSet vs Deployment) work

    main

    The chart supports two controller types for deploying Home Assistant. Choosing the right one depends on your persistence requirements:

    1. StatefulSet (default): Recommended for production. It provides stable network identities and persistent storage that survives pod rescheduling. This is the best choice when persistence.enabled is set to true.

    2. Deployment: A simpler controller type. When using a Deployment with persistence enabled, the chart creates a separate PVC instead of using volumeClaimTemplates.

    To switch the controller type, update your configuration:

    controller:
      type: StatefulSet  # or Deployment
  2. Use an existing volume or PVC for persistence

    main

    Depending on your controller.type, you can bind to existing storage instead of dynamic provisioning:

    StatefulSet (Default)

    To use an existing Persistent Volume (PV), specify its name in persistence.existingVolume.

    Deployment

    • To use an existing PVC: Specify the claim name in persistence.existingClaim.
    • To bind to a specific PV: Create a new PVC that binds to the PV by setting persistence.existingVolume.
    # For StatefulSet using an existing PV
    controller:
      type: StatefulSet
    persistence:
      enabled: true
      existingVolume: "my-existing-volume"
    
    # For Deployment using an existing PVC
    controller:
      type: Deployment
    persistence:
      enabled: true
      existingClaim: "my-existing-pvc"
  3. Install Home Assistant via Helm

    main

    You can install the Home Assistant Helm chart using two methods: adding the repository or using the OCI artifact from GitHub Container Registry.

    Method 1: Using Helm Repository

    $ helm repo add pajikos http://pajikos.github.io/home-assistant-helm-chart/
    $ helm repo update
    $ helm install home-assistant pajikos/home-assistant

    Method 2: Using OCI Artifact

    $ helm install home-assistant oci://ghcr.io/pajikos/charts/home-assistant

    To pin a specific release, add the --version <chart version> flag to either command.

  4. Expose Home Assistant via Gateway API (HTTPRoute)

    main

    The chart can render a Kubernetes Gateway API HTTPRoute. This is an alternative to traditional Ingress.

    Prerequisites

    This chart only renders the HTTPRoute resource. You must manually install:

    1. Gateway API CRDs (e.g., via kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.1/standard-install.yaml).
    2. A Gateway controller (e.g., Envoy Gateway, NGINX Gateway Fabric, or Istio) and a Gateway resource.

    Configuration

    • httpRoute.enabled: Enables the route.
    • httpRoute.parentRefs: Required. Defines which Gateway the route attaches to.
    • httpRoute.hostnames: List of hostnames for the route.
    • httpRoute.matches: Defines custom path matching. If empty, it defaults to a PathPrefix: / match.

    Enabling httpRoute automatically applies reverse-proxy settings (use_x_forwarded_for / trusted_proxies) to Home Assistant.

    httpRoute:
      enabled: true
      parentRefs:
        - name: example-gateway
          namespace: gateway-system
      hostnames:
        - home-assistant.example.com
      matches:
        - path:
            type: PathPrefix
            value: /
  5. Migrate from StatefulSet to Deployment controller

    main

    The chart supports both StatefulSet (default/legacy) and Deployment controllers. If you choose to switch to Deployment (by setting controller.type: Deployment), be aware of the following changes:

    1. PVC Naming: The auto-generated PVC for a Deployment is named <fullname>-pvc. This differs from the StatefulSet default. Update any automation or manifests referencing the volume.
    2. Persistence Compatibility:
      • persistence.existingClaim is only supported with Deployment.
      • persistence.existingVolume is only supported with StatefulSet.
    3. Cleanup: Manual cleanup of legacy StatefulSet or PVC resources may be required after migration.
    controller:
      type: Deployment
  6. Configure code-server authentication

    main

    The code-server addon can be enabled via addons.codeserver.enabled: true. While authentication is disabled by default, it is strongly recommended to enable it. You have four ways to configure authentication:

    1. Existing Kubernetes Secret (Recommended for Production): Use a secret containing a password key.
    2. Direct Password: Set the password directly in your Helm values.
    3. Random Password: Let code-server generate one; retrieve it from the container logs.
    4. Disable Authentication: (Not recommended for production).

    To access the addon, you must also enable ingress (addons.codeserver.ingress.enabled: true) or set the service type to NodePort or LoadBalancer.

    # Option 1: Using an existing secret
    addons:
      codeserver:
        enabled: true
        auth:
          enabled: true
          existingSecret: "my-codeserver-secret"
    
    # Option 2: Setting a password directly
    addons:
      codeserver:
        enabled: true
        auth:
          enabled: true
          password: "my-secure-password"
    
    # Option 3: Random password (retrieve via kubectl logs)
    addons:
      codeserver:
        enabled: true
        auth:
          enabled: true
  7. Handle HTTP settings and reverse proxies (Home Assistant 2026.8+)

    main

    Starting with Home Assistant version 2026.8, the http: block in configuration.yaml is deprecated and will stop working in version 2027.2. Settings are now managed in /config/.storage/http via the UI.

    How the chart handles this:

    • For 2026.8+ (or non-semver tags like stable): If ingress or httpRoute is enabled, the chart's init script seeds /config/.storage/http with use_x_forwarded_for and configuration.trusted_proxies only on fresh installs. Existing installations are left untouched to preserve UI-managed settings.
    • For versions older than 2026.8: The chart continues to render the http: block into configuration.yaml.

    Important for existing users upgrading to 2026.8+:

    1. Home Assistant will import your http: block into the UI once and raise a repair issue.
    2. Verify the values in Settings > System > Network.
    3. Manually delete the http: block from your /config/configuration.yaml (the chart will not do this for you).
    4. Note that changing configuration.trusted_proxies in Helm values will not affect a running 2026.8+ instance; you must update proxies via the UI.
  8. Mount additional volumes and devices

    main

    Use additionalVolumes and additionalMounts to attach extra storage or hardware to the Home Assistant container.

    Important: When mounting USB devices (e.g., Zigbee/Z-Wave dongles), you must set securityContext.privileged: true to allow access to the character devices.

    additionalVolumes:
      - hostPath:
          path: /dev/serial/by-id/usb-ITEAD_SONOFF_Zigbee_3.0_USB_Dongle_Plus_V2_20230509111242-if00
          type: CharDevice
        name: usb
    
    additionalMounts:
      - mountPath: /dev/ttyACM0
        name: usb
    
    # Required for USB access
    securityContext:
      privileged: true
  9. Define additional Ingress resources

    main

    For advanced use cases like exposing IoT devices (e.g., DLNA) or specific webhook paths, use additionalIngresses.

    Each additional ingress supports:

    • name: Unique identifier (prefixed with <release>-home-assistant-).
    • className: Ingress class name.
    • rules: A list of rules containing host (optional) and paths.
    • paths: Contains path, pathType (Exact, Prefix, or ImplementationSpecific), serviceName (defaults to main HA service), and servicePort (defaults to service.port).
    • annotations and tls configurations.
    # Example: Exposing a DLNA service via an additional ingress
    additionalPorts:
      - name: dlna
        containerPort: 5555
        protocol: TCP
    
    additionalServices:
      - name: dlna
        port: 5555
        targetPort: dlna
        type: ClusterIP
        protocol: TCP
    
    additionalIngresses:
      - name: dlna
        annotations:
          nginx.ingress.kubernetes.io/ssl-redirect: "false"
        rules:
          - paths:
              - path: /notify
                pathType: Prefix
                serviceName: home-assistant-dlna
                servicePort: 5555
  10. Enable Prometheus ServiceMonitor

    main

    If using the Prometheus Operator, you can enable a ServiceMonitor to scrape Home Assistant metrics. This requires the Prometheus integration to be active in Home Assistant.

    To use bearer token authentication for the metrics endpoint, provide the secretName and secretKey containing the token.

    serviceMonitor:
      enabled: true
      scrapeInterval: 30s
      labels:
        release: prometheus
      bearerToken:
        secretName: "prometheus-token"
        secretKey: "token"