Skip to content

Commit 793c79a

Browse files
author
eliranb
committed
initial commit
1 parent 544b149 commit 793c79a

File tree

6 files changed

+268
-0
lines changed

6 files changed

+268
-0
lines changed

charts/lightrun-agents/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/lightrun-agents/Chart.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v2
2+
name: lightrun-agents
3+
description: A Helm chart for Kubernetes that deploy lightrun agents CRDs
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.0.1

charts/lightrun-agents/README.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{{ range .Values.javaAgents }}
2+
---
3+
apiVersion: agents.lightrun.com/v1beta
4+
kind: LightrunJavaAgent
5+
metadata:
6+
name: {{ .name }}
7+
namespace: {{ .namespace }}
8+
spec:
9+
initContainer:
10+
image: {{ .initContainer.image }}
11+
sharedVolumeName: {{ .initContainer.sharedVolumeName | default "lightrun-agent-init" }}
12+
sharedVolumeMountPath: {{ .initContainer.sharedVolumeMountPath | default "/lightrun" }}
13+
deploymentName: {{ .deploymentName }}
14+
containerSelector: {{- toYaml .containerSelector | nindent 4 }}
15+
{{- if .agentPoolCredentials.existingSecret }}
16+
secretName: {{ .agentPoolCredentials.existingSecret }}
17+
{{- else }}
18+
secretName: {{ .name }}-secret
19+
{{- end }}
20+
serverHostname: {{ .serverHostname }}
21+
agentEnvVarName: {{ .agentEnvVarName | default "JAVA_TOOL_OPTIONS" }}
22+
{{- if .agentConfig }}
23+
agentConfig: {{ toYaml .agentConfig | nindent 4 }}
24+
{{- end }}
25+
{{- if .agentCliFlags }}
26+
agentCliFlags: {{ .agentCliFlags }}
27+
{{- end }}
28+
agentTags:
29+
{{- range .agentTags }}
30+
- {{. -}}
31+
{{- end }}
32+
{{- if .agentName }}
33+
agentName: {{ .agentName }}
34+
{{- end }}
35+
{{- end }}
36+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{ range .Values.javaAgents }}
2+
{{- if not .agentPoolCredentials.existingSecret }}
3+
---
4+
apiVersion: v1
5+
metadata:
6+
name: {{ .name }}-secret
7+
namespace: {{ .namespace }}
8+
stringData:
9+
# Lightrun key you can take from the server UI at the "setup agent" step
10+
lightrun_key: {{ .agentPoolCredentials.apiKey }}
11+
# Server certificate hash. It is ensuring that agent is connected to the right Lightrun server
12+
pinned_cert_hash: {{ .agentPoolCredentials.pinnedCertHash }}
13+
kind: Secret
14+
type: Opaque
15+
{{- end }}
16+
{{- end }}

charts/lightrun-agents/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Default values for lightrun-javaagent.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
javaAgents: []

0 commit comments

Comments
 (0)