Skip to content

Repository files navigation

Home Assistant Kubernetes Integration

HACS Custom License: MIT codecov GitHub Release

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

A Home Assistant integration for monitoring and controlling Kubernetes clusters.

Features

  • Cluster Monitoring: Monitor pods, nodes, deployments, statefulsets, daemonsets, cronjobs, ingresses, services, Gateway API HTTPRoutes, HorizontalPodAutoscalers, and cert-manager Certificates
  • Real-Time Updates: The Kubernetes Watch API streams resource changes into Home Assistant within seconds (enabled by default; falls back to interval polling automatically when watch is unavailable; a missing watch permission surfaces as a Missing permissions repair issue)
  • Node Sensors: Per-node sensors for status, IP addresses, memory/CPU resources, real-time CPU/memory usage sensors (absolute and percent of capacity), and system information, plus per-node Ready and pressure binary sensors
  • Cluster Alert Sensors: Degraded Workloads, Problem Pods, Restarting Pods, Nodes Under Pressure, Failed Jobs, and Certificate Problems (cert-manager Certificates that are not Ready, overdue for renewal, or expired) count what needs attention cluster-wide and list the offending resources in an attribute — one automation covers the whole cluster
  • Multi-Namespace Support: Monitor a single namespace or all namespaces
  • Workload Control: Scale, start, stop, and rolling-restart deployments, statefulsets, and daemonsets from Home Assistant; a per-workload replica number entity sets an exact replica count from a dashboard or automation. HPA-managed workloads are detected and flagged, and scaling them to a count the HPA would revert is rejected instead of silently undone
  • Pod Management: Click a pod in the panel for a kubectl describe-style dialog (containers with current and last state, recent events); delete individual pods directly from the sidebar panel (requires HA admin role); per-pod sensors expose container-state diagnostics — CrashLoopBackOff, ImagePullBackOff, OOMKilled (including a recovered OOMKill that already restarted, via last_terminated_reason), and scheduling failures — plus a derived problem/problem_reason attribute for easy automations and alerts; opt-in, admin-only pod log snapshots in the panel's Pods tab (experimental, Configure → Enable pod logs in the panel)
  • Job Management: Delete Jobs (including failed Jobs) via the sidebar panel or kubernetes.delete_job service; cascades to pods
  • CronJob Management: Suspend, resume, and trigger CronJobs from the sidebar panel, via the per-CronJob switch, or via kubernetes.start_workload
  • Node Management: Cordon and uncordon nodes from the sidebar panel, via per-node switches (on = schedulable), or via the kubernetes.cordon_node / kubernetes.uncordon_node services; drain nodes for maintenance with kubernetes.drain_node (Eviction API, honours PodDisruptionBudgets)
  • Dynamic Entity Management: Automatic entity creation and cleanup as cluster resources change
  • Dashboard Panel: Built-in sidebar panel with cluster overview (incl. Kubernetes version), resource counts, health monitoring, and alerts; Workloads tab with start/stop/rolling-restart, CronJob suspend/resume/trigger, and Job deletion; Nodes tab with cordon/uncordon and drain; a Network tab lists Ingresses with clickable URLs, backing service, and TLS status, Gateway API HTTPRoutes with clickable hostname URLs, Gateway and backend references, and Accepted/Not Ready status, cert-manager Certificates with DNS names, issuer, expiry, and status, and Services with type, cluster IP, external addresses (LoadBalancer IPs as clickable links), and ports
  • Diagnostics: Native Home Assistant Diagnostics download with redacted credentials for easier bug reporting
  • System Health: Cluster reachability and aggregate pod/node counts shown in Settings → System → Repairs → System Information
  • Repair Issues: Surfaces silent failures (metrics-server unavailable, watch connection failing, missing RBAC permission for a watched resource) as actionable repair issues with auto-clear once resolved
  • In-Cluster ServiceAccount Support: When Home Assistant runs inside the Kubernetes cluster, the config flow auto-fills host/port/token/CA cert from the pod's ServiceAccount, and an opt-in runtime mode re-reads the bearer token on each request to handle automatic projected-token rotation
  • Cluster Event Platform: Opt-in HA event entity ("Cluster events") per cluster that fires Home Assistant events for Kubernetes cluster activity — OOMKilling, FailedScheduling, BackOff, Evicted, Unhealthy, ImagePullBackOff, and more. Use events to drive automations and alerts. Warning-type events only by default; configurable to include all events. Enable via Configure → Enable Cluster Events
  • Data Collection Opt-Out: Opt out of collecting selected data categories (pods, jobs, ingresses, services, CPU/memory metrics, count sensors, …) to reduce entity count, recorder/database growth, and Kubernetes API load. Switches keep working for opted-out workload types. Configure via Configure → Disable data collection for — see the configuration guide

