Skip to content

Troubleshooting Guide

This guide helps you resolve common issues with the Kubernetes integration for Home Assistant.

Authentication Issues (401 Unauthorized)

Problem

You see errors like:

Failed to stop deployment longhorn-ui
Failed to get deployments: (401)
Reason: Unauthorized

Solution

Step 1: Verify RBAC Setup

Check whether the ServiceAccount actually has the permission the failing call needs:

kubectl auth can-i list deployments \
  --as=system:serviceaccount:homeassistant:homeassistant-kubernetes-integration

# Everything the ServiceAccount is allowed to do
kubectl auth can-i --list \
  --as=system:serviceaccount:homeassistant:homeassistant-kubernetes-integration

If a verb is missing, install or upgrade the RBAC (see the next step). The full permission matrix is in the RBAC Reference Guide.

Step 2: Install or Upgrade the RBAC

If you prefer to set up RBAC manually:

  1. Install the RBAC — with Helm:
helm install ha-k8s-rbac oci://ghcr.io/tibuntu/charts/homeassistant-kubernetes-rbac \
  --namespace homeassistant --create-namespace

Or with the plain manifests:

kubectl apply -f manifests/full/         # or manifests/minimal/
  1. Extract the token:
kubectl get secret homeassistant-kubernetes-integration-token -n homeassistant -o jsonpath='{.data.token}' | base64 -d

Step 3: Verify Token Permissions

Test if your token has the correct permissions:

# Replace YOUR_TOKEN with the actual token
curl -H "Authorization: Bearer YOUR_TOKEN" https://YOUR_CLUSTER_HOST:6443/api/v1/

# Test deployment scaling permissions
curl -H "Authorization: Bearer YOUR_TOKEN" https://YOUR_CLUSTER_HOST:6443/apis/apps/v1/namespaces/default/deployments

Step 4: Update the Token in Home Assistant

When the cluster rejects the stored token, the integration detects it on the next poll and Home Assistant shows a "Reauthentication needed" notification for the entry. Click Reconfigure on that notification, paste the new token, and submit — the host, port, and TLS settings are kept as they are.

You can also update the token at any time without waiting for the prompt:

  1. Go to Settings → Devices & Services
  2. Find your Kubernetes integration, open the three-dot menu (...) and select Reconfigure
  3. Update the API token with the new token from Step 2
  4. Save the configuration

Note: If Home Assistant runs inside the cluster with Prefer in-cluster ServiceAccount token enabled, routine token rotation is handled automatically — the integration re-reads the projected token and retries before ever asking you to re-authenticate. A reauthentication prompt in that setup usually means the ServiceAccount or its ClusterRoleBinding was deleted — submitting a token there also switches the entry off in-cluster mode so the pasted token takes effect. Re-enable Prefer in-cluster ServiceAccount token via Reconfigure once the ServiceAccount is back.

Required RBAC Permissions

The service account needs these permissions:

# Read permissions
- apiGroups: [""]
  resources: ["pods", "nodes", "namespaces", "services"]
  verbs: ["get", "list", "watch"]

# Deployment permissions (including scaling)
- apiGroups: ["apps"]
  resources: ["deployments", "deployments/scale"]
  verbs: ["get", "list", "watch", "patch", "update"]

Missing Permissions Repair Issue

Problem

Home Assistant shows a repair issue titled Missing permissions for <resources> on <cluster>. If the ServiceAccount also lacks list on that resource, every poll fails and all of the integration's entities become unavailable until the permission is granted — the integration never shows a partial or empty cluster. The exceptions are hpas, httproutes and certificates: none owns per-resource entities, so a forbidden HPA, HTTPRoute or Certificate list just turns that feature off (with a single warning in the log) and everything else keeps working.

Solution

The ServiceAccount's ClusterRole lacks get, list, or watch on the named resource — typically after upgrading to a release that monitors a new resource type. Re-apply the bundled RBAC (helm upgrade with the chart, or kubectl apply -f manifests/full/), or add the rule to your custom manifest. For hpas, httproutes and certificates you can instead opt out under Configure → Disable data collection for → HorizontalPodAutoscalers / HTTPRoutes / Certificates if you don't want to grant the autoscaling / gateway.networking.k8s.io / cert-manager.io rule; that also silences the repair issue. Each affected watch retries once a minute, and the issue clears on its own once every watch delivers an event or stays open (after a list 403, on the next successful list); reload the integration (Settings → Devices & Services → Kubernetes → ⋮ → Reload) if you don't want to wait.

If the issue appears right after restarting the API server (for example a k3s restart) although the RBAC is complete, it's transient: the authorizer denies requests until it has loaded its rules. It clears within a few minutes without any action — once the retried watch delivers its first event or bookmark. See the RBAC Reference for the full permission matrix.

Problem: HTTPRoutes don't appear in the Network tab

The Network tab only shows an HTTPRoutes section when the cluster has HTTPRoutes the integration may list. Check, in this order: the Gateway API CRDs are installed and serve gateway.networking.k8s.io/v1 (Gateway API 1.0 or newer — the log says "Gateway API is not installed on this cluster" at info level otherwise; this is a normal state and raises no repair issue); the ServiceAccount may list and watch httproutes (a missing rule raises the Missing permissions repair issue above and logs "Listing HTTPRoutes is forbidden" — re-apply the bundled RBAC); HTTPRoutes is not selected under Configure → Disable data collection for; and, with namespace filtering, the routes live in a monitored namespace.

Problem: Certificates don't appear in the Network tab, or Certificate Problems stays at 0

