Mirroring k8s repos with apt mirror and puppet

The way k8s repos are organized makes it hard for me to mirror them in my setup in a cleanly fashion.

I use puppet to control apt-mirror. the mirror server, let’s call it “mirror.company.corp”, has a puppet generated mirror.list containing Canonical mirrors and others, which is usually a short paragraph with the repos URL, branch and components.

Now k8s breaks with the traditional ways and has the version number in the URL, which means:

  • I have to be on the lookout when a new version dawns (hard to automate)

-I have to add sections for every new version (hard to automate, too, or at least involves shenanigans)

My train of thought right now is: loop 30..99 and curl check if anything is behind
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.xy/deb/Release.key
and generate a new section if the list grew, but it’s tedious.

Is there any way to limit this to a one shot, i.e. apt-mirror <base url which contains all the versions of the 1.xy branch> ?