Skip to content

DEVOPS-2694-security-lightrun-installer-container-must-not-consume-secrets-as-env-vars #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests_data/lightrunjavaagent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ spec:
deploymentName: sample-deployment
secretName: lightrun-secrets
serverHostname: dogfood.internal.lightrun.com
useSecretAsEnvVars: true
agentEnvVarName: JAVA_TOOL_OPTIONS
agentConfig:
max_log_cpu_cost: "2"
Expand Down
4 changes: 4 additions & 0 deletions api/v1beta/lightrunjavaagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ type LightrunJavaAgentSpec struct {
// +optional
// Agent name for registration to the server
AgentName string `json:"agentName,omitempty"`

// UseSecretAsEnvVars determines whether to use secret values as environment variables (true) or as mounted files (false)
// +kubebuilder:default=true
UseSecretAsEnvVars bool `json:"useSecretAsEnvVars,omitempty"`
}

// LightrunJavaAgentStatus defines the observed state of LightrunJavaAgent
Expand Down
2 changes: 1 addition & 1 deletion charts/lightrun-agents/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.1
version: 0.0.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to bump version directly on the Chart.yaml file. it automatically bumped as part of release pipeline.

1 change: 1 addition & 0 deletions charts/lightrun-agents/templates/java-agent-cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ spec:
secretName: {{ .name }}-secret
{{- end }}
serverHostname: {{ .serverHostname }}
useSecretAsEnvVars: {{ .useSecretAsEnvVars | default true }}
Copy link
Contributor

@imeliran imeliran Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider wrap it with if condition. because I might use newer version of lightrun-agents chart with an old values that not necessary has this field and I assume it will cause template error.

Suggested change
useSecretAsEnvVars: {{ .useSecretAsEnvVars | default true }}
{{- if .useSecretAsEnvVars }}
useSecretAsEnvVars: {{ .useSecretAsEnvVars }}
{{- end }}

agentEnvVarName: {{ .agentEnvVarName | default "JAVA_TOOL_OPTIONS" }}
{{- if .agentConfig }}
agentConfig: {{ toYaml .agentConfig | nindent 4 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/lightrun-agents/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ javaAgents: []
# containerSelector:
# - my-container-1
# serverHostname: 'lightrun.example.com'
# useSecretAsEnvVars: true
# initContainer:
# image: "lightruncom/k8s-operator-init-java-agent-linux:latest"
# agentPoolCredentials:
Expand All @@ -34,6 +35,7 @@ javaAgents: []
# containerSelector:
# - my-container-2
# serverHostname: 'lightrun.example.com'
# useSecretAsEnvVars: true
# agentPoolCredentials:
# existingSecret: "my-existing-secret"
# apiKey: ""
Expand All @@ -57,6 +59,7 @@ javaAgents: []
# containerSelector:
# - my-container-1
# serverHostname: 'lightrun.example.com'
# useSecretAsEnvVars: true
# agentEnvVarName: '_JAVA_OPTIONS'
# agentConfig:
# max_log_cpu_cost: "2"
Expand Down Expand Up @@ -84,6 +87,7 @@ javaAgents: []
# containerSelector:
# - my-container-2
# serverHostname: 'lightrun.example.com'
# useSecretAsEnvVars: true
# agentEnvVarName: 'JAVA_OPTS'
# agentConfig:
# max_log_cpu_cost: "2"
Expand Down
5 changes: 5 additions & 0 deletions charts/lightrun-operator/crds/lightrunjavaagent_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ spec:
Lightrun server hostname that will be used for downloading an agent
Key and company id in the secret has to be taken from this server as well
type: string
useSecretAsEnvVars:
default: true
description: UseSecretAsEnvVars determines whether to use secret values
as environment variables (true) or as mounted files (false)
type: boolean
workloadName:
description: Name of the Workload that will be patched. workload can
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/agents.lightrun.com_lightrunjavaagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ spec:
Lightrun server hostname that will be used for downloading an agent
Key and company id in the secret has to be taken from this server as well
type: string
useSecretAsEnvVars:
default: true
description: UseSecretAsEnvVars determines whether to use secret values
as environment variables (true) or as mounted files (false)
type: boolean
workloadName:
description: Name of the Workload that will be patched. workload can
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
Expand Down
1 change: 1 addition & 0 deletions config/samples/agents_v1beta_lightrunjavaagent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
workloadType: Deployment
secretName: lightrun-secrets
serverHostname: <lightrun_server> #for saas it will be app.lightrun.com
useSecretAsEnvVars: true
agentEnvVarName: JAVA_TOOL_OPTIONS
agentConfig:
max_log_cpu_cost: "2"
Expand Down
5 changes: 5 additions & 0 deletions config/samples/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ spec:
Lightrun server hostname that will be used for downloading an agent
Key and company id in the secret has to be taken from this server as well
type: string
useSecretAsEnvVars:
default: true
description: UseSecretAsEnvVars determines whether to use secret values
as environment variables (true) or as mounted files (false)
type: boolean
workloadName:
description: Name of the Workload that will be patched. workload can
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
Expand Down
3 changes: 3 additions & 0 deletions docs/custom_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ spec:
# If container not mentioned here it will be not patched
containerSelector:
- app
# UseSecretAsEnvVars determines whether to use secret values as environment variables (true) or as mounted files (false)
# Default is true for backward compatibility
useSecretAsEnvVars: true
---
apiVersion: v1
metadata:
Expand Down
4 changes: 4 additions & 0 deletions examples/lightrunjavaagent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ spec:
- latest
# Agent name. If not provided, pod name will be used
#agentName: "operator-test-agent"

# UseSecretAsEnvVars determines whether to use secret values as environment variables (true) or as mounted files (false)
# Default is true for backward compatibility
useSecretAsEnvVars: true
5 changes: 5 additions & 0 deletions examples/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ spec:
Lightrun server hostname that will be used for downloading an agent
Key and company id in the secret has to be taken from this server as well
type: string
useSecretAsEnvVars:
default: true
description: UseSecretAsEnvVars determines whether to use secret values
as environment variables (true) or as mounted files (false)
type: boolean
workloadName:
description: Name of the Workload that will be patched. workload can
be either Deployment or StatefulSet e.g. my-deployment, my-statefulset
Expand Down
Loading
Loading