Gitlab-runner in a kubernetes cluster doesn't use image cache

I’m wanting to cache base images, like, ruby, node, postgres, etc – these images don’t change much, and it kind of seems like a shame to have to download them all the time.

My setup:

  • gitlab.com repo
  • GKE Kubernetes Cluster
  • Auto DevOps (Slightly Modified)
  • Custom App Helm Chart
  • Custom gitlab-runner helm chart (but based off the official one)

I’m not wanting to use a container registry (as other guides/threads have suggested for the app image (though I will end up using one – this thread is about base images))

my gitlab-runner chart: https://gitlab.com/precognition-llc/aeonvera/tree/feature/k8s/scripts/k8s/gitlab-runner
my app chart: https://gitlab.com/precognition-llc/aeonvera/tree/feature/k8s/scripts/k8s/app-chart
my .gitlab-ci.yml: https://gitlab.com/precognition-llc/aeonvera/blob/feature/k8s/.gitlab-ci.yml

I’ve tried mapping the docker.sock file, but it seems like I can only use docker inside a pod if I enable the docker:dind service, which doesn’t use the docker.sock, but uses the tcp socket for the DOCKER_HOST.
I’ve also tried mapping /var/lib/docker entirely, which I know would cause some concurrency issues, but that didn’t work either.

My test is simple.

$ docker pull ruby
Using default tag: latest
latest: Pulling from library/ruby
85b1f47fba49: Already exists 
ba6bd283713a: Pull complete 
817c8cd48a09: Pull complete 
47cc0ed96dc3: Pull complete 
00233accc944: Pull complete 
b4f747320dba: Pull complete 
5b0e9451d648: Pull complete 
Digest: sha256:3514c324317fd63aa5e27c39592a9e1b5d94f014c49c3d58cb536a42ccf17d28
Status: Downloaded newer image for ruby:latest

but the second time, it should be:

$ docker pull ruby
Using default tag: latest
latest: Pulling from library/ruby
Digest: sha256:3514c324317fd63aa5e27c39592a9e1b5d94f014c49c3d58cb536a42ccf17d28
Status: Image is up to date for ruby:latest

I’ve opened an issue on the gitlab-runner here: https://gitlab.com/gitlab-org/gitlab-runner/issues/2888

but there has been no interaction.

any ideas?

3 Likes