Requirements

Component Version
Home Assistant 2026.4+
Python 3.13+
Kubernetes 1.35 – 1.37 (the three most recent stable releases)

The integration uses only stable (GA) Kubernetes APIs (apps/v1, batch/v1, networking.k8s.io/v1, autoscaling/v2, core v1) plus, where installed, the Gateway API's gateway.networking.k8s.io/v1, so older clusters may work but are not tested. CI runs the full API compatibility suite against all three listed versions on every PR — see .github/workflows/k8s-compat.yaml. The supported range updates automatically when a new Kubernetes stable release is published.

Installation

HACS (Recommended)

  1. Ensure HACS is installed
  2. Search for "Kubernetes" and install
  3. Restart Home Assistant

Manual Installation

  1. Copy custom_components/kubernetes to your config/custom_components/ directory
  2. Restart Home Assistant

Setup

  1. Configure Kubernetes Service Account — with the Helm chart (recommended, so helm upgrade keeps the permissions current):

    # Full permissions: monitoring + switches + Watch API
    helm install ha-k8s-rbac oci://ghcr.io/tibuntu/charts/homeassistant-kubernetes-rbac \
      --namespace homeassistant --create-namespace
    
    # Extract the token
    kubectl get secret homeassistant-kubernetes-integration-token -n homeassistant -o jsonpath='{.data.token}' | base64 -d

    Or with plain manifests, if you don't use Helm:

    kubectl apply -f https://raw.githubusercontent.com/tibuntu/homeassistant-kubernetes/refs/heads/main/manifests/full/serviceaccount.yaml
    kubectl apply -f https://raw.githubusercontent.com/tibuntu/homeassistant-kubernetes/refs/heads/main/manifests/full/clusterrole.yaml
    kubectl apply -f https://raw.githubusercontent.com/tibuntu/homeassistant-kubernetes/refs/heads/main/manifests/full/clusterrolebinding.yaml
    kubectl apply -f https://raw.githubusercontent.com/tibuntu/homeassistant-kubernetes/refs/heads/main/manifests/full/serviceaccount-token-secret.yaml

    Already applied the manifests? Add --take-ownership to the helm install so Helm adopts the existing objects instead of failing on ownership metadata (Helm 3.17+). Same names, same permissions — nothing is recreated. See RBAC.

    Minimal permissions: If you only need read-only sensors and binary sensors (no switches, no Watch API), add --set mode=minimal to the Helm command — or replace full with minimal in the manifest URLs. See the RBAC Reference Guide for a full comparison and all chart values.

    Home Assistant inside the cluster? Add --set tokenSecret.create=false and bind the ServiceAccount to the HA pod instead — see the Setup Guide for automatic token rotation.

  2. Add Integration:

    • Go to Settings → Devices & Services
    • Add "Kubernetes" integration
    • Enter your cluster details and the token from step 1
    • Uncheck Prefer in-cluster ServiceAccount token if it is enabled — while it is on, the integration authenticates with the token file mounted into the Home Assistant pod and only uses the token you entered as a fallback

