Skip to content

Commit d4efd4d

Browse files
committed
DEVOPS-2694 - Update the lightrun-k8s-operator deployment to mount Secrets as files via volumes instead of exposing them as environment variables in containers.
1 parent 2be38da commit d4efd4d

File tree

15 files changed

+244
-94
lines changed

15 files changed

+244
-94
lines changed

.github/workflows/tests_data/lightrunjavaagent.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ spec:
1010
deploymentName: sample-deployment
1111
secretName: lightrun-secrets
1212
serverHostname: dogfood.internal.lightrun.com
13+
useSecretAsEnvVars: true
1314
agentEnvVarName: JAVA_TOOL_OPTIONS
1415
agentConfig:
1516
max_log_cpu_cost: "2"

api/v1beta/lightrunjavaagent_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ type LightrunJavaAgentSpec struct {
9090
// +optional
9191
// Agent name for registration to the server
9292
AgentName string `json:"agentName,omitempty"`
93+
94+
// UseSecretAsEnvVars determines whether to use secret values as environment variables (true) or as mounted files (false)
95+
// +kubebuilder:default=true
96+
UseSecretAsEnvVars bool `json:"useSecretAsEnvVars,omitempty"`
9397
}
9498

9599
// LightrunJavaAgentStatus defines the observed state of LightrunJavaAgent

charts/lightrun-agents/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.0.1
18+
version: 0.0.2

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ spec:
1818
secretName: {{ .name }}-secret
1919
{{- end }}
2020
serverHostname: {{ .serverHostname }}
21+
useSecretAsEnvVars: {{ .useSecretAsEnvVars | default true }}
2122
agentEnvVarName: {{ .agentEnvVarName | default "JAVA_TOOL_OPTIONS" }}
2223
{{- if .agentConfig }}
2324
agentConfig: {{ toYaml .agentConfig | nindent 4 }}

charts/lightrun-agents/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ javaAgents: []
1515
# containerSelector:
1616
# - my-container-1
1717
# serverHostname: 'lightrun.example.com'
18+
# useSecretAsEnvVars: true
1819
# initContainer:
1920
# image: "lightruncom/k8s-operator-init-java-agent-linux:latest"
2021
# agentPoolCredentials:
@@ -34,6 +35,7 @@ javaAgents: []
3435
# containerSelector:
3536
# - my-container-2
3637
# serverHostname: 'lightrun.example.com'
38+
# useSecretAsEnvVars: true
3739
# agentPoolCredentials:
3840
# existingSecret: "my-existing-secret"
3941
# apiKey: ""
@@ -57,6 +59,7 @@ javaAgents: []
5759
# containerSelector:
5860
# - my-container-1
5961
# serverHostname: 'lightrun.example.com'
62+
# useSecretAsEnvVars: true
6063
# agentEnvVarName: '_JAVA_OPTIONS'
6164
# agentConfig:
6265
# max_log_cpu_cost: "2"
@@ -84,6 +87,7 @@ javaAgents: []
8487
# containerSelector:
8588
# - my-container-2
8689
# serverHostname: 'lightrun.example.com'
90+
# useSecretAsEnvVars: true
8791
# agentEnvVarName: 'JAVA_OPTS'
8892
# agentConfig:
8993
# max_log_cpu_cost: "2"

charts/lightrun-operator/crds/lightrunjavaagent_crd.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ spec:
119119
Lightrun server hostname that will be used for downloading an agent
120120
Key and company id in the secret has to be taken from this server as well
121121
type: string
122+
useSecretAsEnvVars:
123+
default: true
124+
description: UseSecretAsEnvVars determines whether to use secret values
125+
as environment variables (true) or as mounted files (false)
126+
type: boolean
122127
workloadName:
123128
description: Name of the Workload that will be patched. workload can
124129
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset

config/crd/bases/agents.lightrun.com_lightrunjavaagents.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ spec:
120120
Lightrun server hostname that will be used for downloading an agent
121121
Key and company id in the secret has to be taken from this server as well
122122
type: string
123+
useSecretAsEnvVars:
124+
default: true
125+
description: UseSecretAsEnvVars determines whether to use secret values
126+
as environment variables (true) or as mounted files (false)
127+
type: boolean
123128
workloadName:
124129
description: Name of the Workload that will be patched. workload can
125130
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset

config/samples/agents_v1beta_lightrunjavaagent.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ spec:
1111
workloadType: Deployment
1212
secretName: lightrun-secrets
1313
serverHostname: <lightrun_server> #for saas it will be app.lightrun.com
14+
useSecretAsEnvVars: true
1415
agentEnvVarName: JAVA_TOOL_OPTIONS
1516
agentConfig:
1617
max_log_cpu_cost: "2"

config/samples/operator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ spec:
131131
Lightrun server hostname that will be used for downloading an agent
132132
Key and company id in the secret has to be taken from this server as well
133133
type: string
134+
useSecretAsEnvVars:
135+
default: true
136+
description: UseSecretAsEnvVars determines whether to use secret values
137+
as environment variables (true) or as mounted files (false)
138+
type: boolean
134139
workloadName:
135140
description: Name of the Workload that will be patched. workload can
136141
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset

docs/custom_resource.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ spec:
4949
# If container not mentioned here it will be not patched
5050
containerSelector:
5151
- app
52+
# UseSecretAsEnvVars determines whether to use secret values as environment variables (true) or as mounted files (false)
53+
# Default is true for backward compatibility
54+
useSecretAsEnvVars: true
5255
---
5356
apiVersion: v1
5457
metadata:

examples/lightrunjavaagent.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ spec:
5959
- latest
6060
# Agent name. If not provided, pod name will be used
6161
#agentName: "operator-test-agent"
62+
63+
# UseSecretAsEnvVars determines whether to use secret values as environment variables (true) or as mounted files (false)
64+
# Default is true for backward compatibility
65+
useSecretAsEnvVars: true

examples/operator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ spec:
121121
Lightrun server hostname that will be used for downloading an agent
122122
Key and company id in the secret has to be taken from this server as well
123123
type: string
124+
useSecretAsEnvVars:
125+
default: true
126+
description: UseSecretAsEnvVars determines whether to use secret values
127+
as environment variables (true) or as mounted files (false)
128+
type: boolean
124129
workloadName:
125130
description: Name of the Workload that will be patched. workload can
126131
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset

0 commit comments

Comments
 (0)