|
| 1 | +# Helm Chart for Deploying Lightrun Agents |
| 2 | +This Helm chart allows you to deploy and manage Lightrun Agents as custom resources in your Kubernetes cluster. |
| 3 | +Currently only java based agents are supported. |
| 4 | +The LightrunJavaAgent custom resource will be configured based on the values provided in the values.yaml file. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | +- Kubernetes 1.16+ |
| 8 | +- Helm 3.0+ |
| 9 | +- Ability to fetch images of the init containers from [Lightrun Repository Dockerhub](https://hub.docker.com/u/lightruncom). or alternatively have them available in private registry. |
| 10 | +## Installation |
| 11 | +### 1 - Add the repo to your Helm repository list |
| 12 | +```shell |
| 13 | +helm repo add lightrun-k8s-operator https://lightrun-platform.github.io/lightrun-k8s-operator |
| 14 | + |
| 15 | +``` |
| 16 | +### 2 - Prepare values.yaml |
| 17 | +The "values.yaml" file contains the following configurable parameters for each java agent object: |
| 18 | + |
| 19 | +| Parameter | Description | Default | |
| 20 | +|----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------| |
| 21 | +| `javaAgents[].agentCliFlags` | [Command-line flags for the Lightrun Java Agent.](https://docs.lightrun.com/jvm/agent-configuration/#additional-command-line-flags). | Optional `""` (empty string) | |
| 22 | +| `javaAgents[].agentConfig` | [Additional configuration for the Lightrun Java Agent.](https://docs.lightrun.com/jvm/agent-configuration/#agent-flags) | Optional `{}` (empty map) | |
| 23 | +| `javaAgents[].agentEnvVarName` | Specifies the Java environment variable name used for adding `--agentpath` | Optional (if not provided, defaults to `"JAVA_TOOL_OPTIONS"`) | |
| 24 | +| `javaAgents[].agentName` | Custom name to assign to the Lightrun Java Agent. | Optional (if not provided, defaults to pod name) | |
| 25 | +| `javaAgents[].agentPoolCredentials.existingSecret` | Name of an existing Kubernetes secret containing api key and pinned cert hash for agent pool. [secret example](https://github.com/lightrun-platform/lightrun-k8s-operator/blob/main/examples/lightrunjavaagent.yaml#L64-L73) | Optional (if not provided, defaults to `name-secret`) | |
| 26 | +| `javaAgents[].agentPoolCredentials.apiKey` | Lightrun agent API key. | Required if `existingSecret` not set | |
| 27 | +| `javaAgents[].agentPoolCredentials.pinnedCertHash` | 64 character sha256 certificate public key hash for pinning | Required if `existingSecret` not set | |
| 28 | +| `javaAgents[].agentTags` | [List of Lightrun Java Agent tags.](https://docs.lightrun.com/jvm/tagging/#manage-lightrun-java-agent-tags) | Optional `[]` (empty list) | |
| 29 | +| `javaAgents[].containerSelector` | Selector for containers within the deployment to inject the Lightrun Java Agent. | Required | |
| 30 | +| `javaAgents[].deploymentName` | Name of the Kubernetes deployment to attach the Lightrun Java Agent. | Required | |
| 31 | +| `javaAgents[].initContainer.image` | Image for the Lightrun Java Agent init container. | Required | |
| 32 | +| `javaAgents[].initContainer.sharedVolumeMountPath` | Mount path for the shared volume in the init container. | Optional (if not provided, defaults to `"/lightrun"`" | |
| 33 | +| `javaAgents[].initContainer.sharedVolumeName` | Name of the shared volume for the init container. | Optional (if not provided, defaults to `"lightrun-agent-init"`" | |
| 34 | +| `javaAgents[].name` | Name of the Lightrun Java Agent custom resource. | Required | |
| 35 | +| `javaAgents[].namespace` | Namespace of the Lightrun Java Agent custom resource. Must be in the same namespace as the workload | Required | |
| 36 | +| `javaAgents[].serverHostname` | Hostname of the Lightrun server to connect the agent. | Required | |
| 37 | + |
| 38 | +#### 2.1 - Set `initContainer.image` |
| 39 | + |
| 40 | +Based on your workload's OS and architecture, you should select the appropriate DockerHub repository from the following options: |
| 41 | +- [linux amd64](https://hub.docker.com/repository/docker/lightruncom/k8s-operator-init-java-agent-linux/general) |
| 42 | +- [linux arm64](https://hub.docker.com/repository/docker/lightruncom/k8s-operator-init-java-agent-linux-arm64/general) |
| 43 | +- [alpine amd64](https://hub.docker.com/repository/docker/lightruncom/k8s-operator-init-java-agent-alpine/general) |
| 44 | +- [alpine arm64](https://hub.docker.com/repository/docker/lightruncom/k8s-operator-init-java-agent-alpine-arm64/general) |
| 45 | + |
| 46 | +After determining the appropriate image, you'll need to choose a tag. The tag can either be "latest," which corresponds to the most up-to-date version, or it can be a specific Lightrun version following the convention `<x.y.z>-init.<number>`. Typically, the `<number>` part is 0, but it's always good to verify on the DockerHub repository. |
| 47 | + |
| 48 | +For your convenience, here are some possible combinations of how the final image might look: |
| 49 | +```text |
| 50 | +Linux amd64 with the latest version -> lightruncom/k8s-operator-init-java-agent-linux:latest |
| 51 | +Linux amd64 with a specific version -> lightruncom/k8s-operator-init-java-agent-linux:1.39.1-init.0 |
| 52 | +Linux arm64 with the latest version -> lightruncom/k8s-operator-init-java-agent-linux-arm64:latest |
| 53 | +Linux arm64 with a specific version -> lightruncom/k8s-operator-init-java-agent-linux-arm64:1.39.1-init.0 |
| 54 | +Alpine amd64 with the latest version -> lightruncom/k8s-operator-init-java-agent-alpine:latest |
| 55 | +Alpine amd64 with a specific version -> lightruncom/k8s-operator-init-java-agent-alpine:1.39.1-init.0 |
| 56 | +Alpine arm64 with the latest version -> lightruncom/k8s-operator-init-java-agent-alpine-arm64:latest |
| 57 | +Alpine arm64 with a specific version -> lightruncom/k8s-operator-init-java-agent-alpine-arm64:1.39.1-init.0 |
| 58 | +``` |
| 59 | +#### 2.2 Install the chart |
| 60 | + |
| 61 | +When installing the chart, it's important to understand that the -n flag provided in the helm install command does not determine where the actual resources will be deployed. Instead, deployment is controlled by the javaAgents[].namespace parameter for each object in the values.yaml file. |
| 62 | + |
| 63 | +Use the -n flag to specify a namespace, either using the same namespace where your Lightrun Kubernetes Operator is installed or creating a new namespace specifically for this purpose, such as "lightrun-agents". This namespace will be referenced if you need to uninstall the chart later. |
| 64 | +```bash |
| 65 | +helm install <release-name> lightrun-k8s-operator/lightrun-agents -n <namespace> -f values.yaml |
| 66 | +``` |
| 67 | + |
| 68 | +## Examples |
| 69 | +### Basic |
| 70 | +- The `my-service-1` does not use an `existingSecret` and instead the `agentPoolCredentials.apiKey` and `agentPoolCredentials.pinnedCertHash` are provided directly. |
| 71 | + |
| 72 | +- The `my-service-2` uses an `existingSecret` named `my-existing-secret` |
| 73 | +```yaml |
| 74 | +javaAgents: |
| 75 | + - name: 'my-service-1' |
| 76 | + namespace: 'my-namespace-1' |
| 77 | + deploymentName: "my-deployment-1" |
| 78 | + containerSelector: |
| 79 | + - my-container-1 |
| 80 | + serverHostname: 'lightrun.example.com' |
| 81 | + initContainer: |
| 82 | + image: "lightruncom/k8s-operator-init-java-agent-linux:latest" |
| 83 | + agentPoolCredentials: |
| 84 | + existingSecret: "" |
| 85 | + apiKey: "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" |
| 86 | + pinnedCertHash: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
| 87 | + agentTags: |
| 88 | + - env-production |
| 89 | + - service-my-server |
| 90 | + - region-us_east_1 |
| 91 | + - provider-aws |
| 92 | + - name: 'my-service-2' |
| 93 | + namespace: 'my-namespace-2' |
| 94 | + initContainer: |
| 95 | + image: "lightruncom/k8s-operator-init-java-agent-linux:latest" |
| 96 | + deploymentName: "my-deployment-2" |
| 97 | + containerSelector: |
| 98 | + - my-container-2 |
| 99 | + serverHostname: 'lightrun.example.com' |
| 100 | + agentPoolCredentials: |
| 101 | + existingSecret: "my-existing-secret" |
| 102 | + apiKey: "" |
| 103 | + pinnedCertHash: "" |
| 104 | + agentTags: |
| 105 | + - env-production |
| 106 | + - service-my-other-server |
| 107 | + - region-us_east_1 |
| 108 | + - provider-aws |
| 109 | +``` |
| 110 | +
|
| 111 | +### Full |
| 112 | +- The `my-service-1` does not use an `existingSecret` and instead the `agentPoolCredentials.apiKey` and `agentPoolCredentials.pinnedCertHash` are provided directly. |
| 113 | + |
| 114 | +- The `my-service-2` uses an `existingSecret` named `my-existing-secret` |
| 115 | +```yaml |
| 116 | +javaAgents: |
| 117 | + - name: 'my-service-1' |
| 118 | + namespace: 'my-namespace-1' |
| 119 | + deploymentName: "my-deployment-1" |
| 120 | + containerSelector: |
| 121 | + - my-container-1 |
| 122 | + serverHostname: 'lightrun.example.com' |
| 123 | + agentEnvVarName: '_JAVA_OPTIONS' |
| 124 | + agentConfig: |
| 125 | + max_log_cpu_cost: "2" |
| 126 | + agentCliFlags: "--lightrun_extra_class_path=<PATH_TO_JAR>:<PATH_TO_JAR>,lightrun_init_wait_time_ms" |
| 127 | + initContainer: |
| 128 | + image: "lightruncom/k8s-operator-init-java-agent-linux:latest" |
| 129 | + sharedVolumeName: 'my-shared-volume' |
| 130 | + sharedVolumeMountPath: '/mypath' |
| 131 | + agentPoolCredentials: |
| 132 | + existingSecret: "" |
| 133 | + apiKey: "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" |
| 134 | + pinnedCertHash: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
| 135 | + agentTags: |
| 136 | + - env-production |
| 137 | + - service-my-server |
| 138 | + - region-us_east_1 |
| 139 | + - provider-aws |
| 140 | + - name: 'my-service-2' |
| 141 | + namespace: 'my-namespace-2' |
| 142 | + initContainer: |
| 143 | + image: "lightruncom/k8s-operator-init-java-agent-linux:latest" |
| 144 | + sharedVolumeName: 'my-shared-volume' |
| 145 | + sharedVolumeMountPath: '/mypath' |
| 146 | + deploymentName: "my-deployment-2" |
| 147 | + containerSelector: |
| 148 | + - my-container-2 |
| 149 | + serverHostname: 'lightrun.example.com' |
| 150 | + agentEnvVarName: 'JAVA_OPTS' |
| 151 | + agentConfig: |
| 152 | + max_log_cpu_cost: "2" |
| 153 | + agentCliFlags: "--lightrun_extra_class_path=<PATH_TO_JAR>:<PATH_TO_JAR>,lightrun_init_wait_time_ms" |
| 154 | + agentPoolCredentials: |
| 155 | + existingSecret: "my-existing-secret" |
| 156 | + apiKey: "" |
| 157 | + pinnedCertHash: "" |
| 158 | + agentTags: |
| 159 | + - env-production |
| 160 | + - service-my-other-server |
| 161 | + - region-us_east_1 |
| 162 | + - provider-aws |
| 163 | +``` |
| 164 | + |
| 165 | +## Uninstallation |
| 166 | +To uninstall the chart: |
| 167 | + |
| 168 | +```bash |
| 169 | +helm uninstall <release-name> -n <namespace> |
| 170 | +``` |
| 171 | +This command removes all the Kubernetes components associated with the chart and deletes the release. |
0 commit comments