|
| 1 | +# System Diagnostics: Kubernetes API Integration |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +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. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +Before enabling this feature, ensure that: |
| 12 | + |
| 13 | +1. The `serviceAccount.create` setting is set to `true` in your values.yaml |
| 14 | +2. Your Kubernetes cluster allows service account token mounting |
| 15 | +3. You have the necessary permissions to create Roles and RoleBindings in the target namespace |
| 16 | + |
| 17 | +## Configuration |
| 18 | + |
| 19 | +To enable Kubernetes API access, set the following in your values.yaml: |
| 20 | + |
| 21 | +```yaml |
| 22 | +general: |
| 23 | + system_diagnostics_k8s_api: |
| 24 | + enabled: true |
| 25 | + |
| 26 | +serviceAccount: |
| 27 | + create: true |
| 28 | +``` |
| 29 | +
|
| 30 | +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. |
| 31 | + |
| 32 | +## How It Works |
| 33 | + |
| 34 | +When enabled, this feature: |
| 35 | + |
| 36 | +1. Creates a Role and RoleBinding that grant the backend pod permission to get and list the following Kubernetes resources in the Lightrun namespace: |
| 37 | + - Deployments |
| 38 | + - DaemonSets |
| 39 | + - StatefulSets |
| 40 | + - ReplicaSets |
| 41 | + - Ingresses |
| 42 | + - NetworkPolicies |
| 43 | + - Pods and Pod logs |
| 44 | + - Services |
| 45 | + - ConfigMaps |
| 46 | + - PersistentVolumeClaims |
| 47 | + - Endpoints |
| 48 | + - ResourceQuotas |
| 49 | + - LimitRanges |
| 50 | + - Events |
| 51 | + |
| 52 | +2. Automatically enables service account token mounting for the backend pod by overriding `automountServiceAccountToken` to `true`, allowing it to authenticate with the Kubernetes API. |
| 53 | + |
| 54 | +3. Enables the backend to collect system diagnostics data about: |
| 55 | + - Deployment, DaemonSet, StatefulSet, and ReplicaSet configurations and status |
| 56 | + - Pod status, resource usage, and logs |
| 57 | + - Service and Endpoint configurations |
| 58 | + - Ingress and NetworkPolicy configurations |
| 59 | + - ConfigMap contents |
| 60 | + - PersistentVolumeClaim status and configurations |
| 61 | + - ResourceQuota and LimitRange settings |
| 62 | + - Cluster events and their details |
| 63 | + |
| 64 | +## Security Considerations |
| 65 | + |
| 66 | +⚠️ **Important Security Notes:** |
| 67 | + |
| 68 | +- This feature automatically enables service account token mounting for the backend pod by setting `automountServiceAccountToken` to `true` |
| 69 | +- The service account token provides access to Kubernetes API resources within the namespace |
| 70 | +- Consider the security implications before enabling this feature in production environments |
| 71 | +- Review your cluster's security policies regarding service account token mounting |
| 72 | + |
| 73 | +## Troubleshooting |
| 74 | + |
| 75 | +If the feature is not working as expected: |
| 76 | + |
| 77 | +1. Verify that `serviceAccount.create` is set to `true` |
| 78 | +2. Check that the service account token is properly mounted in the backend pod |
| 79 | +3. Ensure the Role and RoleBinding were created successfully |
| 80 | +4. Review the backend pod logs for any authentication or authorization errors |
| 81 | + |
| 82 | +## Disabling the Feature |
| 83 | + |
| 84 | +To disable Kubernetes API access: |
| 85 | + |
| 86 | +```yaml |
| 87 | +general: |
| 88 | + system_diagnostics_k8s_api: |
| 89 | + enabled: false |
| 90 | +``` |
| 91 | + |
| 92 | +Note: Disabling this feature only affects the Kubernetes API data collection. Other system diagnostics features will continue to work as normal. |
0 commit comments