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.TrimRightmatches$(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.ToYAMLround trip quotessecure: yesandv4auth: on, which the S3 driver rejects. Thedelete.enabled: truedefault is added when the storage Secret has no top-leveldeletekey, checked with a regex, so input the registry accepts (for example duplicate keys) does not fail the init container. - Files that
config.ymlreferences (certificate, storageextraKey,middleware.storage, profiling key, TLS and database SSL material) are mounted from a projectedregistry-filesvolume withsubPath, not copied. Key files use mode0440withsecurityContext.fsGroupand0444without it. pgx and Gocrypto/tlsdo not check key permissions. Theconfigurecontainer 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.scriptkeeps the previous behaviour byte for byte: the same placeholders,/configlayout andsh /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
gomplateonPATH. The Debian and UBIgitlab-baseimages have it. {% %}in values was previously evaluated by thegitlab-baseentrypoint (set-config) and is now literal on the default path.- The
registry-server-configvolume now holds onlyconfig.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.
Related issues
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-baseinit image: TLS, debug TLS, a notification secret header containing& @ \ " # {%as a multi-line block list, and a CRLF storage Secret withextraKey. The registry started, logged the header unchanged,/v2/returned 401 and debug health 200. Keys were0440 root:1000and readable by uid 1000; withoutfsGroupthey were0444. The migrations Job was not run end to end (no PostgreSQL in that cluster); its init container is covered by specs.
- On kind, with the Debian
- 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
- As soon as you begin reviewing, select Start a review on your first comment so the MR shows Reviewer started review.
- MR has a green pipeline on https://gitlab.com/gitlab-org/charts/gitlab.
- Consider downstream impact to the Operator, as per evaluating impact from changes to GitLab chart.