fix: preload native k3s pause image
This commit is contained in:
+28
-9
@@ -784,6 +784,19 @@ function ensureNativeK3sScript(): string {
|
||||
...rootAccessPrelude(),
|
||||
`native_k3s_image=${shellQuote(nativeK3sImage)}`,
|
||||
`native_ctr_address=${shellQuote(nativeK3sCtrAddress)}`,
|
||||
`build_proxy=${shellQuote(providerGatewayWsEgressProxyUrl)}`,
|
||||
"configure_provider_deploy_proxy() {",
|
||||
" export DOCKER_CONFIG=/tmp/unidesk-docker-config-clean",
|
||||
" mkdir -p \"$DOCKER_CONFIG\"",
|
||||
" [ -f \"$DOCKER_CONFIG/config.json\" ] || printf '{}' > \"$DOCKER_CONFIG/config.json\"",
|
||||
" export HTTP_PROXY=\"$build_proxy\" HTTPS_PROXY=\"$build_proxy\" ALL_PROXY=\"$build_proxy\"",
|
||||
" export NO_PROXY=\"localhost,127.0.0.1,::1,host.docker.internal\"",
|
||||
" if ! curl -fsSI --max-time 20 -x \"$build_proxy\" https://github.com >/dev/null; then",
|
||||
" echo native_k3s_provider_egress_proxy_unavailable=$build_proxy >&2",
|
||||
" exit 1",
|
||||
" fi",
|
||||
" echo native_k3s_provider_egress_proxy=provider-gateway-ws-egress:$build_proxy",
|
||||
"}",
|
||||
"install_native_k3s_binaries() {",
|
||||
" missing=0",
|
||||
" for binary in k3s ctr containerd containerd-shim-runc-v2 crictl runc cni flannel bridge host-local loopback portmap bandwidth firewall; do",
|
||||
@@ -821,18 +834,24 @@ function ensureNativeK3sScript(): string {
|
||||
" fi",
|
||||
"}",
|
||||
"install_pause_image() {",
|
||||
" if root_exec ctr --address \"$native_ctr_address\" -n k8s.io images ls | grep -q 'docker.io/rancher/mirrored-pause:3.6'; then return; fi",
|
||||
" docker image inspect rancher/mirrored-pause:3.6 >/dev/null 2>&1 || {",
|
||||
" docker image inspect \"$native_k3s_image\" >/dev/null 2>&1 || docker pull \"$native_k3s_image\"",
|
||||
" tmp_dir=$(mktemp -d)",
|
||||
" printf '%s\\n' \"FROM $native_k3s_image\" 'ENTRYPOINT [\"/bin/sleep\", \"365d\"]' > \"$tmp_dir/Dockerfile\"",
|
||||
" docker build -q -t rancher/mirrored-pause:3.6 \"$tmp_dir\" >/dev/null",
|
||||
" rm -rf \"$tmp_dir\"",
|
||||
" }",
|
||||
" docker save rancher/mirrored-pause:3.6 -o /tmp/unidesk-k3s-pause.tar",
|
||||
" pause_image=rancher/mirrored-pause:3.6",
|
||||
" pause_entrypoint=$(docker image inspect \"$pause_image\" --format '{{json .Config.Entrypoint}}' 2>/dev/null || true)",
|
||||
" if ! printf '%s' \"$pause_entrypoint\" | grep -q '\"/pause\"'; then",
|
||||
" docker image rm \"$pause_image\" >/dev/null 2>&1 || true",
|
||||
" docker pull --platform linux/amd64 \"$pause_image\"",
|
||||
" pause_entrypoint=$(docker image inspect \"$pause_image\" --format '{{json .Config.Entrypoint}}' 2>/dev/null || true)",
|
||||
" fi",
|
||||
" if ! printf '%s' \"$pause_entrypoint\" | grep -q '\"/pause\"'; then",
|
||||
" echo native_k3s_pause_image_invalid_entrypoint=$pause_entrypoint >&2",
|
||||
" exit 1",
|
||||
" fi",
|
||||
" docker save \"$pause_image\" -o /tmp/unidesk-k3s-pause.tar",
|
||||
" root_exec ctr --address \"$native_ctr_address\" -n k8s.io images rm docker.io/rancher/mirrored-pause:3.6 >/dev/null 2>&1 || true",
|
||||
" root_exec ctr --address \"$native_ctr_address\" -n k8s.io images import /tmp/unidesk-k3s-pause.tar >/dev/null",
|
||||
" root_exec ctr --address \"$native_ctr_address\" -n k8s.io images ls | grep -F 'docker.io/rancher/mirrored-pause:3.6' >/dev/null",
|
||||
" echo native_k3s_imported_pause_image=rancher/mirrored-pause:3.6",
|
||||
"}",
|
||||
"configure_provider_deploy_proxy",
|
||||
"install_native_k3s_binaries",
|
||||
"unmount_invalid_wsl_kubelet_mounts",
|
||||
"if ! systemctl cat k3s.service >/dev/null 2>&1; then",
|
||||
|
||||
Reference in New Issue
Block a user