Both need cert-manager serving cert-manager.io/v1 — the log says "cert-manager is not installed on this cluster" at info level otherwise (a normal state, no repair issue); the sensor exists regardless and simply shows 0. Then check that the ServiceAccount may list and watch certificates (a missing rule raises the Missing permissions repair issue above and logs "Listing Certificates is forbidden" — re-apply the bundled RBAC); that Certificates is not selected under Configure → Disable data collection for; and, with namespace filtering, that the Certificates live in a monitored namespace. Without cert-manager, disable Certificates to remove the sensor.

Pod Logs Dialog Shows an Error

Problem

The Logs dialog in the panel's Pods tab shows an error instead of logs.

Solution

  • Status 403 — the ServiceAccount lacks get on pods/log. Re-apply the bundled RBAC (helm upgrade, or kubectl apply -f manifests/full/); the minimal set does not grant it. This never raises a repair issue, so the dialog is the only place it shows up. See the RBAC Reference.
  • Status 400 with "Previous container" — the container has not restarted yet, so there is no previous run to show. Untick the option.
  • "Pod logs are disabled" — turn on Configure → Enable pod logs in the panel (experimental).
  • No Logs button at all — the option is off for that cluster, or you are not a Home Assistant administrator (the panel hides it, and the server refuses non-admins anyway).

Connection Issues

Problem

Cannot connect to Kubernetes API server. While the API is unreachable (network outage, TLS error, 5xx from the API server) the coordinator's poll fails and every entity becomes unavailable; nothing is deleted, and the entities recover on the next successful poll. If the API is unreachable when Home Assistant starts, the integration shows "Retrying setup" and keeps retrying until the cluster answers — it no longer loads with empty entities.

Solution

  1. Verify Cluster Accessibility
kubectl cluster-info
  1. Check Network Connectivity
# Test if the API server is reachable
curl -k https://YOUR_CLUSTER_HOST:6443/api/v1/
  1. Verify SSL Certificate
  2. If using self-signed certificates, set verify_ssl: false in the configuration
  3. For custom CA certificates, provide the certificate path in the configuration

Deployment Scaling Issues

Problem: "managed by HPA … adjust the HPA's min/max replicas instead"

A HorizontalPodAutoscaler targets the workload and would reset any replica count other than 0 within seconds, so scale_workload and the replica number reject it up front. Change the HPA instead (kubectl edit hpa NAME -n NAMESPACE), or scale to 0 / turn the switch off, which the HPA leaves alone. See HPA-managed workloads.

Problem

Deployment scaling operations fail.

Solution

  1. Check Deployment Exists
kubectl get deployments -n NAMESPACE
  1. Verify Namespace
  2. Ensure the deployment is in the correct namespace
  3. Check if you're monitoring all namespaces or a specific one

  4. Check Resource Quotas

kubectl describe resourcequota -n NAMESPACE

Common Configuration Issues

Problem

Integration shows incorrect data or no data.

Solution

  1. Check Namespace Configuration
  2. If monitor_all_namespaces: false, ensure the selected namespaces exist in your cluster
  3. If monitor_all_namespaces: true, ensure you have cluster-wide permissions

  4. Verify Host Configuration

  5. Remove protocol prefixes (http://, https://) from the host
  6. Use only the hostname or IP address

  7. Check Port Configuration

  8. Default Kubernetes API port is 6443
  9. For k3s, it might be 6443 or 6443
  10. Verify with kubectl config view

Debugging

Enable Debug Logging

Add this to your configuration.yaml:

logger:
  default: info
  logs:
    custom_components.kubernetes: debug

Check Home Assistant Logs

Look for detailed error messages in the Home Assistant logs:

# If running in Docker
docker logs homeassistant

# If running in Kubernetes
kubectl logs -n homeassistant deployment/homeassistant

Test API Endpoints Manually

Use curl to test API endpoints directly:

# Test basic connectivity
curl -H "Authorization: Bearer YOUR_TOKEN" https://YOUR_CLUSTER_HOST:6443/api/v1/

# Test deployments endpoint
curl -H "Authorization: Bearer YOUR_TOKEN" https://YOUR_CLUSTER_HOST:6443/apis/apps/v1/namespaces/default/deployments

# Test scaling endpoint
curl -X PATCH \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/strategic-merge-patch+json" \
  -d '{"spec":{"replicas":0}}' \
  https://YOUR_CLUSTER_HOST:6443/apis/apps/v1/namespaces/default/deployments/DEPLOYMENT_NAME/scale

Downloading Diagnostics for Bug Reports

Home Assistant can export a redacted snapshot of the integration's configuration and runtime state. Attaching this to a GitHub issue is the fastest way to get a useful response.

  1. Go to Settings → Devices & Services.
  2. Find the Kubernetes integration and click the ⋮ menu next to your cluster.
  3. Choose Download diagnostics.
  4. Attach the resulting JSON file to your GitHub issue.

The export includes the cluster host, namespaces, watch/panel options, coordinator status, and resource counts. The API token and CA certificate are automatically redacted before download.

Getting Help

If you're still experiencing issues:

  1. Check the logs with debug logging enabled
  2. Verify your Kubernetes cluster is working correctly
  3. Test the API endpoints manually using curl
  4. Create an issue on the GitHub repository with:
  5. Home Assistant version
  6. Kubernetes version
  7. Error logs
  8. Diagnostics download (see section above)
  9. Configuration (without sensitive data)

Security Best Practices

  1. Use Service Accounts: Always use service accounts instead of user tokens
  2. Principle of Least Privilege: Only grant necessary permissions
  3. Regular Token Rotation: Rotate tokens periodically
  4. Network Security: Use network policies to restrict access
  5. Audit Logging: Enable audit logging to monitor API access