Skip to content

Commit d3340c8

Browse files
committed
feat(cluster): add OPENSHELL_DOCKERIO_MIRROR for docker.io mirror support
Environments where docker.io is blocked (corporate firewalls, air-gapped networks) cannot pull k3s system images like rancher/mirrored-pause, preventing any pods from starting. This adds an OPENSHELL_DOCKERIO_MIRROR environment variable that configures a containerd registry mirror for docker.io in the cluster's registries.yaml. When set, unqualified image pulls are redirected to the configured mirror instead of docker.io. Usage: export OPENSHELL_DOCKERIO_MIRROR="https://mirror.gcr.io" Signed-off-by: Andrew Potozniak <potozniak@redhat.com>
1 parent 5531551 commit d3340c8

4 files changed

Lines changed: 38 additions & 1 deletion

File tree

architecture/gateway.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ All configuration is via CLI flags with environment variable fallbacks. The `--d
128128
| `--sandbox-ssh-port` | `OPENSHELL_SANDBOX_SSH_PORT` | `2222` | SSH listen port inside sandbox pods |
129129
| `--ssh-handshake-secret` | `OPENSHELL_SSH_HANDSHAKE_SECRET` | None | Shared HMAC-SHA256 secret for gateway-to-sandbox handshake |
130130
| `--ssh-handshake-skew-secs` | `OPENSHELL_SSH_HANDSHAKE_SKEW_SECS` | `300` | Allowed clock skew (seconds) for SSH handshake timestamps |
131+
|| `OPENSHELL_DOCKERIO_MIRROR` | None | Mirror endpoint for docker.io (e.g. `https://mirror.gcr.io`). Used when Docker Hub is blocked by corporate firewalls or air-gapped networks. Without this, k3s system images such as `rancher/mirrored-pause` fail to pull and no pods can start. |
131132

132133
## Shared State
133134

crates/openshell-bootstrap/src/docker.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,11 @@ pub async fn ensure_container(
842842
if let Some(endpoint) = registry_endpoint {
843843
env_vars.push(format!("REGISTRY_ENDPOINT={endpoint}"));
844844
}
845+
// Docker Hub mirror for environments where docker.io is blocked
846+
// (corporate firewalls, air-gapped networks, rate limiting, etc.).
847+
if let Some(mirror) = env_non_empty("OPENSHELL_DOCKERIO_MIRROR") {
848+
env_vars.push(format!("OPENSHELL_DOCKERIO_MIRROR={mirror}"));
849+
}
845850
if let Some(password) = effective_password {
846851
// Default to __token__ when only a password/token is provided.
847852
let username = effective_username.unwrap_or_else(|| "__token__".to_string());

deploy/docker/cluster-entrypoint.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,21 @@ REGEOF
282282
REGEOF
283283
fi
284284

285+
# Mirror docker.io to an alternative registry for environments where
286+
# Docker Hub is inaccessible (corporate firewalls, air-gapped networks,
287+
# rate limiting, etc.). Without this, k3s system images such as
288+
# rancher/mirrored-pause fail to pull and no pods can start.
289+
if [ -n "${OPENSHELL_DOCKERIO_MIRROR:-}" ]; then
290+
echo "Adding docker.io mirror: ${OPENSHELL_DOCKERIO_MIRROR}"
291+
cat >>"$REGISTRIES_YAML" <<REGEOF
292+
"docker.io":
293+
endpoint:
294+
- "${OPENSHELL_DOCKERIO_MIRROR}"
295+
REGEOF
296+
else
297+
echo "Info: OPENSHELL_DOCKERIO_MIRROR not set; unqualified image pulls will use docker.io directly"
298+
fi
299+
285300
if [ -n "${REGISTRY_USERNAME:-}" ] && [ -n "${REGISTRY_PASSWORD:-}" ]; then
286301
cat >>"$REGISTRIES_YAML" <<REGEOF
287302
@@ -318,7 +333,22 @@ REGEOF
318333
fi
319334
fi
320335
else
321-
echo "Warning: REGISTRY_HOST not set; skipping registry config"
336+
echo "Warning: REGISTRY_HOST not set; skipping OpenShell component registry mirror config"
337+
fi
338+
339+
# Mirror docker.io independently of REGISTRY_HOST — even without a
340+
# component registry configured, k3s still needs to pull system images
341+
# (e.g. rancher/mirrored-pause) and will fail if docker.io is unreachable.
342+
if [ -n "${OPENSHELL_DOCKERIO_MIRROR:-}" ] && [ ! -f "$REGISTRIES_YAML" ]; then
343+
echo "Configuring docker.io mirror: ${OPENSHELL_DOCKERIO_MIRROR}"
344+
cat >"$REGISTRIES_YAML" <<REGEOF
345+
mirrors:
346+
"docker.io":
347+
endpoint:
348+
- "${OPENSHELL_DOCKERIO_MIRROR}"
349+
REGEOF
350+
elif [ ! -f "$REGISTRIES_YAML" ]; then
351+
echo "Info: OPENSHELL_DOCKERIO_MIRROR not set; unqualified image pulls will use docker.io directly"
322352
fi
323353

324354
# Copy bundled Helm chart tarballs to the k3s static charts directory.

docs/reference/support-matrix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ To override the default image references, set the following environment variable
5454
| ------------------------------ | --------------------------------------------------- |
5555
| `OPENSHELL_CLUSTER_IMAGE` | Override the cluster image reference. |
5656
| `OPENSHELL_COMMUNITY_REGISTRY` | Override the registry for community sandbox images. |
57+
| `OPENSHELL_DOCKERIO_MIRROR` | Mirror endpoint for docker.io (e.g. `https://mirror.gcr.io`). Required when Docker Hub is inaccessible. |
5758

5859
## Kernel Requirements
5960

0 commit comments

Comments
 (0)