Known limitations

  • CPU and memory need metrics-server. Without it the workload and node CPU/memory sensors stay empty and a repair issue says so. The panel's Pods table and workload cards show the same usage, as - or hidden when the cluster has no metrics. With the Watch API on (the default), metrics refresh every 5 minutes, because the Metrics API cannot be watched. Usage of a workload only counts pods the integration collects, so Job-owned pods do not count while Exclude Job pods is on.
  • Pod, Job and node customizations expire an hour after the resource is gone. Their names are usually generated, so the entity-registry records of removed ones are purged to keep the registry from growing without bound. A StatefulSet pod or node that comes back later than that gets a fresh entity without its earlier entity_id, name or area.
  • HPA-managed workloads cannot be scaled to a fixed count. The HorizontalPodAutoscaler would revert it, so scaling to anything but 0 is rejected; change the HPA's min/max replicas instead. Turning the switch back on hands control back to the HPA. See HPA-managed workloads.
  • Ingresses, HTTPRoutes, and Services have no per-resource entities — only count sensors and the sidebar panel's Network tab (HTTPRoutes have no count sensor at all). There are no PersistentVolumeClaim / storage sensors.
  • HTTPRoutes need the Gateway API CRDs installed (gateway.networking.k8s.io/v1, Gateway API 1.0+) and are entirely optional — without them, or without the RBAC rule, the Network tab simply shows no HTTPRoutes section. The integration does not fetch the referenced Gateway, so it cannot know whether a route is TLS-terminated; the clickable link is https only when the route's parentRef pins port 443 or names a listener containing "https", "tls" or "websecure", else http — it may be wrong for other listener names or routes that attach to every listener.
  • Certificates need cert-manager (cert-manager.io/v1): without it there is no Certificates section, and the Certificate Problems sensor stays at 0 — disable Certificates under Configure → Disable data collection for to remove it. There are no per-certificate entities, and the TLS Secret is never read, so only what cert-manager reports in the Certificate's status is known (certificates managed outside cert-manager are not seen).
  • Pods of Jobs and CronJobs are hidden by default, so a failed Job run does not show up as a problem pod. Use the Failed Jobs sensor, the Job sensor or the Cluster Events entity instead, or switch the filter off (details).
  • The minimal RBAC set is read-only: no switches, restarts, deletions, pod logs, cluster events or pod events, and no Watch API — the integration falls back to polling (details).
  • A namespace-scoped ServiceAccount sees no cluster-wide resources such as nodes (details).
  • Services have no admin check. The sidebar panel hides mutation buttons from non-admin users, but Home Assistant cannot restrict who calls scale_workload, cordon_node and the other services (details).
  • Large clusters create many entities — one sensor per pod, plus per-workload, per-node and per-Job entities. Turn off categories you don't need under Configure → Disable data collection for (details).
  • Replica numbers go up to 100, and pod logs are polled snapshots (experimental; long lines wrap, optional 5 s auto-refresh, but no live streaming; capped at 256 KiB).
  • drain_node does not wait for evicted pods to terminate, and it skips pods without a controller (unless force is set) and the pod Home Assistant runs in. Without a mounted ServiceAccount token, it recognises that pod only by hostname and namespace: then it misses it with hostNetwork: true or a custom hostname, and it can skip a same-named pod in another cluster (details).
  • The cluster name cannot be changed after setup; it identifies the config entry. Remove and re-add the integration to rename it.

Removal

  1. Go to Settings → Devices & Services → Kubernetes, open the ⋮ menu of each cluster entry and choose Delete. This removes its devices, entities and repair issues; the sidebar panel disappears with the last entry.
  2. Uninstall the integration in HACS (or delete custom_components/kubernetes/) and restart Home Assistant.
  3. Remove the cluster-side RBAC: helm uninstall ha-k8s-rbac --namespace homeassistant, or kubectl delete -f on the four manifest URLs from step 1 of Setup. Either way the token Secret is deleted and the token stops working; the homeassistant namespace itself stays (kubectl delete namespace homeassistant if nothing else lives there).

Documentation

For full documentation, visit the documentation site.

Quality

Custom integrations are not part of Home Assistant's official Integration Quality Scale, but this integration voluntarily meets all Bronze, Silver and Gold tier requirements. In practice this means:

  • Fully UI-based setup with connection validation, duplicate detection, a reconfigure flow, and a re-authentication prompt when the API token becomes invalid
  • Service calls that surface errors in the UI and in automation traces instead of failing silently
  • An enforced test-coverage gate of 95% overall; the config flow is kept at 100% by convention
  • Clean config entry lifecycle handling (typed runtime data, proper unload, no leftovers)
  • Translated entity names, icons and error messages, diagnostic entity categories, and automatic removal of devices and entities for resources that no longer exist

These requirements are maintained for every change as part of code review. The status of every rule, including the open Platinum ones, is tracked in quality_scale.yaml.

Contributing

Contributions are welcome. Please submit a Pull Request or refer to the Development Guide to get started.

Contributors

License

This project is licensed under the MIT License - see the LICENSE file for details.