From 91789255dfbcc6b1b4eebdbea862456ebcf56363 Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Tue, 31 Mar 2026 13:09:22 +0200 Subject: [PATCH] feat(must-gather): allow passing extra env vars to the must-gather container --- charts/must-gather/Chart.yaml | 2 +- charts/must-gather/README.md | 7 +- .../with-secrets-and-cluster-info-values.yaml | 7 +- charts/must-gather/templates/deployment.yaml | 3 + charts/must-gather/values.schema.json | 118 ++++++++++++++++++ charts/must-gather/values.schema.tmpl.json | 8 ++ charts/must-gather/values.yaml | 4 + 7 files changed, 144 insertions(+), 5 deletions(-) diff --git a/charts/must-gather/Chart.yaml b/charts/must-gather/Chart.yaml index eeee1300..95c95ef5 100644 --- a/charts/must-gather/Chart.yaml +++ b/charts/must-gather/Chart.yaml @@ -35,4 +35,4 @@ maintainers: # Versions are expected to follow Semantic Versioning (https://semver.org/) # Note that when this chart is published to https://github.com/openshift-helm-charts/charts # it will follow the RHDH versioning 1.y.z -version: 0.1.0 +version: 0.2.0 diff --git a/charts/must-gather/README.md b/charts/must-gather/README.md index 766d6600..473366be 100644 --- a/charts/must-gather/README.md +++ b/charts/must-gather/README.md @@ -1,7 +1,7 @@ # Must Gather Chart for Red Hat Developer Hub (RHDH) -![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) +![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) A Helm chart for deploying the RHDH Must-Gather diagnostic tool on Kubernetes @@ -27,7 +27,7 @@ Kubernetes: `>= 1.27.0-0` ```console helm upgrade --install my-rhdh-must-gather rhdh-must-gather \ --repo https://redhat-developer.github.io/rhdh-chart \ - --version 0.1.0 + --version 0.2.0 ``` Running the command again will automatically replace the previous pod and start a new gather. @@ -105,9 +105,10 @@ The command removes all the Kubernetes resources associated with the chart and d | dataHolder | Runs alongside the gather container and stays alive so you can exec in and retrieve the output. | object | `{"resources":{"limits":{"cpu":"100m","ephemeral-storage":"64Mi","memory":"128Mi"},"requests":{"cpu":"50m","ephemeral-storage":"32Mi","memory":"64Mi"}}}` | | dataHolder.resources | Resource requests and limits for the data-holder container | object | `{"limits":{"cpu":"100m","ephemeral-storage":"64Mi","memory":"128Mi"},"requests":{"cpu":"50m","ephemeral-storage":"32Mi","memory":"64Mi"}}` | | fullnameOverride | | string | `""` | -| gather | Gather script configuration | object | `{"clusterInfo":false,"cmdTimeout":"30","extraArgs":[],"logLevel":"info","namespaces":[],"since":"","sinceTime":"","withHeapDumps":false,"withHelm":true,"withIngress":true,"withNamespaceInspect":true,"withOperator":true,"withOrchestrator":true,"withPlatform":true,"withRoute":true,"withSecrets":false}` | +| gather | Gather script configuration | object | `{"clusterInfo":false,"cmdTimeout":"30","extraArgs":[],"extraEnvVars":[],"logLevel":"info","namespaces":[],"since":"","sinceTime":"","withHeapDumps":false,"withHelm":true,"withIngress":true,"withNamespaceInspect":true,"withOperator":true,"withOrchestrator":true,"withPlatform":true,"withRoute":true,"withSecrets":false}` | | gather.cmdTimeout | Command timeout for individual kubectl/helm commands (seconds) | string | `"30"` | | gather.extraArgs | Additional custom arguments to pass to the gather script | list | `[]` | +| gather.extraEnvVars | Additional environment variables to pass to the gather init container.
See [Define Environment variables for a container](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container). | list | `[]` | | gather.logLevel | Log level: info, INFO, debug, DEBUG, trace, TRACE | string | `"info"` | | gather.namespaces | Example: ["rhdh-prod", "rhdh-staging"] | list | `[]` | | gather.since | Relative time for log collection (e.g., "2h", "30m") | string | `""` | diff --git a/charts/must-gather/ci/with-secrets-and-cluster-info-values.yaml b/charts/must-gather/ci/with-secrets-and-cluster-info-values.yaml index f52888cd..3629b96d 100644 --- a/charts/must-gather/ci/with-secrets-and-cluster-info-values.yaml +++ b/charts/must-gather/ci/with-secrets-and-cluster-info-values.yaml @@ -2,4 +2,9 @@ gather: withSecrets: true clusterInfo: true - logLevel: "DEBUG" + logLevel: "INFO" + extraEnvVars: + - name: CMD_TIMEOUT + value: "5" + - name: LOG_LEVEL + value: "debug" diff --git a/charts/must-gather/templates/deployment.yaml b/charts/must-gather/templates/deployment.yaml index 27ad1e64..03b8da1e 100644 --- a/charts/must-gather/templates/deployment.yaml +++ b/charts/must-gather/templates/deployment.yaml @@ -68,6 +68,9 @@ spec: - name: MUST_GATHER_SINCE_TIME value: {{ .Values.gather.sinceTime | quote }} {{- end }} + {{- with .Values.gather.extraEnvVars }} + {{- toYaml . | nindent 12 }} + {{- end }} {{- $nsScope := ne .Values.rbac.scope "cluster" }} {{- $effectiveNamespaces := .Values.gather.namespaces }} {{- if $nsScope }} diff --git a/charts/must-gather/values.schema.json b/charts/must-gather/values.schema.json index b6696abb..be9dc2f9 100644 --- a/charts/must-gather/values.schema.json +++ b/charts/must-gather/values.schema.json @@ -839,6 +839,124 @@ "title": "Additional custom arguments to pass to the gather script.", "type": "array" }, + "extraEnvVars": { + "default": [], + "items": { + "description": "EnvVar represents an environment variable present in a Container.", + "properties": { + "name": { + "description": "Name of the environment variable. Must be a C_IDENTIFIER.", + "type": "string" + }, + "value": { + "description": "Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to \"\".", + "type": "string" + }, + "valueFrom": { + "description": "EnvVarSource represents a source for the value of an EnvVar.", + "properties": { + "configMapKeyRef": { + "description": "Selects a key from a ConfigMap.", + "properties": { + "key": { + "description": "The key to select.", + "type": "string" + }, + "name": { + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the ConfigMap or its key must be defined", + "type": "boolean" + } + }, + "required": [ + "key" + ], + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "fieldRef": { + "description": "ObjectFieldSelector selects an APIVersioned field of an object.", + "properties": { + "apiVersion": { + "description": "Version of the schema the FieldPath is written in terms of, defaults to \"v1\".", + "type": "string" + }, + "fieldPath": { + "description": "Path of the field to select in the specified API version.", + "type": "string" + } + }, + "required": [ + "fieldPath" + ], + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "resourceFieldRef": { + "description": "ResourceFieldSelector represents container resources (cpu, memory) and their output format", + "properties": { + "containerName": { + "description": "Container name: required for volumes, optional for env vars", + "type": "string" + }, + "divisor": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "number" + } + ] + }, + "resource": { + "description": "Required: resource to select", + "type": "string" + } + }, + "required": [ + "resource" + ], + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "secretKeyRef": { + "description": "SecretKeySelector selects a key of a Secret.", + "properties": { + "key": { + "description": "The key of the secret to select from. Must be a valid secret key.", + "type": "string" + }, + "name": { + "description": "Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the Secret or its key must be defined", + "type": "boolean" + } + }, + "required": [ + "key" + ], + "type": "object", + "x-kubernetes-map-type": "atomic" + } + }, + "type": "object" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "title": "Additional environment variables to pass to the gather init container.", + "type": "array" + }, "logLevel": { "default": "info", "enum": [ diff --git a/charts/must-gather/values.schema.tmpl.json b/charts/must-gather/values.schema.tmpl.json index f6305517..17fc4ebe 100644 --- a/charts/must-gather/values.schema.tmpl.json +++ b/charts/must-gather/values.schema.tmpl.json @@ -265,6 +265,14 @@ "type": "string" }, "default": [] + }, + "extraEnvVars": { + "title": "Additional environment variables to pass to the gather init container.", + "type": "array", + "items": { + "$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.4/_definitions.json#/definitions/io.k8s.api.core.v1.EnvVar" + }, + "default": [] } } }, diff --git a/charts/must-gather/values.yaml b/charts/must-gather/values.yaml index 6549be92..3d329a5b 100644 --- a/charts/must-gather/values.yaml +++ b/charts/must-gather/values.yaml @@ -96,6 +96,10 @@ gather: # -- Additional custom arguments to pass to the gather script extraArgs: [] + # -- Additional environment variables to pass to the gather init container.
+ # See [Define Environment variables for a container](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container). + extraEnvVars: [] + # -- Resource requests and limits for the gather container resources: requests: