Render the registry configuration with gomplate

What does this MR do?

The registry configure init container spliced secrets into config.yml with sed. sed treats the secret as part of its expression, so passwords containing &, @, \ or newlines were corrupted or replaced with the literal placeholder, and the script ignored the failure. The script also needs a shell, sed, grep and coreutils, which a minimal init image does not have.

With default values, the init container in the registry Deployment and the migrations Job now runs gomplate with no shell:

command: ["gomplate", "--left-delim", "{%", "--right-delim", "%}", "--file", "/templates/config.yml.tpl", "--out", "/registry/config.yml"]
  • Scalar secrets (HTTP secret, database password, Redis cache, rate-limiting and load-balancing passwords) are read as data and emitted as JSON strings: file.Read | strings.TrimRight "\n" | data.ToJSON. TrimRight matches $(cat), which strips all trailing newlines.
  • Storage and notification header secrets are inserted as indented YAML text, as the sed splice did, not parsed and re-emitted. A data.YAML | data.ToYAML round trip quotes secure: yes and v4auth: on, which the S3 driver rejects. The delete.enabled: true default is added when the storage Secret has no top-level delete key, checked with a regex, so input the registry accepts (for example duplicate keys) does not fail the init container.
  • Files that config.yml references (certificate, storage extraKey, middleware.storage, profiling key, TLS and database SSL material) are mounted from a projected registry-files volume with subPath, not copied. Key files use mode 0440 with securityContext.fsGroup and 0444 without it. pgx and Go crypto/tls do not check key permissions. The configure container mounts only the Secrets the template reads.
  • {% in values is escaped. Chart-emitted gomplate actions are rendered as NUL-delimited placeholders, every {% in the text is escaped, then the placeholders are swapped back, so a value can never become an action. A value containing NUL fails rendering.
  • A custom registry.init.script keeps the previous behaviour byte for byte: the same placeholders, /config layout and sh /config/configure. It is documented as requiring an init image with a shell. It is not deprecated: the init step stays and only its interpreter changes, so a user hook into it is still coherent.

The first commit is a pure refactor that moves the config body into named templates; its helm template output is identical to master.

Upgrade notes

Added to doc/charts/registry/_index.md and doc/releases/10_0.md:

  • The init image needs gomplate on PATH. The Debian and UBI gitlab-base images have it.
  • {% %} in values was previously evaluated by the gitlab-base entrypoint (set-config) and is now literal on the default path.
  • The registry-server-config volume now holds only config.yml.

Sentinel passwords already reached the registry before this change: the configure container set only args:, so the entrypoint rendered /templates/*.tpl before the script. command: now bypasses the entrypoint, so the template is rendered once.

Dependency for the hardened (nix) images

The hardened gitlab-base image ships gomplate but sets no PATH, so the init container fails there with exec: "gomplate": executable file not found in $PATH. That needs a hardened-builds change before this reaches the nix variant (gitlab-org/software-supply-chain-security/hardened-builds#35 (closed)). Debian and UBI are unaffected.

Closes #6730 (closed)

Author checklist

For general guidance, please follow our Contributing guide.

Required

For anything in this list which will not be completed, please provide a reason in the MR discussion.

  • Merge Request Title and Description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • MR has a green pipeline.
  • Documentation created/updated.
  • Tests added/updated.
  • Have you validated that your change works end-to-end on a real cluster deployment?
    • On kind, with the Debian gitlab-base init image: TLS, debug TLS, a notification secret header containing & @ \ " # {% as a multi-line block list, and a CRLF storage Secret with extraKey. The registry started, logged the header unchanged, /v2/ returned 401 and debug health 200. Keys were 0440 root:1000 and readable by uid 1000; without fsGroup they were 0444. The migrations Job was not run end to end (no PostgreSQL in that cluster); its init container is covered by specs.
  • Equivalent MR/issue for omnibus-gitlab opened. Not applicable: chart-only init container.
  • When ready for review, MR is marked as ready (not a draft) and assigned to a reviewer.

Reviewers checklist

🤖 Generated with Claude Code

Edited by Clemens Beck

Merge request reports

Loading
Loading