Skip to content

Helm chart: configure app via values and FOCA overlays #67

Closed

Description

@uniqueg

Why?

The Helm chart (deployment/) fills the app's config in a way that is fragile, partly broken and over-privileged:

  • templates/cloud-registry-configmap-job.yaml creates a placeholder ConfigMap app-config and a Job that runs update-config-map.sh. The script rewrites the config baked into the image with yq, patches the ConfigMap through the Kubernetes API, and then deletes the app pods to restart them.
  • Bug: the script sets .endpoints.service.* instead of .custom.endpoints.service.*. FOCA silently accepts the unknown top-level key, so host_name is never applied: the service-info URL stays https://0.0.0.0:8080/. Only .db.host is applied.
  • Security: the Job's ServiceAccount is bound to the admin ClusterRole in the namespace (read and write access to everything there, including Secrets), only to patch one ConfigMap.
  • Lifecycle: app pods can start before the Job has filled the ConfigMap (crash loop until the Job deletes them). helm upgrade resets the ConfigMap to the placeholder, and the completed Job (immutable spec) does not run again cleanly.
  • The ConfigMap is mounted with subPath over /app/cloud_registry/config.yaml, so it shadows the whole file and never updates.
  • Only host_name can be set through values. Everything else (auth audience, service-info organization and environment, log level, access-control group mapping) needs a new image.
  • The Dockerfile installs curl, jq and yq (and switches to USER root) only for this script.

How?

Use FOCA's config overlays (FOCA_CONFIG_OVERLAY, FOCA ≥ 0.14, so after the FOCA 0.14 upgrade, #65):

  1. Keep cloud_registry/config.yaml as the complete base config that runs as-is with docker compose up, and mark in comments which keys deployments typically override.
  2. Replace the Job with a plain Helm template, templates/cloud-registry-configmap.yaml, whose data key overlay.yaml is the mergeOverwrite of:
    • an overlay generated from existing values: custom.endpoints.service.url_prefix / external_host / external_port from host_name and the ingress TLS setting;
    • a new free-form config: value (default {}), so admins can override any key and their values win.
  3. In templates/cloud-registry-deploy.yaml, mount the ConfigMap as a directory (e.g. /etc/cloud-registry/), set FOCA_CONFIG_OVERLAY=/etc/cloud-registry/overlay.yaml, and add a checksum/config pod annotation so that helm upgrade rolls the pods when the config changes.
  4. Delete templates/cloud-registry-configmap-job.yaml (ConfigMap placeholder, Job, ServiceAccount, RoleBinding) and update-config-map.sh, and drop the curl/jq/yq installation and the USER root step from the Dockerfile.
  5. values.yaml: add config: {} with commented examples (security.auth.audience, custom.endpoints.service_info fields, log level, security.access_control.group_mapping). Bump the chart version.
  6. Docs:
    • deployment/README.md: keep a per-deployment values file outside this repo (e.g. in the deployment's own infrastructure repo), apply changes with helm upgrade -f values-prod.yaml, and do not kubectl edit the ConfigMap (Helm overwrites it).
    • Main README: fix the deployments/ typo; the host and port of the app are set in config.yaml, not in docker-compose.yaml; add a short "Configuration" section on base config vs overlay.
    • Local development: optional gitignored compose.override.yaml + config.local.yaml with FOCA_CONFIG_OVERLAY, the same mechanism as on Kubernetes.
  7. Tests: helm lint and helm template with a test values file in CI, plus a pytest that loads the base config with a sample overlay and checks that custom.endpoints.service.external_host is taken from the overlay.

A shared FOCA Helm library chart is proposed in elixir-cloud-aai/foca#312. This issue can be done first and moved to the library later.

Acceptance criteria

  • No Job, ServiceAccount or RoleBinding is needed to configure the app; update-config-map.sh and the extra Dockerfile tools are gone.
  • With host_name: registry.example.org, GET /ga4gh/registry/v1/service-info reports https://registry.example.org:443/.
  • Any config key can be overridden through config: in a values file, and helm upgrade with a changed value rolls the pods and the new value takes effect.
  • docker compose up works unchanged with the base config.
  • Chart is linted and rendered in CI; deployment docs updated.

Activity

  1. added
    priority: high
    type: bug
    type: delivery
    type: security
    workload: days
    on Oct 19, 2026
  2. uniqueg commented on Oct 20, 2026

    @uniqueg
    MemberAuthor

    Follow-ups from the Sourcery review of #65 (FOCA 0.14):

    • Set the chart's default image (deployment/values.yaml, currently elixircloud/cloud-registry:20240716) to the first image published with FOCA 0.14 once feat!: upgrade to FOCA 0.14.0 #65 is merged.
    • Let the chart configure the token audience (security.auth.audience, the client IDs of the apps calling the registry) and drop verify_audience: False in deployments, so that LS Login tokens issued to other clients are rejected.
  3. uniqueg commented on Oct 20, 2026

    @uniqueg
    MemberAuthor

    Follow-up from #95: the configmap Job (deployment/templates/cloud-registry-configmap-job.yaml) is a plain batch/v1 Job. Helm resets the app-config ConfigMap to its # Empty placeholder on every helm upgrade (three-way merge against the data patched in by update-config-map.sh), and cannot update the Job when the image changes (immutable pod template). #95 documents a manual procedure (delete the Job, upgrade, wait). Proposal for the Helm config rework: render the config with Helm (values → ConfigMap) instead of patching it from a Job, or at least run the Job as a post-install,post-upgrade hook with before-hook-creation delete policy, and roll the Deployment on config changes (checksum annotation).

  4. uniqueg commented on Oct 20, 2026

    @uniqueg
    MemberAuthor

    Also from the review of #95: update-config-map.sh does not check the result of the ConfigMap PATCH, so the Job succeeds (and deletes the app pods) even if the config was not written. The rework should fail the Job on errors (e.g. curl --fail, set -euo pipefail) or, better, render the config with Helm.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: hightype: bugtype: deliverytype: securityworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions