Skip to content

Commit

Permalink
Working version of pull through registries
Browse files Browse the repository at this point in the history
  • Loading branch information
pvannierop committed Jul 21, 2024
1 parent 8905e6e commit ce48867
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 14 deletions.
54 changes: 54 additions & 0 deletions .github/ci_config/docker-compose-registries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: '3'
services:
registry-docker: &registry-base
image: registry:2
extra_hosts:
- host.docker.internal:host-gateway
volumes:
- ${IMAGE_DIR:?You must set IMAGE_DIR environmental variable!}:/var/lib/registry
restart: always
ports:
- "5000:5000"
environment:
REGISTRY_PROXY_REMOTEURL: https://registry-1.docker.io
registry-quay:
<<: *registry-base
ports:
- "5001:5000"
environment:
REGISTRY_PROXY_REMOTEURL: https://quay.io
registry-ghcr:
<<: *registry-base
ports:
- "5002:5000"
environment:
REGISTRY_PROXY_REMOTEURL: https://ghcr.io
registry-gcr:
<<: *registry-base
ports:
- "5003:5000"
environment:
REGISTRY_PROXY_REMOTEURL: https://gcr.io
registry-aws:
<<: *registry-base
ports:
- "5004:5000"
environment:
REGISTRY_PROXY_REMOTEURL: https://public.ecr.aws
registry-mcr:
<<: *registry-base
ports:
- "5005:5000"
environment:
REGISTRY_PROXY_REMOTEURL: https://mcr.microsoft.com
registry-gitlab:
<<: *registry-base
ports:
- "5006:5000"
environment:
REGISTRY_PROXY_REMOTEURL: https://registry.gitlab.com


#https://distribution.github.io/distribution/recipes/mirror/
#https://distribution.github.io/distribution/recipes/mirror/#configure-the-cache
#https://distribution.github.io/distribution/about/deploying/#customize-the-storage-location
50 changes: 50 additions & 0 deletions .github/ci_config/k3d-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# See: https://k3d.io/v5.4.6/usage/registries/#creating-a-registry-proxy-pull-through-registry
apiVersion: k3d.io/v1alpha5
kind: Simple
metadata:
name: k3d-config
# proxies for pull-through cache
registries:
config: |
mirrors:
"docker.io":
endpoint:
- http://host.docker.internal:5000
"quay.io":
endpoint:
- http://host.docker.internal:5001
"ghcr.io":
endpoint:
- http://host.docker.internal:5002
"gcr.io":
endpoint:
- http://host.docker.internal:5003
"public.ecr.aws":
endpoint:
- http://host.docker.internal:5004
"mcr.microsoft.com":
endpoint:
- http://host.docker.internal:5005
"registry.gitlab.com":
endpoint:
- http://host.docker.internal:5006
options:
k3s:
extraArgs:
- arg: --disable=cloud-controller
nodeFilters:
- server:*
- arg: --disable=helm-controller
nodeFilters:
- server:*
- arg: --disable=traefik
nodeFilters:
- server:*
- arg: --disable=servicelb
nodeFilters:
- server:*
ports:
# same as `--port '80:80@loadbalancer'`
- port: 80:80
nodeFilters:
- loadbalancer
12 changes: 0 additions & 12 deletions .github/ci_config/k3d-local-image-repo.yaml

This file was deleted.

12 changes: 10 additions & 2 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ jobs:
run: |
helmfile template
test-k8s-versions:
start-k3d-pullthrough-registries:
runs-on: self-hosted
needs: test-helmfile-template
steps:
- run: |
IMAGE_DIR=$HOME/.local/share/k3d-pull-through-registry docker-compose -f .github/ci_config/docker-compose-registries.yaml up -d
test-k8s-versions:
needs: start-k3d-pullthrough-registries
runs-on: self-hosted
strategy:
matrix:
Expand All @@ -68,10 +75,11 @@ jobs:
- uses: nolar/setup-k3d-k3s@v1
with:
version: ${{ matrix.K3S_VERSION }}
k3d-args: --k3s-arg --disable=traefik@server:0 --k3s-arg --disable-helm-controller@server:0 --config .github/ci_config/k3d-local-image-repo.yaml
k3d-args: --config .github/ci_config/k3d-config.yaml
# Note: k3d adds a 'k3d-' prefix to this name
k3d-name: ${{ matrix.KUBECTL_VERSION }}

# TODO would be better to do this with a command line parameter. I have been unable to get this to work.
- name: Set kubeContext
run: |
sed -i "s/kubeContext: .*/kubeContext: k3d-${{ matrix.KUBECTL_VERSION }}/" etc/production.yaml
Expand Down

0 comments on commit ce48867

Please sign in to comment.