Skip to content

Commit d3954d5

Browse files
committed
init-cluster.sh: Add --docker-io-registry-mirror
Allowing to test the previous changes on a Windows Machine in the cloud, as it was hit by rate limit.
1 parent e8d14ca commit d3954d5

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,28 @@ You can apply the GitOps playground to
150150
* or almost any k8s cluster.
151151
Note that if you want to deploy Jenkins inside the cluster, you either need Docker as container runtime or set Jenkins up to run its build on an agent that provides Docker.
152152

153+
For the local cluster, you can avoid hitting DockerHub's rate limiting by using a mirror via the `--docker-io-registry-mirror` parameter.
154+
155+
For example:
156+
157+
```bash
158+
bash <(curl -s \
159+
https://raw.githubusercontent.com/cloudogu/gitops-playground/main/scripts/init-cluster.sh) --docker-io-registry-mirror https://mirror.gcr.io
160+
```
161+
162+
This parameter is passed on the containerd used by k3d.
163+
164+
In addition, the Jobs run by Jenkins are using the host's Docker daemon.
165+
To avoid rate limits there, you might have to configure a mirror there as well.
166+
This can be done in the `/etc/docker/daemon.json` or in the config of Docker Desktop.
167+
168+
For example:
169+
```json
170+
{
171+
"registry-mirrors": ["https://mirror.gcr.io"]
172+
}
173+
```
174+
153175
### Apply playground
154176

155177
You can apply the playground to your cluster using our container image `ghcr.io/cloudogu/gitops-playground`.

scripts/init-cluster.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ function createCluster() {
7777
# Disable traefik (we roll our own ingress-controller)
7878
'--k3s-arg=--disable=traefik@server:0'
7979
)
80+
81+
REGISTRIES=""
82+
if [[ -n "$DOCKER_IO_REGISTRY_MIRROR" ]]; then
83+
REGISTRIES=$(cat <<EOF
84+
registries:
85+
config: |
86+
mirrors:
87+
docker.io:
88+
endpoint:
89+
- "$DOCKER_IO_REGISTRY_MIRROR"
90+
EOF
91+
)
92+
fi
8093

8194
if [[ ${BIND_LOCALHOST} == 'true' ]]; then
8295
K3D_ARGS+=(
@@ -114,7 +127,7 @@ function createCluster() {
114127
)
115128
fi
116129

117-
if [ -n "$BIND_PORTS" ]; then
130+
if [[ -n "$BIND_PORTS" ]]; then
118131
IFS=","
119132
read -ra portBindings <<< "$BIND_PORTS"
120133
unset IFS
@@ -134,6 +147,7 @@ function createCluster() {
134147
kind: Simple
135148
kubeAPI:
136149
hostIP: "127.0.0.1"
150+
$REGISTRIES
137151
EOF
138152

139153

@@ -173,6 +187,8 @@ function printParameters() {
173187
echo " | --bind-ingress-port=INT >> Bind the ingress controller to this localhost port. Defaults to 80. Set to - to disable."
174188
echo " | --bind-registry-port=INT >> Specify a custom port for the container registry to bind to localhost port. Only use this when port 30000 is blocked and --bind-localhost=true. Defaults to 30000 (default used by the playground)."
175189
echo " | --bind-portBindings=STRING >> A comma separated list of additional port bindings like 443:443,9090:9090. Ignored when --bind-localhost."
190+
191+
echo " | --docker-io-registry-mirror=STRING >> the hostname of a registry that mirrors DockerHub. Useful when encountering rate limits"
176192
echo
177193
echo " -x | --trace >> Debug + Show each command executed (set -x)"
178194
}
@@ -221,6 +237,7 @@ readParameters() {
221237
# Use default port for playground registry, because no parameter is required when applying
222238
BIND_REGISTRY_PORT="30000"
223239
BIND_PORTS=""
240+
DOCKER_IO_REGISTRY_MIRROR=""
224241
TRACE=false
225242

226243
while [ $# -gt 0 ]; do
@@ -237,6 +254,8 @@ readParameters() {
237254
if [[ "$1" == *"="* ]]; then shift; else shift 2; fi ;;
238255
--bind-ports*) BIND_PORTS=$(get_longopt_value "--bind-ports" "$@");
239256
if [[ "$1" == *"="* ]]; then shift; else shift 2; fi ;;
257+
--docker-io-registry-mirror*) DOCKER_IO_REGISTRY_MIRROR=$(get_longopt_value "--docker-io-registry-mirror" "$@");
258+
if [[ "$1" == *"="* ]]; then shift; else shift 2; fi ;;
240259
--) shift; break ;;
241260
*) break ;;
242261
esac

0 commit comments

Comments
 (0)