Removing the Image Repo Sync Jobs

Problem Description

Most charts have an image repo sync feature. When a deployment sets images.local_registry.active: true:

  • the chart runs a <chart>-image-repo-sync job. The job pulls every image in images.tags that is not in images.local_registry.exclude and pushes it to the registry at the local_image_registry endpoint;

  • the helm-toolkit.snippets.image snippet adds the address of that registry in front of every image;

  • the init container of every pod waits for the job and for the registry.

The feature is outdated

The job mounts the Docker socket of the host, /var/run/docker.sock, and runs the docker command: docker pull, docker tag and docker push. This design comes from the time when Kubernetes nodes ran Docker. Kubernetes removed dockershim in 1.24, and the nodes run containerd now. A containerd node has no Docker daemon and no Docker socket, so the job cannot work there, and it cannot be fixed without a rewrite. The test clusters of OpenStack-Helm run containerd too, so no CI job turns the feature on, and the registry chart that the local_image_registry endpoint points to by default is removed.

The feature is opinionated

The feature supports one way to use a local registry: a job in every chart copies the images that the chart lists to a registry that every node reaches at the same address, localhost:5000 by default, and every pod waits for that job. Deployments mirror images in many other ways: a pull-through cache such as Harbor or the CNCF Distribution registry, a registry mirror in the container runtime (hosts.toml in containerd), skopeo sync or crane copy in a pipeline, or an image bundle for an air-gapped site. The right tool depends on the use case of the deployment, and the choice is outside the scope of the charts. The charts already let a deployment point every image at any registry with images.tags and pass the registry credentials with endpoints.oci_image_registry.

The feature is about 4000 lines in 60 chart templates, the values of 72 charts and six helm-toolkit templates. A new chart copies it from the existing charts.

Use cases

  1. A deployment that cannot pull from public registries manages its own registry mirror with the tools that suit it best, and sets images.tags to the mirror or configures the mirror in the container runtime of the nodes. Both ways work on containerd nodes and also cover the images that the charts do not list.

  2. Chart maintainers do not keep and copy code that no deployment can use.

Proposed Change

Remove the feature from all charts and from helm-toolkit in one change:

  • the job-image-repo-sync.yaml templates and the image-repo-sync.sh key of the -bin ConfigMaps;

  • the values images.tags.image_repo_sync, images.local_registry, dependencies.dynamic.common.local_image_registry, dependencies.static.image_repo_sync, pod.resources.jobs.image_repo_sync, endpoints.local_image_registry and manifests.job_image_repo_sync, from the charts and from values_overrides;

  • the helm-toolkit.manifests.job_image_repo_sync, helm-toolkit.scripts.image_repo_sync and helm-toolkit.utils.image_sync_list templates, and the local_registry code in the image, kubernetes_entrypoint_init_container and kubernetes_pod_rbac_serviceaccount snippets.

A dependencies.dynamic map that becomes empty is removed. Other maps that become empty stay as {}, because the templates still read them.

Backward compatibility

The values are removed without a deprecation period. The rule is to keep a value working for one release series, but this feature needs the Docker socket and the docker command, which containerd nodes do not have. A deprecation would keep code that cannot work.

After the upgrade:

  • a deployment that set images.local_registry.active pulls the images from images.tags. It must set images.tags to its registry before the upgrade. The charts have no values schema, so Helm ignores the old values;

  • the charts that always put image-repo-sync.sh into their -bin ConfigMap get a new configmap-bin-hash, and their pods restart once;

  • a chart outside this repository that calls the removed helm-toolkit templates fails to render until it drops its image repo sync job.

The release note says this in the Changelog: removed trailer.

Security Impact

The charts no longer mount the Docker socket of the host. Access to that socket is root access to the node.

Performance Impact

None. Some pods restart once on the upgrade, as described above.

Alternatives

  1. Rewrite the job for containerd, for example with skopeo or crane, which push over the network. The charts would still need a registry, which OpenStack-Helm no longer deploys, and the feature would still allow only one way to mirror images. The users are free to choose the tools that suit their use case, and those tools work outside the charts.

  2. Deprecate the values for one release series and remove them later. Only a deployment with a Docker daemon on every node can use the feature, CI does not test it, and the code stays in every chart for another series.

Implementation

Assignee(s)

Primary assignee:

kozhukalov (Vladimir Kozhukalov)

Work Items

  1. Remove the feature from the charts, the overrides and helm-toolkit in one change.

  2. Remove the example value from the networking developer reference.

Testing

Render every chart with the default values, and with the overrides that set the removed values, before and after the change, and compare. The only expected differences are the removed image-repo-sync.sh keys, the changed configmap-bin-hash annotations and the egress rule to the docker-registry namespace in the prometheus NetworkPolicy, which helm-toolkit generates from the endpoints. The CI deploy jobs do not use the feature and must pass unchanged.

Documentation Impact

The networking developer reference loses one example value. The release notes of all charts describe the removal.

References