Skip to content

Commit 7fbc1a4

Browse files
authored
Merge pull request #50 from lightrun-platform/DEVOPS-2694-security-lightrun-installer-container-must-not-consume-secrets-as-env-vars-2nd-attempt
DEVOPS-2694-security-lightrun-installer-container-must-not-consume-secrets-as-env-vars-2nd-attempt
2 parents 7c90c92 + 9ad2f96 commit 7fbc1a4

File tree

14 files changed

+263
-110
lines changed

14 files changed

+263
-110
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+
useSecretsAsMountedFiles: false
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
@@ -93,6 +93,10 @@ type LightrunJavaAgentSpec struct {
9393
// +optional
9494
// Agent name for registration to the server
9595
AgentName string `json:"agentName,omitempty"`
96+
97+
// UseSecretsAsMountedFiles determines whether to use secret values as mounted files (true) or as environment variables (false)
98+
// +kubebuilder:default=false
99+
UseSecretsAsMountedFiles bool `json:"useSecretsAsMountedFiles,omitempty"`
96100
}
97101

98102
// LightrunJavaAgentStatus defines the observed state of LightrunJavaAgent

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ spec:
2929
secretName: {{ .name }}-secret
3030
{{- end }}
3131
serverHostname: {{ .serverHostname }}
32+
{{- if .useSecretsAsMountedFiles }}
33+
useSecretsAsMountedFiles: {{ .useSecretsAsMountedFiles | default false }}
34+
{{- end }}
3235
agentEnvVarName: {{ .agentEnvVarName | default "JAVA_TOOL_OPTIONS" }}
3336
{{- if .agentConfig }}
3437
agentConfig: {{ toYaml .agentConfig | nindent 4 }}

charts/lightrun-agents/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ javaAgents: []
1919
# containerSelector:
2020
# - my-container-1
2121
# serverHostname: 'lightrun.example.com'
22+
# useSecretsAsMountedFiles: false
2223
# initContainer:
2324
# image: "lightruncom/k8s-operator-init-java-agent-linux:latest"
2425
# imagePullPolicy: "IfNotPresent"
@@ -42,6 +43,7 @@ javaAgents: []
4243
# containerSelector:
4344
# - my-container-2
4445
# serverHostname: 'lightrun.example.com'
46+
# useSecretsAsMountedFiles: false
4547
# agentPoolCredentials:
4648
# existingSecret: "my-existing-secret"
4749
# apiKey: ""
@@ -69,6 +71,7 @@ javaAgents: []
6971
# containerSelector:
7072
# - my-container-1
7173
# serverHostname: 'lightrun.example.com'
74+
# useSecretsAsMountedFiles: false
7275
# agentEnvVarName: '_JAVA_OPTIONS'
7376
# agentConfig:
7477
# max_log_cpu_cost: "2"
@@ -100,6 +103,7 @@ javaAgents: []
100103
# containerSelector:
101104
# - my-container-2
102105
# serverHostname: 'lightrun.example.com'
106+
# useSecretsAsMountedFiles: false
103107
# agentEnvVarName: 'JAVA_OPTS'
104108
# agentConfig:
105109
# 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
@@ -123,6 +123,11 @@ spec:
123123
Lightrun server hostname that will be used for downloading an agent
124124
Key and company id in the secret has to be taken from this server as well
125125
type: string
126+
useSecretsAsMountedFiles:
127+
default: false
128+
description: UseSecretsAsMountedFiles determines whether to use secret
129+
values as mounted files (true) or as environment variables (false)
130+
type: boolean
126131
workloadName:
127132
description: Name of the Workload that will be patched. workload can
128133
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
@@ -124,6 +124,11 @@ spec:
124124
Lightrun server hostname that will be used for downloading an agent
125125
Key and company id in the secret has to be taken from this server as well
126126
type: string
127+
useSecretsAsMountedFiles:
128+
default: false
129+
description: UseSecretsAsMountedFiles determines whether to use secret
130+
values as mounted files (true) or as environment variables (false)
131+
type: boolean
127132
workloadName:
128133
description: Name of the Workload that will be patched. workload can
129134
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+
useSecretsAsMountedFiles: false
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
@@ -135,6 +135,11 @@ spec:
135135
Lightrun server hostname that will be used for downloading an agent
136136
Key and company id in the secret has to be taken from this server as well
137137
type: string
138+
useSecretsAsMountedFiles:
139+
default: false
140+
description: UseSecretsAsMountedFiles determines whether to use secret
141+
values as mounted files (true) or as environment variables (false)
142+
type: boolean
138143
workloadName:
139144
description: Name of the Workload that will be patched. workload can
140145
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
@@ -51,6 +51,9 @@ spec:
5151
# If container not mentioned here it will be not patched
5252
containerSelector:
5353
- app
54+
# useSecretsAsMountedFiles determines whether to use secret values as environment variables (false) or as mounted files (true)
55+
# Default is false for backward compatibility
56+
useSecretsAsMountedFiles: false
5457
---
5558
apiVersion: v1
5659
metadata:

examples/lightrunjavaagent.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ spec:
6161
- latest
6262
# Agent name. If not provided, pod name will be used
6363
#agentName: "operator-test-agent"
64+
65+
# UseSecretsAsMountedFiles determines whether to use secret values as mounted files (true) or as environment variables (false)
66+
# Default is false for better security practices
67+
useSecretsAsMountedFiles: false

examples/operator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ spec:
125125
Lightrun server hostname that will be used for downloading an agent
126126
Key and company id in the secret has to be taken from this server as well
127127
type: string
128+
useSecretsAsMountedFiles:
129+
default: false
130+
description: UseSecretsAsMountedFiles determines whether to use secret
131+
values as mounted files (true) or as environment variables (false)
132+
type: boolean
128133
workloadName:
129134
description: Name of the Workload that will be patched. workload can
130135
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset

0 commit comments

Comments
 (0)