System Diagnostics: Kubernetes API Integration¶
This document describes how to enable and configure the System Diagnostics feature to access the Kubernetes API from the backend pod. This integration allows the System Diagnostics feature to collect detailed information about the Lightrun deployment's Kubernetes environment.
Overview¶
The System Diagnostics feature can be configured to access the Kubernetes API from the backend pod to enhance its diagnostic capabilities. This integration provides valuable insights into the Kubernetes environment where Lightrun is deployed, enabling more comprehensive system monitoring and troubleshooting.
Prerequisites¶
Before enabling this feature, ensure that:
- The
serviceAccount.create
setting is set totrue
in your values.yaml - Your Kubernetes cluster allows service account token mounting
- You have the necessary permissions to create Roles and RoleBindings in the target namespace
Configuration¶
To enable Kubernetes API access, set the following in your values.yaml:
general:
system_diagnostics_k8s_api:
enabled: true
serviceAccount:
create: true
Note: When system_diagnostics_k8s_api.enabled
is set to true
, the feature will automatically override serviceAccount.automountServiceAccountToken
to true
for the backend pod, regardless of its global setting.
How It Works¶
When enabled, this feature:
-
Creates a Role and RoleBinding that grant the backend pod permission to get and list the following Kubernetes resources in the Lightrun namespace:
- Deployments
- DaemonSets
- StatefulSets
- ReplicaSets
- Ingresses
- NetworkPolicies
- Pods and Pod logs
- Services
- ConfigMaps
- PersistentVolumeClaims
- Endpoints
- ResourceQuotas
- LimitRanges
- Events
-
Automatically enables service account token mounting for the backend pod by overriding
automountServiceAccountToken
totrue
, allowing it to authenticate with the Kubernetes API. -
Enables the backend to collect system diagnostics data about:
- Deployment, DaemonSet, StatefulSet, and ReplicaSet configurations and status
- Pod status, resource usage, and logs
- Service and Endpoint configurations
- Ingress and NetworkPolicy configurations
- ConfigMap contents
- PersistentVolumeClaim status and configurations
- ResourceQuota and LimitRange settings
- Cluster events and their details
Security Considerations¶
⚠️ Important Security Notes:
- This feature automatically enables service account token mounting for the backend pod by setting
automountServiceAccountToken
totrue
- The service account token provides access to Kubernetes API resources within the namespace
- Consider the security implications before enabling this feature in production environments
- Review your cluster's security policies regarding service account token mounting
Troubleshooting¶
If the feature is not working as expected:
- Verify that
serviceAccount.create
is set totrue
- Check that the service account token is properly mounted in the backend pod
- Ensure the Role and RoleBinding were created successfully
- Review the backend pod logs for any authentication or authorization errors
Disabling the Feature¶
To disable Kubernetes API access:
general:
system_diagnostics_k8s_api:
enabled: false
Note: Disabling this feature only affects the Kubernetes API data collection. Other system diagnostics features will continue to work as normal.