Skip to content

CI: cache Docker Hub image pulls in-cluster for the k8s Jenkins agents - #4974

Open
michaelsembwever wants to merge 3 commits into
apache:cassandra-5.0from
thelastpickle:mck/21541/5.0
Open

CI: cache Docker Hub image pulls in-cluster for the k8s Jenkins agents#4974
michaelsembwever wants to merge 3 commits into
apache:cassandra-5.0from
thelastpickle:mck/21541/5.0

Conversation

@michaelsembwever

Copy link
Copy Markdown
Member

In a Helm deployed CI, each CI agent runs its own docker-in-docker daemon on an emptyDir, blank to begin with. Every agent therefore pulls the same build and test images afresh; the largest, cassandra-ubuntu-test, is ~35Gi. At hundreds of concurrent agents this is slow, wastes bandwidth, and trips pull-rate limits.

Add an in-cluster Docker Hub pull-through cache (a registry:2 proxy) and point the agents' dind at it via --registry-mirror. Each image is then fetched from Docker Hub once and served to every agent over the cluster LAN; dind falls back to Docker Hub directly if the cache is unreachable.

Docker's --registry-mirror can only mirror Docker Hub, not an arbitrary registry such as apache.jfrog.io. So the prefetch in the Jenkinsfile is repointed from the apache.jfrog.io names to those same Docker Hub names.

Patch changes:

  • .jenkins/k8s/docker-cache.yaml: the pull-through cache (Deployment, Service, PVC), pinned to the always-on controller node.
  • .jenkins/k8s/jenkins-deployment.yaml: dind --registry-mirror in all three agent templates.
  • .build/run-ci: --setup/--only-setup applies the cache; teardown removes it.
  • .jenkins/Jenkinsfile: prefetch the Docker Hub image names.

The cache runs a single replica for now. It converts repeated WAN pulls into one origin fetch plus LAN reads; if the pod's egress becomes the bottleneck this can be scaled with replicas or an object-storage backend.

@michaelsembwever
michaelsembwever changed the base branch from trunk to cassandra-5.0 July 29, 2026 14:19
In a Helm deployed CI, each CI agent runs its own docker-in-docker daemon on an emptyDir, blank to begin with. Every agent therefore pulls the same build and test images afresh; the largest, `cassandra-ubuntu-test`, is ~35Gi. At hundreds of concurrent agents this is slow, wastes bandwidth, and trips pull-rate limits.
Add an in-cluster Docker Hub pull-through cache (a registry:2 proxy) and point the agents' `dind` at it via `--registry-mirror`. Each image is then fetched from Docker Hub once and served to every agent over the cluster LAN; `dind` falls back to Docker Hub directly if the cache is unreachable.
Docker's `--registry-mirror` can only mirror Docker Hub, not an arbitrary registry such as apache.jfrog.io. So the prefetch in the Jenkinsfile is repointed from the apache.jfrog.io names to those same Docker Hub names.

Patch changes:
 - `.jenkins/k8s/docker-cache.yaml`: the pull-through cache (Deployment, Service, PVC), pinned to the always-on controller node.
 - `.jenkins/k8s/jenkins-deployment.yaml`: `dind` `--registry-mirror` in all three agent templates.
 - `.build/run-ci`: `-setup/-only-setup` applies the cache; teardown removes it. It injects the cache PVC's `storageClassName` from the Jenkins values' `persistence.storageClass`, so a site declares its storage class once and the PVC binds on clusters (such as EKS) that mark no  default StorageClass.
 - `.jenkins/Jenkinsfile`: prefetch the Docker Hub image names.

The cache runs a single replica for now. It converts repeated WAN pulls into one origin fetch plus LAN reads; if the pod's egress becomes the bottleneck this can be scaled with replicas or an object-storage backend.

 patch by Mick Semb Wever; reviewed by xxx for CASSANDRA-21541
Comment thread .jenkins/k8s/docker-cache.yaml
Comment thread .build/run-ci Outdated
Comment thread .build/run-ci Outdated
@michaelsembwever
michaelsembwever marked this pull request as ready for review July 29, 2026 20:03
@michaelsembwever

Copy link
Copy Markdown
Member Author

Another commit added:
fix CI checks; and add fallback to using apache.jfrog.io when no registry mirror

  - fetchDockerImages: detect the dind registry mirror via `docker info`;
    fall back to apache.jfrog.io when none is configured (dark launch)
  - run-ci: keep the module under pylint's 1000-line cap by folding
    resolve_storage_class into apply_docker_cache and merging the two
    kubectl-cp download helpers
  - jenkins-test.sh: validate multi-document manifests (docker-cache.yaml)
    with safe_load_all
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