Skip to content

ci: render charts with exhaustive test values through kubeconform and kustomize - #1034

Draft
marcleblanc2 wants to merge 3 commits into
mainfrom
marc/ci-kustomize-duplicate-keys
Draft

marcleblanc2 wants to merge 3 commits into
mainfrom
marc/ci-kustomize-duplicate-keys

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Our charts have templates that break as soon as a customer sets a documented value, and CI never notices. Buildkite only validates the charts rendered with their default values, and nothing checks the output the way customers consume it. Sourcegraph Cloud and customers who post-process the chart run kustomize over it, and kustomize rejects YAML that Helm accepts, such as a label key repeated in one map.

This PR's check current fails on main; each item below is a value a customer can set today that breaks their deploy.

Problem Check Test file
jaeger.serviceAccount.create: true fails with index of nil pointer: jaeger.ServiceAccount.yaml passes "tracing", which is not a values key helm template sourcegraph/tests/kustomizeRender_allValues.yaml, allValuesAlternate.yaml
openTelemetry.agent.env renders invalid YAML: value: is indented under name: helm template sourcegraph/tests/kustomizeRender_allValues.yaml, masked by the problem above
privateDockerRegistry.serviceAnnotations renders invalid YAML: annotations: is indented 4 spaces instead of 2 helm template sourcegraph-executor/dind/tests/kustomizeRender_allValues.yaml
A label or annotation key set globally and per component is rendered twice in one map. kubeconform 0.4.12, the version in .tool-versions, accepts the duplicates; newer versions reject them kustomize sourcegraph/tests/kustomizeRender_labelOverrides.yaml

A one-off scan during development also found documented values that render nothing. They are not part of this check:

  • sourcegraph.serviceLabels
  • redisStore.serviceAccount.annotations
  • jaeger.extraSelectorLabels
  • storageClass.allowVolumeExpansion: false, which renders true
  • sourcegraph-executor/k8s: sourcegraph.labels, sourcegraph.nodeSelector, sourcegraph.affinity, sourcegraph.tolerations, executor.securityContext.privileged
  • sourcegraph-executor/dind: storageClass.*, executor.maximumNumJobs

Solution

New GitHub Actions job Render charts through kustomize (.github/workflows/kustomize_render.yml) runs scripts/ci/kustomize-render.sh. For every charts/**/tests/kustomizeRender_*.yaml, it runs helm template, then:

  • kubeconform -strict: catches values rendered in the wrong place or with the wrong type
  • a grep for Go template output such as map[, %!, or <no value> in the manifests
  • kubectl kustomize: catches YAML that kustomize rejects, such as duplicate keys

Helm and kubeconform come from .tool-versions through jdx/mise-action, the same versions Buildkite uses. kubectl comes with the runner image.

The test values files sit next to the helm-unittest suites in each chart's tests/ directory. helm-unittest only loads *_test.yaml, so it ignores them. Each file starts with a header naming this CI job, and all names and endpoints are placeholders.

  • kustomizeRender_sourcegraphCloud.yaml, kustomizeRender_selfHosted.yaml: shaped like Sourcegraph Cloud and common self-hosted deployments
  • kustomizeRender_allValues.yaml, plus allValuesAlternate and allValuesExternalServices where a chart has either-or choices: set every value the templates read to a non-default value. Label and annotation keys differ at each level, so a duplicate key in these renders is a template bug.
  • kustomizeRender_labelOverrides.yaml: the same label key at the global and component levels, where the component value should win

Checklist

Test plan

Ran scripts/ci/kustomize-render.sh locally with Helm 4.3 and kubeconform 0.8.0, and in this PR's CI run with the .tool-versions versions. Both fail on the same 4 files:

  • kustomizeRender_sourcegraphCloud.yaml, every kustomizeRender_selfHosted.yaml, allValuesExternalServices.yaml, and the executor and migrator files other than dind allValues pass all three checks.
  • The files in the Problem table fail as described.
  • With scratch workarounds for the three template bugs, every allValues file passes all three checks, so nothing else is hiding behind them.
  • Control: renaming one field in a rendered manifest makes kubeconform fail.

helm unittest (281 tests) and scripts/ci/lint.sh pass, and ./scripts/helm-docs.sh changes nothing.

Linked PRs

  • #1008: fixes the jaeger.ServiceAccount.yaml render failure, and deduplicates the label keys that kustomizeRender_labelOverrides.yaml repeats

Amp threads

marcleblanc2 and others added 2 commits November 25, 2026 15:32
Helm emits a map key twice when a label or annotation is set at both the
global and the component level. Helm and kubectl accept that, but kustomize
rejects it, which breaks anyone who runs kustomize over the chart.

Add tests/kustomizeRender_*.yaml values files for each chart, shaped like
Sourcegraph Cloud and self-hosted deployments, and a workflow that renders
each chart with them and builds the output with kustomize. Helm comes from
.tool-versions, as on Buildkite. kustomizeRender_labelOverrides.yaml fails on
main until the chart deduplicates these keys.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a2140d-bf64-751f-9812-0c8757baf6fd
Add tests/kustomizeRender_allValues*.yaml for each chart. Together they set
every value the templates read to a non-default value, with alternate files
for either-or choices, such as existing Secrets, ingress host lists, and
external services. Label and annotation keys differ at each level, so a
duplicate key in these renders is a template bug.

kustomize-render.sh now also validates each render with kubeconform -strict,
as the Buildkite schema step does for default values, and fails on Go
template output such as map[ or <no value> in the manifests.

On main, these find:
- sourcegraph: jaeger.serviceAccount.create fails to render
- sourcegraph: openTelemetry.agent.env renders invalid YAML
- sourcegraph-executor-dind: privateDockerRegistry.serviceAnnotations renders
  invalid YAML

Amp-Thread-ID: https://ampcode.com/threads/T-01a2140d-bf64-751f-9812-0c8757baf6fd
Co-authored-by: Amp <amp@ampcode.com>
@github-actions

Copy link
Copy Markdown

…files

Checkov's CKV_SECRET_6 flags the placeholder Secret names and passwords in
tests/kustomizeRender_*.yaml. They are not secrets, so skip the check on
those lines, the way alert 347 on frontendIngress_test.yaml was dismissed as
used in tests.

Amp-Thread-ID: https://ampcode.com/threads/T-01a2140d-bf64-751f-9812-0c8757baf6fd
Co-authored-by: Amp <amp@ampcode.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants