Kubernetes Integration Logging¶
This document explains the logging system used by the Kubernetes integration and how to troubleshoot common issues.
Log Levels¶
The integration uses different log levels to provide appropriate information:
- DEBUG: Successful operations and detailed information
- INFO: Important successful operations (like scaling deployments)
- ERROR: Problems that need attention
Log Format¶
All logs include structured context information:
Common Error Messages and Solutions¶
Authentication Failed (401)¶
Solutions:
- Verify the API token is correct and not expired
- Check that the service account has the necessary RBAC permissions
- Ensure the token has access to the specified namespace
A 401 that persists across a poll cycle also raises a "Reauthentication needed" notification in Home Assistant, where you can enter a fresh token without reconfiguring the rest of the entry. See Re-authentication.
Permission Denied (403)¶
Permission denied for get deployments (cluster=default, host=kubernetes.example.com:6443, namespace=default). Check RBAC roles and namespace access.
Solutions:
- Check RBAC roles assigned to the service account
- Verify namespace access permissions
- Review cluster role bindings
Resource Not Found (404)¶
Resource not found for get deployments (cluster=default, host=kubernetes.example.com:6443, namespace=default). Check namespace and resource names.
Solutions:
- Verify the namespace exists
- Check that the resource names are correct
- Ensure the namespace is accessible
Network Errors¶
Network error during get deployments (cluster=default, host=kubernetes.example.com:6443, namespace=default): [error details]
Solutions:
- Check network connectivity to the Kubernetes API server
- Verify firewall rules allow HTTPS traffic to the API server
- Check DNS resolution for the hostname
Timeout Errors¶
Timeout during get deployments (cluster=default, host=kubernetes.example.com:6443, namespace=default). Check network connectivity and API server response time.
Solutions:
- Check network latency to the Kubernetes cluster
- Verify the API server is not overloaded
- Consider increasing timeout values if needed
Enabling Debug Logging¶
To see detailed debug information, add this to your configuration.yaml:
Troubleshooting Steps¶
- Check Connection: Look for "Successfully connected to Kubernetes API" messages
- Verify Permissions: Check for 401/403 errors and review RBAC configuration
- Network Issues: Look for timeout or network error messages
- Resource Access: Verify namespace and resource existence for 404 errors
Authentication Testing¶
If you're experiencing authentication issues, verify the token outside Home Assistant with the same request the integration's connection probe makes:
curl -sS -o /dev/null -w '%{http_code}\n' \
-H "Authorization: Bearer $TOKEN" \
https://<host>:<port>/api/v1/
200— the token is accepted401— the token is rejected (the integration raises a reauthentication flow for a persistent 401)403— the token authenticates but lacks RBAC permissions; see RBAC.md
Add --cacert <ca.crt> (or -k for a quick test only) when the cluster uses a private CA.
Log Examples¶
Successful Operation¶
DEBUG (MainThread) [custom_components.kubernetes.kubernetes_client] Successfully completed get pods count (cluster=production, host=k8s.example.com:6443, namespaces=default): retrieved 15 pods
Authentication Error¶
ERROR (MainThread) [custom_components.kubernetes.kubernetes_client] aiohttp connection test failed with status: 401