Skip to content

Commit e895b2f

Browse files
committed
feat(helm): add server.extraEnv for the gateway container
Signed-off-by: Eric Curtin <eric.curtin@docker.com>
1 parent 72e4eaa commit e895b2f

5 files changed

Lines changed: 60 additions & 0 deletions

File tree

‎deploy/helm/openshell/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ discovery endpoint or its TLS CA.
527527
| server.enableUserNamespaces | bool | `false` | Enable Kubernetes user namespace isolation (hostUsers: false) for sandbox pods. Requires Kubernetes 1.33+ with user namespace support available (beta through 1.35, GA in 1.36+), plus a supporting container runtime and Linux 5.12+. When enabled, container UID 0 maps to an unprivileged host UID and capabilities become namespaced. |
528528
| server.enableWebsocketTunnel | bool | `false` | Enable the WebSocket tunnel used by CLI/SDK clients behind an authenticated edge proxy. Leave disabled for direct gateway installs. |
529529
| server.externalDbSecret | string | `""` | Name of a pre-existing Opaque Secret containing a PostgreSQL connection URI (key: uri). When set, the gateway reads OPENSHELL_DB_URL from this Secret instead of using dbUrl. The Secret must contain a `uri` key, e.g. postgresql://user:pass@host:5432/dbname. |
530+
| server.extraEnv | list | `[]` | Additional environment variables for the gateway container, such as OTEL_* exporter settings. Entries can read from a Secret with valueFrom. |
530531
| server.extraVolumeMounts | list | `[]` | Additional volume mounts for the gateway container. |
531532
| server.extraVolumes | list | `[]` | Additional volumes for the gateway pod. |
532533
| server.grpcEndpoint | string | `""` | gRPC endpoint sandboxes call back into the gateway. Leave empty to derive it from the chart fullname, release namespace, service port, and disableTls flag, for example https://openshell.openshell.svc.cluster.local:8080. Override only when sandboxes must reach the gateway via a different hostname (e.g. an external ingress or a host alias). |

‎deploy/helm/openshell/templates/_gateway-workload.tpl‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ spec:
140140
- name: OPENSHELL_GATEWAY_SPIFFE_WORKLOAD_API_SOCKET
141141
value: {{ $spiffeSocketPath | quote }}
142142
{{- end }}
143+
{{- with .Values.server.extraEnv }}
144+
{{- toYaml . | nindent 8 }}
145+
{{- end }}
143146
volumeMounts:
144147
{{- if eq (include "openshell.workloadKind" .) "statefulset" }}
145148
- name: openshell-data

‎deploy/helm/openshell/tests/gateway_config_test.yaml‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,47 @@ tests:
508508
mountPath: /var/log/openshell
509509
subPathExpr: $(OPENSHELL_POD_NAME)
510510

511+
- it: adds extra gateway environment variables in a StatefulSet
512+
template: templates/statefulset.yaml
513+
set:
514+
server.extraEnv:
515+
- name: OTEL_TRACES_SAMPLER
516+
value: parentbased_traceidratio
517+
- name: OTEL_EXPORTER_OTLP_HEADERS
518+
valueFrom:
519+
secretKeyRef:
520+
name: otel-collector-auth
521+
key: headers
522+
asserts:
523+
- contains:
524+
path: spec.template.spec.containers[0].env
525+
content:
526+
name: OTEL_TRACES_SAMPLER
527+
value: parentbased_traceidratio
528+
- contains:
529+
path: spec.template.spec.containers[0].env
530+
content:
531+
name: OTEL_EXPORTER_OTLP_HEADERS
532+
valueFrom:
533+
secretKeyRef:
534+
name: otel-collector-auth
535+
key: headers
536+
537+
- it: adds extra gateway environment variables in a Deployment
538+
template: templates/deployment.yaml
539+
set:
540+
workload.kind: deployment
541+
server.externalDbSecret: my-pg-secret
542+
server.extraEnv:
543+
- name: OTEL_TRACES_SAMPLER
544+
value: parentbased_traceidratio
545+
asserts:
546+
- contains:
547+
path: spec.template.spec.containers[0].env
548+
content:
549+
name: OTEL_TRACES_SAMPLER
550+
value: parentbased_traceidratio
551+
511552
- it: mounts the OIDC CA bundle when TLS is disabled
512553
template: templates/statefulset.yaml
513554
set:

‎deploy/helm/openshell/values.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ server:
369369
extraVolumes: []
370370
# -- Additional volume mounts for the gateway container.
371371
extraVolumeMounts: []
372+
# -- Additional environment variables for the gateway container, such as
373+
# OTEL_* exporter settings. Entries can read from a Secret with valueFrom.
374+
extraEnv: []
372375
# -- Enable anonymous OpenShell telemetry from the gateway and the sandbox
373376
# supervisors it launches.
374377
telemetryEnabled: true

‎docs/how-it-works/gateways/configuration.mdx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,18 @@ The gateway honors these variables:
506506
| `OTEL_EXPORTER_OTLP_LOGS_HEADERS`, `OTEL_EXPORTER_OTLP_LOGS_COMPRESSION`, `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT` | Exporter transport tuning for OCSF log records only. These override the general variables. |
507507
| `SSL_CERT_FILE`, `SSL_CERT_DIR` | Additional trust roots for `https://` endpoints, such as a private CA. |
508508

509+
For Helm deployments, set these variables with `server.extraEnv`. Read credentials from a Secret so they stay out of the values file:
510+
511+
```yaml
512+
server:
513+
extraEnv:
514+
- name: OTEL_EXPORTER_OTLP_HEADERS
515+
valueFrom:
516+
secretKeyRef:
517+
name: otel-collector-auth
518+
key: headers
519+
```
520+
509521
These variables have no effect. Only `[openshell.gateway.otlp]` decides which signals are exported and where they go, for two reasons:
510522

511523
- OCSF events are security records, so where they go must be a deliberate choice. Platform tooling can add `OTEL_*` variables to a process, as the OpenTelemetry Operator does for annotated pods on Kubernetes. Such a variable must not start sending security records to a collector, redirect them, or turn them off.

0 commit comments

Comments
 (0)