Skip to content

Commit 7ca4b25

Browse files
author
eliranb
committed
Merge remote-tracking branch 'origin' into DEVOPS-2693-lightrun-k-8-s-operator-add-ability-to-set-image-pull-policy-for-init-container
2 parents 4931a6b + 560e389 commit 7ca4b25

File tree

4 files changed

+105
-18
lines changed

4 files changed

+105
-18
lines changed

charts/lightrun-agents/README.md

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ The values.yaml file includes the following configurable parameters for each Jav
3131
| `javaAgents[].agentPoolCredentials.pinnedCertHash` | 64 character sha256 certificate public key hash for pinning. | Required if `existingSecret` not set |
3232
| `javaAgents[].agentTags` | [List of Lightrun Java Agent tags](https://docs.lightrun.com/jvm/tagging/#manage-lightrun-java-agent-tags). | Optional `[]` (empty list) |
3333
| `javaAgents[].containerSelector` | Selector for containers within the deployment to inject the Lightrun Java Agent. | Required |
34-
| `javaAgents[].deploymentName` | Name of the Kubernetes deployment to attach the Lightrun Java Agent. | Required |
34+
| `javaAgents[].workloadName` | Name of the Kubernetes workload (Deployment or StatefulSet) to attach the Lightrun Java Agent. **Recommended over `deploymentName`**. | Required (if `deploymentName` not used) |
35+
| `javaAgents[].workloadType` | Type of the Kubernetes workload. Must be either `"Deployment"` or `"StatefulSet"`. **Required when using `workloadName`**. | Required (if `workloadName` is used) |
36+
| `javaAgents[].deploymentName` | **[DEPRECATED]** Name of the Kubernetes deployment to attach the Lightrun Java Agent. Use `workloadName` and `workloadType` instead. | Required (if `workloadName` not used) |
3537
| `javaAgents[].initContainer.image` | Image for the Lightrun Java Agent init container. | Required |
3638
| `javaAgents[].initContainer.imagePullPolicy` | Image pull policy for the init container. Can be one of: Always, IfNotPresent, or Never. | Optional (if not provided, defaults according to [Kubernetes Default Image Pull Policy](https://kubernetes.io/docs/concepts/containers/images/#imagepullpolicy-defaulting)) |
3739
| `javaAgents[].initContainer.sharedVolumeMountPath` | Mount path for the shared volume in the init container. | Optional (if not provided, defaults to `"/lightrun"`" |
@@ -74,19 +76,56 @@ Use the -n flag to specify a namespace, either using the same namespace where yo
7476
helm install <release-name> lightrun-k8s-operator/lightrun-agents -n <namespace> -f values.yaml
7577
```
7678

79+
## Migration from Legacy Configuration
80+
81+
If you are currently using the `deploymentName` field, you should migrate to the new `workloadName` and `workloadType` fields for better clarity and StatefulSet support:
82+
83+
**Legacy Configuration (deprecated):**
84+
```yaml
85+
javaAgents:
86+
- name: 'my-service'
87+
namespace: 'my-namespace'
88+
deploymentName: "my-deployment" # deprecated
89+
# ... other fields
90+
```
91+
92+
**New Configuration (recommended):**
93+
```yaml
94+
javaAgents:
95+
- name: 'my-service'
96+
namespace: 'my-namespace'
97+
workloadName: "my-deployment" # new field
98+
workloadType: "Deployment" # new field (required)
99+
# ... other fields
100+
```
101+
102+
**For StatefulSets:**
103+
```yaml
104+
javaAgents:
105+
- name: 'my-service'
106+
namespace: 'my-namespace'
107+
workloadName: "my-statefulset" # new field
108+
workloadType: "StatefulSet" # new field (required)
109+
# ... other fields
110+
```
111+
112+
> **Note:** You cannot use both `deploymentName` and `workloadName`/`workloadType` in the same configuration. The chart validation will fail if both are specified.
113+
77114
## Examples
78115

79116
### Basic
80117

81-
- The `my-service-1` does not use an `existingSecret` and instead the `agentPoolCredentials.apiKey` and `agentPoolCredentials.pinnedCertHash` are provided directly.
82-
83-
- The `my-service-2` uses an `existingSecret` named `my-existing-secret`
118+
- The `my-service-1` uses the new workload configuration (recommended) for a Deployment and does not use an `existingSecret`
119+
- The `my-service-2` uses the new workload configuration for a StatefulSet and uses an `existingSecret` named `my-existing-secret`
120+
- The `my-service-3` shows the legacy configuration using `deploymentName` (deprecated but still supported)
84121

85122
```yaml
86123
javaAgents:
87124
- name: 'my-service-1'
88125
namespace: 'my-namespace-1'
89-
deploymentName: "my-deployment-1"
126+
# New workload configuration (recommended)
127+
workloadName: "my-deployment-1"
128+
workloadType: "Deployment"
90129
containerSelector:
91130
- my-container-1
92131
serverHostname: 'lightrun.example.com'
@@ -106,8 +145,9 @@ javaAgents:
106145
namespace: 'my-namespace-2'
107146
initContainer:
108147
image: "lightruncom/k8s-operator-init-java-agent-linux:latest"
109-
imagePullPolicy: "IfNotPresent"
110-
deploymentName: "my-deployment-2"
148+
# StatefulSet configuration
149+
workloadName: "my-statefulset-2"
150+
workloadType: "StatefulSet"
111151
containerSelector:
112152
- my-container-2
113153
serverHostname: 'lightrun.example.com'
@@ -120,19 +160,36 @@ javaAgents:
120160
- service-my-other-server
121161
- region-us_east_1
122162
- provider-aws
163+
- name: 'my-service-3'
164+
namespace: 'my-namespace-3'
165+
# Legacy configuration (deprecated but still supported)
166+
deploymentName: "my-deployment-3"
167+
containerSelector:
168+
- my-container-3
169+
serverHostname: 'lightrun.example.com'
170+
initContainer:
171+
image: "lightruncom/k8s-operator-init-java-agent-linux:latest"
172+
agentPoolCredentials:
173+
existingSecret: "my-existing-secret"
174+
apiKey: ""
175+
pinnedCertHash: ""
176+
agentTags:
177+
- env-production
178+
- service-legacy
123179
```
124180
125181
### Full
126182
127-
- The `my-service-1` does not use an `existingSecret` and instead the `agentPoolCredentials.apiKey` and `agentPoolCredentials.pinnedCertHash` are provided directly.
128-
129-
- The `my-service-2` uses an `existingSecret` named `my-existing-secret`
183+
- The `my-service-1` uses the new workload configuration for a Deployment with full configuration options
184+
- The `my-service-2` uses the new workload configuration for a StatefulSet with an `existingSecret`
130185

131186
```yaml
132187
javaAgents:
133188
- name: 'my-service-1'
134189
namespace: 'my-namespace-1'
135-
deploymentName: "my-deployment-1"
190+
# New workload configuration (recommended)
191+
workloadName: "my-deployment-1"
192+
workloadType: "Deployment"
136193
containerSelector:
137194
- my-container-1
138195
serverHostname: 'lightrun.example.com'
@@ -161,7 +218,9 @@ javaAgents:
161218
imagePullPolicy: "IfNotPresent"
162219
sharedVolumeName: 'my-shared-volume'
163220
sharedVolumeMountPath: '/mypath'
164-
deploymentName: "my-deployment-2"
221+
# StatefulSet configuration with full options
222+
workloadName: "my-statefulset-2"
223+
workloadType: "StatefulSet"
165224
containerSelector:
166225
- my-container-2
167226
serverHostname: 'lightrun.example.com'

charts/lightrun-agents/templates/_checkConfig.tpl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ Compile all warnings into a single message, and call fail.
2222
{{- if not .initContainer.image }}
2323
{{- $objectErrorMsgs = append $objectErrorMsgs "Init Container Image Checker:\n Error: The 'initContainer.image' field is missing. Please provide the 'initContainer.image' parameter." -}}
2424
{{- end }}
25-
{{- if not .deploymentName }}
26-
{{- $objectErrorMsgs = append $objectErrorMsgs "Deployment Name Checker:\n Error: The 'deploymentName' field is missing. Please provide the 'deploymentName' parameter." -}}
25+
26+
{{- /* Workload configuration validation */}}
27+
{{- $hasDeploymentName := .deploymentName }}
28+
{{- $hasWorkloadConfig := and .workloadName .workloadType }}
29+
30+
{{- if and $hasDeploymentName $hasWorkloadConfig }}
31+
{{- $objectErrorMsgs = append $objectErrorMsgs "Workload Configuration Checker:\n Error: Both 'deploymentName' (legacy) and 'workloadName'/'workloadType' (new) are specified. Please use only one configuration method: either 'deploymentName' OR 'workloadName' with 'workloadType'." -}}
32+
{{- else if not (or $hasDeploymentName $hasWorkloadConfig) }}
33+
{{- $objectErrorMsgs = append $objectErrorMsgs "Workload Configuration Checker:\n Error: No workload configuration specified. Please provide either 'deploymentName' (legacy) OR 'workloadName' with 'workloadType' (recommended)." -}}
2734
{{- end }}
35+
2836
{{- if not .containerSelector }}
2937
{{- $objectErrorMsgs = append $objectErrorMsgs "Container Selector Checker:\n Error: The 'containerSelector' field is missing. Please provide the 'containerSelector' parameter." -}}
3038
{{- end }}

charts/lightrun-agents/templates/java-agent-cr.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ spec:
1313
{{- end }}
1414
sharedVolumeName: {{ .initContainer.sharedVolumeName | default "lightrun-agent-init" }}
1515
sharedVolumeMountPath: {{ .initContainer.sharedVolumeMountPath | default "/lightrun" }}
16+
{{- if .workloadName }}
17+
workloadName: {{ .workloadName }}
18+
{{- end }}
19+
{{- if .workloadType }}
20+
workloadType: {{ .workloadType }}
21+
{{- end }}
22+
{{- if .deploymentName }}
1623
deploymentName: {{ .deploymentName }}
24+
{{- end }}
1725
containerSelector: {{- toYaml .containerSelector | nindent 4 }}
1826
{{- if .agentPoolCredentials.existingSecret }}
1927
secretName: {{ .agentPoolCredentials.existingSecret }}

charts/lightrun-agents/values.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ javaAgents: []
1111
#javaAgents:
1212
# - name: 'my-service-1'
1313
# namespace: 'my-namespace-1'
14-
# deploymentName: "my-deployment-1"
14+
# # New workload configuration (recommended)
15+
# workloadName: "my-deployment-1"
16+
# workloadType: "Deployment" # or "StatefulSet"
17+
# # Legacy configuration (deprecated, use workloadName and workloadType instead)
18+
# # deploymentName: "my-deployment-1"
1519
# containerSelector:
1620
# - my-container-1
1721
# serverHostname: 'lightrun.example.com'
@@ -32,7 +36,9 @@ javaAgents: []
3236
# initContainer:
3337
# image: "lightruncom/k8s-operator-init-java-agent-linux:latest"
3438
# imagePullPolicy: "IfNotPresent"
35-
# deploymentName: "my-deployment-2"
39+
# # Example of StatefulSet configuration
40+
# workloadName: "my-statefulset-2"
41+
# workloadType: "StatefulSet"
3642
# containerSelector:
3743
# - my-container-2
3844
# serverHostname: 'lightrun.example.com'
@@ -55,7 +61,11 @@ javaAgents: []
5561
#javaAgents:
5662
# - name: 'my-service-1'
5763
# namespace: 'my-namespace-1'
58-
# deploymentName: "my-deployment-1"
64+
# # New workload configuration (recommended)
65+
# workloadName: "my-deployment-1"
66+
# workloadType: "Deployment" # or "StatefulSet"
67+
# # Legacy configuration (deprecated, use workloadName and workloadType instead)
68+
# # deploymentName: "my-deployment-1"
5969
# containerSelector:
6070
# - my-container-1
6171
# serverHostname: 'lightrun.example.com'
@@ -84,7 +94,9 @@ javaAgents: []
8494
# imagePullPolicy: "IfNotPresent"
8595
# sharedVolumeName: 'my-shared-volume'
8696
# sharedVolumeMountPath: '/mypath'
87-
# deploymentName: "my-deployment-2"
97+
# # Example of StatefulSet configuration
98+
# workloadName: "my-statefulset-2"
99+
# workloadType: "StatefulSet"
88100
# containerSelector:
89101
# - my-container-2
90102
# serverHostname: 'lightrun.example.com'

0 commit comments

Comments
 (0)