Entities Documentation¶
This document describes all sensors, binary sensors, switches, and number entities provided by the Kubernetes integration.
Sensors¶
The integration provides the following sensors to monitor your Kubernetes cluster:
| Sensor | Description | Example Value | Unit |
|---|---|---|---|
| Pods Count | Number of pods in the monitored namespace(s) | 15 |
pods |
| Nodes Count | Number of nodes in the cluster | 3 |
nodes |
| Deployments Count | Number of deployments in the monitored namespace(s) | 8 |
deployments |
| StatefulSets Count | Number of statefulsets in the monitored namespace(s) | 2 |
statefulsets |
| DaemonSets Count | Number of daemonsets in the monitored namespace(s) | 3 |
daemonsets |
| CronJobs Count | Number of cronjobs in the monitored namespace(s) | 5 |
cronjobs |
| Jobs Count | Number of jobs in the monitored namespace(s) | 3 |
jobs |
| Ingresses Count | Number of ingresses in the monitored namespace(s) | 4 |
ingresses |
| Services Count | Number of services in the monitored namespace(s) | 12 |
services |
Cluster Alert Sensors¶
Six per-cluster sensors count resources that currently need attention, so a single automation can cover the whole cluster. They use the same rules as the sidebar panel's Overview alerts, so both always agree. The offending resources are listed in an attribute; that list is excluded from the recorder (history keeps the count only).
| Sensor | Counts | Attribute | Unit |
|---|---|---|---|
| Degraded Workloads | Deployments with fewer available, StatefulSets with fewer ready, and DaemonSets with fewer available replicas than desired, plus Deployments whose rollout is stalled (workloads scaled to 0 are ignored) | workloads: list of {name, type, namespace, ready, desired, reason} — reason is ProgressDeadlineExceeded for a stalled rollout, otherwise null |
workloads |
| Problem Pods | Pods whose problem flag is set (CrashLoopBackOff, ImagePullBackOff, non-zero exit, init-container failures, phase Failed, Unschedulable — see Pod sensors) plus pods in phase Unknown |
pods: list of {name, namespace, phase, reason} (reason is the pod's problem_reason, or the phase when there is none — e.g. Unknown) |
pods |
| Restarting Pods | Pods in a restart loop that may look healthy right now: at least 3 restarts in total (summed across containers) and the latest container termination finished within the last 60 minutes. Catches pods that OOM or crash and come back Running before the next update, which Problem Pods misses |
pods: list of {name, namespace, restarts, last_terminated_reason, last_terminated_exit_code, last_terminated_at} (the reason and exit code are from the first container with a previous termination) |
pods |
| Nodes Under Pressure | Nodes with Memory/Disk/PID Pressure or Network Unavailable | nodes: list of {name, conditions} |
nodes |
| Failed Jobs | Jobs whose terminal Failed condition (e.g. BackoffLimitExceeded, DeadlineExceeded) was set within the last 24 hours. A Job still retrying below its backoffLimit is not counted, and a failed CronJob run drops out as soon as a later run of the same CronJob succeeds. A failed Job that Kubernetes deletes earlier (ttlSecondsAfterFinished, failedJobsHistoryLimit: 0) drops out with it, so for "did the backup run?" also watch the CronJob's last_successful_time |
jobs: list of {name, namespace, cronjob, reason, message, failed_at} (cronjob is the owning CronJob, null for a standalone Job) |
jobs |
| Certificate Problems | cert-manager Certificates that need attention: not Ready, or their renewal time (status.renewalTime) passed more than 24 hours ago (cert-manager failed to renew them), or already expired (status.notAfter in the past). Deliberately independent of the certificate lifetime, so it works for 90-day and 6-day certificates alike. Stays at 0 without cert-manager |
certificates: list of {name, namespace, reason, message, not_after, renewal_time} — reason is Expired, the Ready condition's reason when not Ready (e.g. DoesNotExist, NotReady without one), or RenewalOverdue |
certificates |
Gating: Problem Pods and Restarting Pods are not created when Pods is disabled under Configure → Disable data collection for, Nodes Under Pressure when Node sensors is disabled, Failed Jobs when Jobs is disabled, Certificate Problems when Certificates is disabled (it exists, at 0, on clusters without cert-manager — disable the category to hide it), and Degraded Workloads only when Deployment sensors, StatefulSet sensors and DaemonSets are all disabled.
Individual Node Sensors¶
The integration creates a separate sensor for each Kubernetes node in the cluster:
| Sensor | Description | Example Value | Unit |
|---|---|---|---|
| Node [node-name] | Individual node status and information | Ready / NotReady / Unknown |
- |
| [node-name] CPU Usage | Current CPU usage from metrics-server | 850 |
m |
| [node-name] Memory Usage | Current memory usage from metrics-server | 4096 |
MiB |
| [node-name] CPU Usage Percent | CPU usage as a percentage of the node's CPU capacity | 21.3 |
% |
| [node-name] Memory Usage Percent | Memory usage as a percentage of the node's memory capacity | 25.0 |
% |
The four usage sensors need metrics-server; without it (or when the fetch fails) they show unknown. They are not created when Node sensors or CPU/memory metrics is disabled under Configure → Disable data collection for. Percentages are relative to node capacity, the same base as the sidebar panel's Nodes tab. kubectl top node divides by allocatable instead, so its percentages are slightly higher. With the Watch API on, usage values refresh at the 300 s poll interval, not with every node event.
Individual DaemonSet Sensors¶
The integration creates a separate sensor for each Kubernetes DaemonSet in the monitored namespace(s):
| Sensor | Description | Example Value |
|---|---|---|
| [daemonset-name] | Individual DaemonSet readiness status | Ready / Degraded / Not Ready / Unknown |
DaemonSet Sensor Attributes¶
Each DaemonSet sensor provides scheduling and readiness information:
| Attribute | Description | Example Value |
|---|---|---|
| namespace | Kubernetes namespace of the DaemonSet | kube-system |
| desired | Number of nodes that should run the DaemonSet pod | 3 |
| current | Number of nodes currently running the DaemonSet pod | 3 |
| ready | Number of nodes where the pod is ready | 3 |
| available | Number of nodes where the pod is available | 3 |
Each DaemonSet also gets CPU and memory usage sensors, described under Workload Metric Sensors.
Status values:
- Ready — all desired pods are ready (ready >= desired)
- Degraded — some but not all pods are ready (0 < ready < desired)
- Not Ready — no pods are ready (ready == 0)
- Unknown — data is unavailable or no nodes are scheduled
Workload Status Sensors¶
The integration creates a readiness status sensor for each deployment and statefulset:
| Sensor | Description | Example Value |
|---|---|---|
| [workload-name] | Readiness status of the workload | Ready / Rollout Stalled / Degraded / Not Ready / Scaled Down / Unknown |
Status values:
- Rollout Stalled — Deployments only: Kubernetes marked the rollout Progressing=False with reason ProgressDeadlineExceeded (no progress within progressDeadlineSeconds, 600 s by default). Takes priority over the readiness states below, because the old pods usually stay ready while the new ones fail. StatefulSets do not report this condition; a broken StatefulSet update already shows as Degraded.
- Ready — all desired replicas are ready (ready_replicas >= replicas > 0). The ready count can briefly exceed the desired count during a surge rollout or right after a scale-down; that still counts as Ready
- Degraded — some but not all replicas are ready (0 < ready_replicas < replicas)
- Not Ready — no replicas are ready (ready_replicas == 0 and replicas > 0)
- Scaled Down — workload is intentionally scaled to zero (replicas == 0)
- Unknown — data is unavailable
Each sensor exposes the following attributes: namespace, replicas, ready_replicas, available_replicas, updated_replicas, rollout_reason (ProgressDeadlineExceeded while the rollout is stalled, otherwise null).
Workload Metric Sensors¶
The integration creates CPU and memory usage sensors for each deployment, statefulset and daemonset. These sensors read live data from the metrics-server and require it to be installed in your cluster.
| Sensor | Description | Example Value | Unit |
|---|---|---|---|
| [workload-name] CPU Usage | Aggregated CPU usage across all pods of the workload | 142 |
m (millicores) |
| [workload-name] Memory Usage | Aggregated memory usage across all pods of the workload | 256 |
MiB |
If two workloads of different kinds in the same namespace share a name (for example a Deployment and a DaemonSet both called web), both sensors are named web CPU Usage, so Home Assistant adds a _2 suffix to one of the entity IDs.
The memory sensor uses the data_size device class, so Home Assistant can display it in another unit (for example GiB) via the entity settings. CPU usage has no matching device class.
These sensors expose numeric values with SensorStateClass.MEASUREMENT, making them suitable for history tracking and use in automations:
# Scale up a deployment when CPU usage exceeds 800 millicores
trigger:
- platform: numeric_state
entity_id: sensor.my_app_cpu_usage
above: 800
action:
- service: kubernetes.scale_workload
data:
workload_name: my-app
namespace: default
replicas: 3
Note: If metrics-server is not installed, these sensors will report
0.
Tip: These sensors change on nearly every update cycle and are the biggest contributors to recorder/database growth. If you don't need them, disable the CPU/memory metrics category via Configure → Disable data collection for — see the data collection opt-out. The same option can disable other entity categories (per-pod sensors, count sensors, …) entirely.
Individual Pod Sensors¶
The integration creates a separate sensor for each Kubernetes pod in the monitored namespace(s):
| Sensor | Description | Example Value | Unit |
|---|---|---|---|
| Pod [pod-name] | Individual pod phase and information | Running / Pending / Failed / Succeeded / Unknown |
- |
Node Sensor Attributes¶
Each node sensor provides comprehensive information about the node:
| Attribute | Description | Example Value |
|---|---|---|
| internal_IP | Internal IP address of the node | 10.0.0.1 |
| external_IP | External IP address of the node | 203.0.113.1 |
| memory_capacity_(GiB) | Total memory capacity | 16 GiB |
| memory_allocatable_(GiB) | Allocatable memory | 14.5 GiB |
| CPU | Number of CPU cores | 4 vCPU |
| OS_image | Operating system image | Ubuntu 22.04.3 LTS |
| kernel_version | Kernel version | 5.15.0-56-generic |
| container_runtime | Container runtime version | containerd://1.6.6 |
| kubelet_version | Kubelet version | v1.25.4 |
| schedulable | Whether the node can schedule new pods | true / false |
| creation_timestamp | When the node was created | 2023-01-01T00:00:00Z |
Note: Real-time CPU/memory usage is exposed by the separate usage sensors listed under Individual Node Sensors, not as attributes on this sensor.
Pod Sensor Attributes¶
Each pod sensor provides comprehensive information about the pod:
| Attribute | Description | Example Value |
|---|---|---|
| namespace | Kubernetes namespace where the pod is located | default |
| phase | Current phase of the pod (useful for filtering with auto-entities) | Running / Pending / Failed / Succeeded / Unknown |
| ready_containers | Number of ready containers in the pod | 2 |
| total_containers | Total number of containers in the pod | 2 |
| restart_count | Total number of container restarts | 0 |
| node_name | Name of the node where the pod is running | worker-node-1 |
| pod_ip | IP address of the pod | 10.244.1.5 |
| creation_timestamp | When the pod was created | 2023-01-01T00:00:00Z |
| owner_kind | Type of resource that owns this pod | ReplicaSet |
| owner_name | Name of the resource that owns this pod | my-app-7d4b8c9f6b |
| container_waiting_reason | Reason the first container found in a waiting state is waiting (present only when waiting) | CrashLoopBackOff / ImagePullBackOff / ContainerCreating |
| container_terminated_reason | Reason the first container found terminated in the current run (present only when terminated) | OOMKilled / Error |
| container_terminated_exit_code | Exit code of the current container termination | 137 |
| last_terminated_reason | Reason the first container found terminated in its previous run — catches an OOMKilled that has already restarted | OOMKilled |
| last_terminated_exit_code | Exit code of the previous container termination | 137 |
| pending_reason | Reason the pod is stuck in Pending (present only when Pending) | Unschedulable |
| problem | true when the pod is currently in a broken state (non-benign waiting reason or non-zero exit code in any container, including init containers; phase Failed, or Unschedulable Pending); false otherwise — recovered OOMKills and transient ContainerCreating do not set this |
true / false |
| problem_reason | Human-readable explanation of why problem is true; absent when problem is false |
CrashLoopBackOff / OOMKilled / Unschedulable / Init:CrashLoopBackOff (init containers are prefixed with Init:) |
Note on
problem/problem_reason: These derived attributes are designed for automations and alerts. A pod that OOMKilled but has since restarted successfully will havelast_terminated_reason: OOMKilledyetproblem: false— the flag only fires when the pod is currently broken, not for historical events.
Note on container selection: These attributes reflect the pod's application containers (
containerStatuses); the per-container reason attributes above reflect the first application container found, whileproblemconsiders every application container and the init containers (initContainerStatuses), reporting an init-container failure with anInit:prefix similar tokubectl(e.g.Init:CrashLoopBackOff). Exit codes of native sidecars (init containers withrestartPolicy: Always) are ignored, because Kubernetes stops them after the app containers exit; a crash-looping sidecar still counts.
Individual Job Sensors¶
The integration creates a separate sensor for each Kubernetes Job in the monitored namespace(s):
| Sensor | Description | Example Value |
|---|---|---|
| [job-name] | Individual Job status | Complete / Failed / Suspended / Running / Retrying / Pending / Unknown |
Status values:
- Complete — the Job's Complete condition is set (or, without conditions, succeeded >= completions)
- Failed — the Job's terminal Failed condition is set: it ran out of retries (BackoffLimitExceeded) or time (DeadlineExceeded). The reason attribute says which
- Suspended — the Job is suspended (spec.suspend: true)
- Running — the job has active pods (active > 0)
- Retrying — pods failed, but the Job has not given up yet (failed > 0, below its backoffLimit)
- Pending — no pod has run yet
- Unknown — data is unavailable
Before 1.16, a Job with failed pods and no active ones already read Failed while it was still retrying, and a Job that had not started read Unknown. Automations that matched Failed now fire only on the final failure.
Job Sensor Attributes¶
Each Job sensor provides execution details:
| Attribute | Description | Example Value |
|---|---|---|
| namespace | Kubernetes namespace of the Job | default |
| completions | Number of completions required | 1 |
| succeeded | Number of successfully completed pods | 1 |
| failed | Number of failed pods | 0 |
| active | Number of currently active pods | 0 |
| start_time | When the Job started | 2025-01-01T00:00:00Z |
| completion_time | When the Job completed | 2025-01-01T00:05:00Z |
| backoff_limit | Retries allowed before the Job fails (spec.backoffLimit, Kubernetes default 6) |
6 |
| cronjob | Owning CronJob, null for a standalone Job |
backup |
| reason | Reason of the terminal Complete/Failed condition, null while the Job runs |
BackoffLimitExceeded |
Individual CronJob Sensors¶
The integration creates a separate status sensor for each Kubernetes CronJob in the monitored namespace(s), in addition to the CronJob switch that controls suspension:
| Sensor | Description | Example Value |
|---|---|---|
| [cronjob-name] | Individual CronJob status | Suspended / Active / Scheduled / Unknown |
Status values:
- Suspended — the CronJob's suspend field is true
- Active — the CronJob is not suspended and has at least one currently active Job (active_jobs_count > 0)
- Scheduled — the CronJob is not suspended and has no active Jobs
- Unknown — data is unavailable
CronJob Sensor Attributes¶
| Attribute | Description | Example Value |
|---|---|---|
| namespace | Kubernetes namespace of the CronJob | default |
| schedule | The cron schedule expression | 0 2 * * * |
| last_schedule_time | Last time the CronJob was scheduled | 2025-01-01T02:00:00Z |
| last_successful_time | Last time a Job of this CronJob completed successfully (null until the first success). Alert when it is older than the schedule interval plus some slack — this also catches runs that never started or Jobs deleted before the Failed Jobs sensor saw them |
2025-01-01T02:03:12Z |
| next_schedule_time | Next scheduled execution time | 2025-01-02T02:00:00Z |
| active_jobs_count | Number of currently active Jobs | 0 |
Sensor Attributes¶
The cluster-wide count sensors (Pods Count, Nodes Count, Deployments Count, etc.) expose no extra attributes — only the numeric state. The per-resource sensors documented above (Node, Pod, DaemonSet, Job, CronJob, Workload Status) each expose their own set of attributes; see their respective sections for the exact keys.
Binary Sensors¶
| Binary Sensor | Description | States |
|---|---|---|
| Cluster Health | Indicates if the cluster is reachable and responding | on (healthy) / off (unhealthy) |
Cluster Health and the node condition binary sensors below are diagnostic entities (entity_category: diagnostic): Home Assistant lists them in the device's Diagnostic section and leaves them out of auto-generated dashboards, but they work in automations, history and manually built dashboards like any other entity.
Node Condition Binary Sensors¶
The integration creates binary sensors for each node condition on every node in the cluster:
| Binary Sensor | Description | Device Class |
|---|---|---|
| [node-name] Ready | Node reports the Ready condition |
connectivity |
| [node-name] Memory Pressure | Node is running low on memory | problem |
| [node-name] Disk Pressure | Node is running low on disk space | problem |
| [node-name] PID Pressure | Node is running too many processes | problem |
| [node-name] Network Unavailable | Node network is not correctly configured | problem |
- States: for the pressure / network sensors
onmeans the condition is active (problem detected) andoffmeans normal operation; Ready is the other way round —onwhile the node is Ready,offwhen it is NotReady - Device assignment: Assigned to the cluster device alongside individual node sensors
Switches¶
The integration automatically creates switches for controlling Kubernetes workloads:
Deployment Switches¶
- Entity ID Format:
switch.[cluster_name]_[namespace]_[deployment_name](e.g.switch.production_default_web_app) - Function: Control individual deployments (scale to 0/1 replicas)
- States:
on: Deployment is running (replicas > 0)off: Deployment is stopped (replicas = 0)
StatefulSet Switches¶
- Entity ID Format:
switch.[cluster_name]_[namespace]_[statefulset_name](e.g.switch.production_default_postgres) - Function: Control individual statefulsets (scale to 0/1 replicas)
- States:
on: StatefulSet is running (replicas > 0)off: StatefulSet is stopped (replicas = 0)
CronJob Switches¶
- Entity ID Format:
switch.[cluster_name]_[namespace]_[cronjob_name](e.g.switch.production_default_backup) - Function: Control CronJob suspension
- States:
on: CronJob is enabled (suspend=false)off: CronJob is suspended (suspend=true)
Node Schedulable Switches¶
- Entity ID Format:
switch.[cluster_name]_[node_name]_schedulable - Function: Cordon / uncordon individual nodes (patches
spec.unschedulable) - States:
on: Node is schedulable (uncordoned)off: Node is cordoned (unschedulable — running pods keep running, no new pods are scheduled)- Attributes:
node_name,status,schedulable,cordoned,last_cordon_time,last_uncordon_time - Requires: the
patchverb onnodes(included inmanifests/full/)
Switch Features¶
- Real-time State: Switches automatically reflect the actual Kubernetes state through the Watch API (default) or interval polling
- Error Recovery: If scaling operations fail, switches automatically recover the correct state
- State Verification: Verifies that scaling operations actually took effect
- Configurable Polling: Adjust the coordinator's update interval to balance responsiveness and API load — switches are not polled individually, they update from the shared coordinator data
- Failure Indication: Shows when the last scaling attempt failed via entity attributes
Switch Attributes¶
Deployment and StatefulSet switches (KubernetesReplicaWorkloadSwitch) expose:
| Attribute | Description | Example Value |
|---|---|---|
| deployment_name / statefulset_name | Name of the workload (key matches the resource type) | web-app |
| namespace | Kubernetes namespace | default |
| replicas | Current number of replicas | 3 |
| workload_type | Deployment or StatefulSet |
Deployment |
| last_scale_attempt_failed | true if the most recent scale operation failed |
false |
| cpu_usage_(millicores) | Aggregated CPU usage across the workload's pods | 142 |
| memory_usage_(MiB) | Aggregated memory usage across the workload's pods | 256 |
| hpa_managed | true if a HorizontalPodAutoscaler targets the workload |
true |
| hpa_name | Name of that HPA (null when unmanaged) |
web-app |
| hpa_min_replicas / hpa_max_replicas | The HPA's replica bounds (null when unmanaged) |
2 / 10 |
CronJob switches expose: namespace, cronjob_name, schedule, suspend, suspended (alias of suspend), active_jobs_count, last_schedule_time, next_schedule_time, last_suspend_time, last_resume_time, workload_type.
Node schedulable switches expose the attributes listed under Node Schedulable Switches above: node_name, status, schedulable, cordoned, last_cordon_time, last_uncordon_time.
Number Entities¶
Replica Numbers¶
Every Deployment and StatefulSet also gets a number entity for setting an exact replica count, from a dashboard (input box) or an automation (number.set_value).
- Entity ID Format:
number.[cluster_name]_[namespace]_[workload_name]_replicas(e.g.number.production_default_web_app_replicas) - Value: the desired replica count (
spec.replicas), range 0–100, step 1 - Setting a value scales the workload through the
scalesubresource; a failed scale raises an error instead of failing silently - Device: same device as the workload's switch (namespace device, or the cluster device in
clustergrouping mode) - Attributes:
namespace,workload_type,ready_replicas,available_replicas, plus thehpa_*attributes listed under Switch Attributes - Opt-out: removed when the workload type is in Disable data collection for (unlike the switch, which stays)
- Requires: the
patchverb ondeployments/scale/statefulsets/scale(included inmanifests/full/)
The switch and the number are two views of the same field: setting the number to 0 turns the switch off, and switching off shows 0 after the next refresh.
Replica limit: the range tops out at 100. A workload running more replicas still shows its real count, but Home Assistant rejects setting a value above 100.
HPA-managed workloads¶
A HorizontalPodAutoscaler resets spec.replicas within its sync period (15 s by default), so a manually set count would silently revert. The integration therefore detects HPAs (hpa_managed attribute) and:
- rejects setting the number, or calling
kubernetes.scale_workload, to any value other than0with a validation error — adjust the HPA'sminReplicas/maxReplicasinstead; - allows scaling to
0(switch off,stop_workload, number0): the HPA controller skips targets at 0 replicas, so this sticks; - allows turning the switch on /
start_workload: this re-enables the HPA, which then picks its own count (the switch does not wait for exactly 1 replica).
HPA detection needs the autoscaling RBAC rule (see RBAC). Opting out of HorizontalPodAutoscalers under Disable data collection for turns detection off.
Cluster Events¶
The integration provides an opt-in event entity per cluster that fires Home Assistant events whenever the Kubernetes cluster emits an event (e.g. a pod is OOM-killed, scheduling fails, a container enters CrashLoopBackOff).
Entity¶
| Entity | Description |
|---|---|
| Cluster events | Fires a Home Assistant event for each matching Kubernetes cluster event |
The entity is only created when Enable Cluster Events is turned on under Settings → Devices & Services → Kubernetes → Configure. It is disabled by default.
Event types¶
Each fired Home Assistant event has an event_type derived from the Kubernetes event reason. A curated set of reasons are surfaced as distinct types; any unrecognised reason maps to other:
event_type |
Kubernetes reason |
|---|---|
OOMKilling |
Container killed by the OOM killer |
BackOff |
Container image pull or restart back-off |
Failed |
Generic failure (e.g. mount failure, exec failure) |
FailedScheduling |
Scheduler could not place the pod |
FailedMount |
Volume mount failure |
FailedAttachVolume |
Volume attachment failure |
Unhealthy |
Liveness or readiness probe failure |
Evicted |
Pod evicted from the node |
FailedCreatePodSandBox |
Container runtime sandbox creation failure |
NodeNotReady |
Node transitioned to NotReady |
ImagePullBackOff |
Image pull back-off |
ErrImagePull |
Image pull error |
Preempted |
Pod preempted by a higher-priority pod |
FailedKillPod |
Pod termination failure |
other |
Any Kubernetes reason not in the list above |
Event attributes¶
Each fired event carries the following attributes:
| Attribute | Description | Example |
|---|---|---|
reason |
Raw Kubernetes event reason | OOMKilling |
type |
Kubernetes event type | Warning / Normal |
involved_kind |
Kind of the involved object | Pod / Node |
involved_name |
Name of the involved object | my-app-7d4b8c9f6b-xv2p1 |
namespace |
Namespace of the event | default |
message |
Full event message from Kubernetes | Killing container with id ... |
count |
How many times this event has been seen | 3 |
event_time |
Last occurrence timestamp | 2025-01-01T12:00:00Z |
Filtering¶
By default only Warning-type Kubernetes events are dispatched. To also receive Normal-type events, set Event Types to all in Configure → Event Types.
Note: The watch loop anchors to the current resource version on startup so that existing events in the cluster are not replayed. Only events that occur after the integration starts are fired.
Note: Recurring conditions fire repeatedly — Kubernetes increments an existing event's count, so e.g. a CrashLoopBackOff pod emits an event on each retry.
Example automation¶
automation:
- alias: Notify on pod OOMKill
trigger:
- platform: state
entity_id: event.my_cluster_cluster_events
condition:
- condition: template
value_template: "{{ trigger.to_state.attributes.event_type == 'OOMKilling' }}"
action:
- service: notify.notify
data:
message: >-
OOMKilled: {{ trigger.to_state.attributes.involved_name }}
in {{ trigger.to_state.attributes.namespace }}
Device Organization¶
The integration organizes entities using Home Assistant's device system, creating a hierarchical structure that makes it easier to manage large clusters:
Device Hierarchy¶
Cluster Device (e.g., "production-cluster")
├── Cluster-level entities:
│ ├── Cluster Health (binary_sensor)
│ ├── Nodes Count (sensor)
│ ├── Pods Count (sensor)
│ ├── Deployments Count (sensor)
│ ├── StatefulSets Count (sensor)
│ ├── DaemonSets Count (sensor)
│ ├── CronJobs Count (sensor)
│ ├── Jobs Count (sensor)
│ ├── Ingresses Count (sensor)
│ ├── Services Count (sensor)
│ ├── Degraded Workloads / Problem Pods / Restarting Pods / Nodes Under Pressure / Failed Jobs / Certificate Problems (sensors)
│ ├── Cluster events (event — opt-in, only when enable_events is on)
│ ├── Individual Node sensors (one per node)
│ ├── Node condition binary sensors (5 per node: Ready, Memory/Disk/PID Pressure, Network Unavailable)
│ └── Node schedulable switches (one per node: cordon / uncordon)
│
└── Namespace Devices (e.g., "production-cluster: default")
├── Pod sensors (all pods in this namespace)
├── Deployment switches and replica numbers (all deployments in this namespace)
├── Deployment status sensors (one per deployment)
├── Deployment CPU/memory sensors (one pair per deployment)
├── StatefulSet switches and replica numbers (all statefulsets in this namespace)
├── StatefulSet status sensors (one per statefulset)
├── StatefulSet CPU/memory sensors (one pair per statefulset)
├── DaemonSet sensors (all daemonsets in this namespace)
├── DaemonSet CPU/memory sensors (one pair per daemonset)
├── CronJob switches and status sensors (all cronjobs in this namespace)
└── Job sensors (all jobs in this namespace)
cluster Grouping Mode¶
Setting Device Grouping Mode to cluster (see Configuration) puts every entity — cluster-level and namespace-scoped alike — on the single cluster device; no namespace devices are created (device.py's get_namespace_device_info/get_or_create_namespace_device return the cluster device or None in this mode). Use it for small clusters or single-namespace deployments where per-namespace devices add clutter without benefit.
Benefits of Device Organization¶
- Better Organization: Entities are logically grouped by cluster and namespace
- Easier Filtering: Filter entities by device in the Home Assistant UI
- Clearer Context: Entity names clearly indicate which cluster and namespace they belong to
- Scalability: Better handles large clusters with many resources
- Kubernetes Alignment: Follows Kubernetes namespace organization pattern
Device Management¶
- Automatic Device Creation: Devices are automatically created when entities are first discovered
- Automatic Device Cleanup: Namespace devices are automatically removed when namespaces are deleted from the cluster
- Dynamic Updates: New namespace devices are created when new namespaces are discovered
Entity Naming¶
With device-based grouping, entities are automatically named using the following patterns:
- Cluster-level Sensors:
sensor.[cluster_name]_[metric_type](e.g.,sensor.production_nodes_count) - Cluster-level Binary Sensors:
binary_sensor.[cluster_name]_cluster_health(e.g.,binary_sensor.production_cluster_health) - Node Sensors:
sensor.[cluster_name]_[node_name](e.g.,sensor.production_worker_node_1) - Node Usage Sensors:
sensor.[cluster_name]_[node_name]_[cpu|memory]_usage[_percent](e.g.,sensor.production_worker_node_1_memory_usage_percent) - Node Schedulable Switches:
switch.[cluster_name]_[node_name]_schedulable(e.g.,switch.production_worker_node_1_schedulable) - Namespace-level Pod Sensors:
sensor.[cluster_name]_[namespace]_[pod_name](e.g.,sensor.production_default_my_app_pod) - Namespace-level Switches:
switch.[cluster_name]_[namespace]_[resource_name](e.g.,switch.production_default_web_app) - Replica Numbers:
number.[cluster_name]_[namespace]_[workload_name]_replicas(e.g.,number.production_default_web_app_replicas)
In cluster grouping mode there is no namespace device, so the namespace segment is absent from namespace-level switch and number entity IDs (e.g. switch.production_web_app, number.production_web_app_replicas).
The device hierarchy ensures that entity names include cluster and namespace context, making it clear what each entity represents.
Dynamic Entity Discovery¶
The integration automatically discovers and creates entities for:
- All deployments in monitored namespaces (switch + replica number + status sensor + CPU/memory sensors)
- All statefulsets in monitored namespaces (switch + replica number + status sensor + CPU/memory sensors)
- All daemonsets in monitored namespaces (status sensor + CPU/memory sensors)
- All cronjobs in monitored namespaces (switch + status sensor)
- All jobs in monitored namespaces (status sensor)
- Individual Kubernetes pods in monitored namespaces
- Individual Kubernetes nodes in the cluster
- Node condition binary sensors (5 per node: Ready, Memory Pressure, Disk Pressure, PID Pressure, Network Unavailable)
- Node schedulable switches (one per node, for cordon / uncordon)
- Cluster-wide metrics (pods, nodes, deployments, statefulsets, daemonsets, cronjobs, jobs, ingresses, services count)
- Cluster alert sensors (degraded workloads, problem pods, restarting pods, nodes under pressure, failed jobs, certificate problems)
- Overall cluster health
Entities are automatically added when new resources are created and removed when resources are deleted from the cluster.
Node Entity Management¶
- Automatic Creation: Node sensors are automatically created for each node discovered during integration setup
- Dynamic Updates: Node information is refreshed during regular coordinator updates
- Automatic Cleanup: Node sensors are automatically removed when nodes are deleted from the cluster
- Entity Naming: Node entities use the format
sensor.[cluster_name]_[node_name](e.g.sensor.production_worker_node_1)
Pod Entity Management¶
- Automatic Creation: Pod sensors are automatically created for each pod discovered during integration setup — except pods owned by a Job or CronJob, which are skipped by default (see Job and CronJob Pods)
- Dynamic Updates: Pod information is refreshed during regular coordinator updates
- Automatic Cleanup: Pod sensors are automatically removed when pods are deleted from the cluster
- Entity Naming: Pod entities use the format
sensor.[cluster_name]_[namespace]_[pod_name](e.g.sensor.production_default_my_app_pod) - Namespace Support: Pods are tracked by both namespace and name for proper identification
- Phase Tracking: Pod sensors show the current phase (Running, Pending, Failed, Succeeded, etc.)
- Container Status: Detailed information about container readiness and restart counts
- Owner Information: Shows which workload (Deployment, StatefulSet, etc.) owns the pod
Using Pod Entities with Auto-Entities¶
The pod entities are perfect for use with the auto-entities card to create dynamic dashboards. Here's an example configuration to show pods that are not in a Running or Completed phase:
type: custom:auto-entities
card:
type: entities
title: "Pods with Issues"
filter:
include:
- entity_id: sensor.production_*
state:
- "Pending"
- "Failed"
- "Unknown"
exclude:
- state: "Running"
- state: "Succeeded"
This configuration will automatically populate a card with all pod entities that are in a problematic state, making it easy to monitor and troubleshoot your Kubernetes cluster.