cached docker volume in gha-runner-scale-set #2944
Replies: 13 comments 11 replies
-
Hello! Thank you for filing an issue. The maintainers will triage your issue shortly. In the meantime, please take a look at the troubleshooting guide for bug reports. If this is a feature request, please review our contribution guidelines. |
Beta Was this translation helpful? Give feedback.
-
It sounds like the recommended approach would be to unset I'll likely need to do so to remove the verbose piece from the init container ( FROM docker:dind
COPY --from=ghcr.io/actions/actions-runner:latest /home/runner/externals/. /home/runner/tmpDir/ |
Beta Was this translation helpful? Give feedback.
-
100%
@JohnYoungers we want to reduce the number of container images we publish |
Beta Was this translation helpful? Give feedback.
-
We are also in need for the exact same feature.
I dont quite understand what you meant by unsetting that mode. there are only two modes for the gha-runner-scale-set. dind and kubernetes. care to explain a bit further on how that could help with cached images? From my experience with the old dynamic PVs and runnerset to control cache of docker images, we really didn't have a good experience with this feature. You can also see many issues on the subject that people aren't very happy with it. |
Beta Was this translation helpful? Give feedback.
-
If either mode is active, the helm chart will include settings on your behalf: by unsetting, you would manually specify what the containers look like. @Link- would it be possible to shed some insight on what's relying on those files from the initContainer? I've updated my helm chart values with the following, using the vanilla dind image: it seems to be working for my use cases, as well as using cached images from the Here's the typescript code which generates the yaml for the helm chart: const runnerContainer = {
name: "runner",
image: `my-custom-image:latest`,
env: [] as any[],
volumeMounts: [] as any[],
resources: {
requests: {
cpu: runner.cpu,
memory: runner.memory,
},
},
};
const containers: any[] = [runnerContainer];
const volumes: any[] = [];
if (runner.enableDocker) {
runnerContainer.env.push({ name: "RUNNER_WAIT_FOR_DOCKER_IN_SECONDS", value: "60" });
runnerContainer.env.push({ name: "DOCKER_HOST", value: "unix:///run/docker/docker.sock" });
runnerContainer.volumeMounts.push({ name: "dind-sock", mountPath: "/run/docker", readOnly: true });
containers.push({
name: "dind",
image: "docker:dind",
args: ["dockerd", "--host=unix:///run/docker/docker.sock", "--group=$(DOCKER_GROUP_GID)"],
securityContext: { privileged: true },
env: [{ name: "DOCKER_GROUP_GID", value: "123" }],
volumeMounts: [
{ name: "dind-sock", mountPath: "/run/docker" },
{ name: "var-lib-docker", mountPath: "/var/lib/docker" },
],
});
volumes.push({ name: "dind-sock", emptyDir: {} });
volumes.push({
name: "var-lib-docker",
ephemeral: {
volumeClaimTemplate: {
spec: {
accessModes: ["ReadWriteOnce"],
resources: { requests: { storage: "20Gi" } },
storageClassName: "gp3",
dataSource: {
name: `docker-snapshot-12345`,
kind: "VolumeSnapshot",
apiGroup: "snapshot.storage.k8s.io",
},
},
},
},
});
} |
Beta Was this translation helpful? Give feedback.
-
@JohnYoungers these contain the node runtime and other dependencies needed for the functioning of the runner. You'll need them in both containers. |
Beta Was this translation helpful? Give feedback.
-
I'm converting this to a discussion |
Beta Was this translation helpful? Give feedback.
-
any news regarding this issue? we are looking to transition to the new runners and we currently have no solution for caching docker images. specifically the service containers. |
Beta Was this translation helpful? Give feedback.
-
After a few testing i found out the the ephemeral volumes are not what I needed. I need persistent docker image caching without creating a snapshot. I need the volumes to not be removed once the pods are done. How can i achieve that using runner-scale-set? |
Beta Was this translation helpful? Give feedback.
-
This use-case is important for tools that utilize a semi-persistent local cache. For the docker use-case, a cache of commonly used base images builds up on runners. This significantly helps improve build times; there is no need to repeatedly pull multi-GiB images from the centralized repository. |
Beta Was this translation helpful? Give feedback.
-
I have now invested several hours and tried different ways... unfortunately it has not worked so far. Could you please provide an example of how to do this? |
Beta Was this translation helpful? Give feedback.
-
@mrclrchtr I can give a high level overview of what I spiked out and got working the other day, largely based on what I learned from @JohnYoungers in the comments above. It's not integrated into this project at all, and is quite a bit of custom work. When we go to make this more production ready for ourselves, we'll be writing a bit of glue code and schedule based scripts to seed the snapshots on a cadence that gives us the best performance improvement. PrequisitesThe prerequisites you'll need are a storage driver in the k8s cluster that can provision persistent storage, as well as the kubernetes external snapshotter set up to be able to create Summary
AssetsExample
|
Beta Was this translation helpful? Give feedback.
-
Is this still the best solution? Or are there any new developments? I think the pre-seed approach is just a workaround unless you have identified all images that you need beforehand and keep updating the pre-seed volume (which in a busy build environment might even be problematic). |
Beta Was this translation helpful? Give feedback.
-
What would you like added?
In the existing implementation of
actions-runner-controller
, you could optionally come up with a way to cache docker images by customizing the/var/lib/docker
path as described here: https://github.com/actions/actions-runner-controller/blob/master/docs/using-custom-volumes.mdIs there a recommended approach for doing something similar in
gha-runner-scale-set
?Why is this needed?
For workflows that use containers (e.g.
services
), run time can be greatly improved/made more consistent if images already exist locallyAdditional context
In the helm chart, you can override the container configuration of the runner by including values in an
template.spec.containers[]
object wherename: "runner"
. If this docker image caching were an option, I think there would need to be similar logic applied to thedind
container as well: https://github.com/actions/actions-runner-controller/blob/master/charts/gha-runner-scale-set/templates/_helpers.tpl#L98Beta Was this translation helpful? Give feedback.
All reactions