|
| 1 | +apiVersion: v1 |
| 2 | +kind: ConfigMap |
| 3 | +metadata: |
| 4 | + name: containerd-registry-mirrors |
| 5 | + namespace: ${namespace} |
| 6 | +data: |
| 7 | + docker-io-hosts.toml: | |
| 8 | + [host."http://${harbor_fqdn}/v2/proxy-docker.io"] |
| 9 | + capabilities = ["pull", "resolve"] |
| 10 | + skip_verify = true |
| 11 | + override_path = true |
| 12 | +
|
| 13 | + # Fall back to Docker Hub if Harbor fails |
| 14 | + [host."https://registry-1.docker.io"] |
| 15 | + capabilities = ["pull", "resolve"] |
| 16 | +
|
| 17 | + ghcr-io-hosts.toml: | |
| 18 | + [host."http://${harbor_fqdn}/v2/proxy-ghcr.io"] |
| 19 | + capabilities = ["pull", "resolve"] |
| 20 | + skip_verify = true |
| 21 | + override_path = true |
| 22 | +
|
| 23 | + # Fall back to GHCR if Harbor fails |
| 24 | + [host."https://ghcr.io"] |
| 25 | + capabilities = ["pull", "resolve"] |
| 26 | +
|
| 27 | + quay-io-hosts.toml: | |
| 28 | + [host."http://${harbor_fqdn}/v2/proxy-quay.io"] |
| 29 | + capabilities = ["pull", "resolve"] |
| 30 | + skip_verify = true |
| 31 | + override_path = true |
| 32 | +
|
| 33 | + # Fall back to Quay if Harbor fails |
| 34 | + [host."https://quay.io"] |
| 35 | + capabilities = ["pull", "resolve"] |
| 36 | +--- |
| 37 | +apiVersion: apps/v1 |
| 38 | +kind: DaemonSet |
| 39 | +metadata: |
| 40 | + name: configure-containerd-mirrors |
| 41 | + namespace: ${namespace} |
| 42 | +spec: |
| 43 | + selector: |
| 44 | + matchLabels: |
| 45 | + app: configure-containerd-mirrors |
| 46 | + template: |
| 47 | + metadata: |
| 48 | + labels: |
| 49 | + app: configure-containerd-mirrors |
| 50 | + spec: |
| 51 | + initContainers: |
| 52 | + - name: configure-containerd |
| 53 | + image: busybox |
| 54 | + command: |
| 55 | + - /bin/sh |
| 56 | + - -c |
| 57 | + - | |
| 58 | + set -e |
| 59 | + echo "Configuring containerd registry mirrors..." |
| 60 | + mkdir -p /host/etc/containerd/certs.d/docker.io |
| 61 | + mkdir -p /host/etc/containerd/certs.d/ghcr.io |
| 62 | + mkdir -p /host/etc/containerd/certs.d/quay.io |
| 63 | +
|
| 64 | + echo "Copying Docker, GHCR, and Quay registry mirror configurations..." |
| 65 | + cp /config/docker-io-hosts.toml /host/etc/containerd/certs.d/docker.io/hosts.toml |
| 66 | + cp /config/ghcr-io-hosts.toml /host/etc/containerd/certs.d/ghcr.io/hosts.toml |
| 67 | + cp /config/quay-io-hosts.toml /host/etc/containerd/certs.d/quay.io/hosts.toml |
| 68 | + echo "Containerd registry mirrors configured." |
| 69 | + securityContext: |
| 70 | + runAsUser: 0 |
| 71 | + allowPrivilegeEscalation: false |
| 72 | + capabilities: |
| 73 | + drop: |
| 74 | + - ALL |
| 75 | + add: |
| 76 | + - DAC_OVERRIDE |
| 77 | + volumeMounts: |
| 78 | + - name: host-fs |
| 79 | + mountPath: /host/etc/containerd/certs.d |
| 80 | + - name: config |
| 81 | + mountPath: /config |
| 82 | + readOnly: true |
| 83 | + containers: |
| 84 | + - name: wait |
| 85 | + image: registry.k8s.io/pause:3.8 |
| 86 | + resources: |
| 87 | + requests: |
| 88 | + cpu: 10m |
| 89 | + memory: 10Mi |
| 90 | + limits: |
| 91 | + cpu: 50m |
| 92 | + memory: 50Mi |
| 93 | + securityContext: |
| 94 | + privileged: false |
| 95 | + runAsNonRoot: true |
| 96 | + runAsUser: 65532 |
| 97 | + allowPrivilegeEscalation: false |
| 98 | + capabilities: |
| 99 | + drop: |
| 100 | + - ALL |
| 101 | + volumes: |
| 102 | + - name: host-fs |
| 103 | + hostPath: |
| 104 | + path: /etc/containerd/certs.d |
| 105 | + type: DirectoryOrCreate |
| 106 | + - name: config |
| 107 | + configMap: |
| 108 | + name: containerd-registry-mirrors |
0 commit comments