Deploy into an air-gapped cluster

Rehearse the hardest kind of FDE deployment on your own laptop. You will build a genuinely offline environment, a Docker network with no route to the internet containing an internal registry, a k3s cluster installed from its official air-gap images, and an operator jump box. On the connected side you will turn an application release into a verified offline bundle; on the inside you will verify it, mirror it into the registry, install it with Helm, prove that nothing reaches the internet, and then deliver and apply an upgrade the same way. Every command in this project was run end to end on a laptop before publishing.

Advanced about 8 hours 6 phases · 26 steps 0 / 26 done
What you will have at the end

A repository with connected/ (bundle build scripts and an image list derived from the chart), inside/ (verify, mirror and install scripts), cluster/ (k3s and registry configuration), RUNBOOK.md and a recorded session showing: no internet inside, checksum verification, install of v6.14.0, an unbundled image failing to pull, and an offline upgrade to v6.15.0 with Helm history.

Before you start
  • Docker (Docker Desktop or Docker Engine) with about 4 GB of free memory
  • Helm installed on your connected machine
  • The packaging and air-gapped lessons of this track
Tools you will install
  • k3s — a Kubernetes distribution with a documented air-gap install ↗
  • Docker internal networks — a network with no route out, so the air gap is real ↗
  • skopeo — copy images to and from OCI archives and registries without a Docker daemon ↗
  • Helm — pull charts on the connected side and install them inside ↗
  • podinfo — a small, realistic application published as an OCI chart and image ↗
Repository layout at the end
airgap-lab/
├── connected/
│   ├── images.txt          # derived from the rendered chart
│   └── build-bundle.sh
├── inside/
│   ├── verify-and-mirror.sh
│   └── install.sh
├── cluster/
│   ├── registries.yaml     # k3s: public names -> internal registry
│   └── start-k3s.sh
├── k3s-images/             # k3s air-gap images archive (downloaded once)
├── bundle-6.14.0/ bundle-6.15.0/
└── RUNBOOK.md

Tick each step as you finish it — your progress is saved in this browser only (back up or restore on the hub). Every code block has a copy button. If something goes wrong, the troubleshooting section at the end covers the usual suspects.

Phase 1

Build the isolated environment

A Docker network with no internet route, an internal registry inside it, and proof that the inside cannot reach out.

  1. Create the lab folder and an internal Docker network. --internal networks have no gateway to the outside world.
    bash
    mkdir -p airgap-lab/{connected,inside,cluster,k3s-images} && cd airgap-lab
    docker network create --internal airgap-net
  2. Pre-pull the images the inside will need while you still can: the registry, k3s, a Helm client and skopeo. In a real engagement these too arrive as part of an approved bundle.
    bash
    docker pull registry:2
    docker pull rancher/k3s:v1.37.1-k3s1
    docker pull alpine/helm:3.19.0
    docker pull quay.io/skopeo/stable:latest
  3. Start the internal registry on the isolated network.
    bash
    docker run -d --name registry --network airgap-net registry:2
  4. Prove the network is isolated by trying to reach the internet from a container on it.
    bash
    docker run --rm --network airgap-net alpine sh -c \
      'wget -q -T 5 -O /dev/null https://ghcr.io && echo INTERNET || echo no-internet'
    Check: The output is no-internet.
Phase 2

Install k3s from its air-gap images

A Kubernetes cluster running inside the isolated network, installed with the official offline images and configured to pull only from the internal registry.

  1. On the connected side, download the k3s air-gap images archive for your CPU architecture (uname -m prints arm64 or x86_64) and the matching release.
    bash
    ARCH=$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')
    curl -L -o "k3s-images/k3s-airgap-images-${ARCH}.tar.zst" \
      "https://github.com/k3s-io/k3s/releases/download/v1.37.1%2Bk3s1/k3s-airgap-images-${ARCH}.tar.zst"
    k3s loads any image archive placed in /var/lib/rancher/k3s/agent/images/ at start, which is exactly the documented air-gap method.
  2. Write the registry mirror configuration so that images referenced as ghcr.io or docker.io are served from the internal registry, with no manifest edits.
    yaml
    # cluster/registries.yaml
    mirrors:
      ghcr.io:
        endpoint:
          - "http://registry:5000"
      docker.io:
        endpoint:
          - "http://registry:5000"
    A real internal registry uses TLS with the customer's CA; plain HTTP is acceptable only inside this lab.
  3. Start k3s inside the isolated network. k3s requires a default route even when there is no internet; its air-gap docs recommend a black-hole route through a dummy interface, which the entry command creates.
    bash
    docker run -d --name k3s --hostname k3s --network airgap-net --privileged \
      -v "$PWD/k3s-images:/var/lib/rancher/k3s/agent/images" \
      -v "$PWD/cluster/registries.yaml:/etc/rancher/k3s/registries.yaml:ro" \
      --entrypoint /bin/sh rancher/k3s:v1.37.1-k3s1 -c \
      'ip link add dummy0 type dummy && ip link set dummy0 up &&
       ip addr add 203.0.113.254/31 dev dummy0 &&
       ip route add default via 203.0.113.255 dev dummy0 metric 1000 &&
       exec /bin/k3s server --tls-san k3s --disable traefik --disable metrics-server'
    Without the dummy route k3s exits with 'no default routes found'; that error is common on real air-gapped hosts too.
  4. Wait for the node to become Ready and confirm the cluster itself cannot reach the internet.
    bash
    until docker exec k3s kubectl get nodes 2>/dev/null | grep -q ' Ready'; do sleep 5; done
    docker exec k3s kubectl get nodes
    docker exec k3s sh -c 'wget -q -T 5 -O /dev/null https://ghcr.io && echo INTERNET || echo no-internet'
    Check: The node is Ready and the cluster reports no-internet.
  5. Create a kubeconfig for the jump box: the cluster's admin config with the server address changed to the container hostname, which is in the certificate thanks to --tls-san k3s.
    bash
    docker exec k3s cat /etc/rancher/k3s/k3s.yaml | sed 's#https://127.0.0.1:6443#https://k3s:6443#' > kubeconfig
    chmod 600 kubeconfig
Phase 3

Build the offline bundle (connected side)

Two versioned bundles, each containing every image and chart for one release, with checksums.

  1. Pull the application chart for the version you will install first and derive the image list from the rendered manifests rather than writing it by hand.
    bash
    mkdir -p bundle-6.14.0/images bundle-6.14.0/charts
    helm pull oci://ghcr.io/stefanprodan/charts/podinfo --version 6.14.0 -d bundle-6.14.0/charts
    helm template podinfo bundle-6.14.0/charts/podinfo-6.14.0.tgz |
      grep -E '^\s+image:' | awk '{print $2}' | tr -d '"' | sort -u > connected/images-6.14.0.txt
    cat connected/images-6.14.0.txt
    Check: The list contains ghcr.io/stefanprodan/podinfo:6.14.0 and also the helper images the chart's test hooks use (curl, grpc_health_probe, tiny-tools): exactly the kind of image people forget when they write the list by hand.
  2. Write the bundle script: copy the image list into the bundle, export every listed image into an OCI archive with skopeo, then write checksums for everything except the checksum file itself.
    bash
    cat > connected/build-bundle.sh <<'SCRIPT'
    #!/usr/bin/env bash
    set -euo pipefail
    VER="$1"
    B="bundle-$VER"
    cp "connected/images-$VER.txt" "$B/images.txt"      # the list travels with the bundle
    while read -r img; do
      name=$(echo "$img" | tr '/:@' '___')
      docker run --rm -v "$PWD/$B:/b" quay.io/skopeo/stable:latest copy --all \
        "docker://$img" "oci-archive:/b/images/$name.tar:$img"
    done < "$B/images.txt"
    (cd "$B" && find . -type f ! -name SHA256SUMS -exec shasum -a 256 {} \; > SHA256SUMS)
    SCRIPT
    chmod +x connected/build-bundle.sh
    ./connected/build-bundle.sh 6.14.0
    find ... ! -name SHA256SUMS matters: without it the checksum file lists itself and verification always fails, a mistake this lab caught while it was being written.
  3. Repeat for the next release, 6.15.0, which you will deliver later as an upgrade.
    bash
    mkdir -p bundle-6.15.0/images bundle-6.15.0/charts
    helm pull oci://ghcr.io/stefanprodan/charts/podinfo --version 6.15.0 -d bundle-6.15.0/charts
    helm template podinfo bundle-6.15.0/charts/podinfo-6.15.0.tgz |
      grep -E '^\s+image:' | awk '{print $2}' | tr -d '"' | sort -u > connected/images-6.15.0.txt
    ./connected/build-bundle.sh 6.15.0
  4. Record what each bundle contains (versions, image digests, checksum file) in a short release note, as you would hand to a customer's change board.
Phase 4

Verify, mirror and install (inside)

The first release installed in the isolated cluster from the internal registry only.

  1. Verify the bundle's checksums before anything is loaded.
    bash
    (cd bundle-6.14.0 && shasum -a 256 -c SHA256SUMS)
    Check: Every line says OK.
  2. Push every image archive into the internal registry, keeping the repository path so the mirror configuration resolves the original names. skopeo runs on the isolated network, as an operator's tool inside the gap would.
    bash
    cat > inside/verify-and-mirror.sh <<'SCRIPT'
    #!/usr/bin/env bash
    set -euo pipefail
    B="bundle-$1"
    (cd "$B" && shasum -a 256 -c SHA256SUMS)
    while read -r img; do
      name=$(echo "$img" | tr '/:@' '___')
      first="${img%%/*}"
      if [[ "$img" == */* && ( "$first" == *.* || "$first" == *:* ) ]]; then
        path="${img#*/}"                                  # drop the registry host
      else
        path="$img"                                       # docker.io short name
        [[ "$path" == */* ]] || path="library/$path"
      fi
      [[ "${path##*/}" == *:* || "$path" == *@* ]] || path="$path:latest"
      docker run --rm --network airgap-net -v "$PWD/$B:/b" quay.io/skopeo/stable:latest \
        copy --all --dest-tls-verify=false "oci-archive:/b/images/$name.tar" "docker://registry:5000/$path"
    done < "$B/images.txt"
    SCRIPT
    chmod +x inside/verify-and-mirror.sh
    ./inside/verify-and-mirror.sh 6.14.0
    The script reads the image list carried in the bundle and maps each reference to a path in the internal registry: it drops the registry host (ghcr.io, docker.io), adds library/ for official Docker Hub images and :latest when no tag is given. Rebuilding names from archive file names instead breaks on images with underscores in their names, which is exactly what happened while this lab was being tested.
  3. List what the internal registry now holds, so you can compare it with the bundle's image list.
    bash
    docker run --rm --network airgap-net alpine \
      wget -qO- http://registry:5000/v2/_catalog
    Check: The catalog includes stefanprodan/podinfo and the helper images.
  4. Install the chart from the bundle using Helm in a jump-box container on the isolated network.
    bash
    helm_in() {
      docker run --rm --network airgap-net -v "$PWD:/w" -e KUBECONFIG=/w/kubeconfig \
        alpine/helm:3.19.0 "$@"
    }
    helm_in upgrade --install podinfo /w/bundle-6.14.0/charts/podinfo-6.14.0.tgz \
      -n demo --create-namespace --atomic --timeout 3m
    Check: Helm reports STATUS: deployed.
  5. Confirm the pod is running and that its image, still referenced by its public name, was pulled through the internal mirror.
    bash
    docker exec k3s kubectl -n demo get pods
    docker exec k3s kubectl -n demo get events --field-selector reason=Pulled \
      -o custom-columns=MSG:.message --no-headers
    Check: The event says Successfully pulled image "ghcr.io/stefanprodan/podinfo:6.14.0", even though the cluster has no internet.
  6. Run the chart's own tests inside the gap. They use the helper images you bundled, which is why those had to be in the image list.
    bash
    docker exec k3s kubectl -n demo rollout status deploy/podinfo --timeout=120s
    helm_in test podinfo -n demo --timeout 3m
    Check: The grpc, jwt and service tests all report Phase: Succeeded.
  7. Prove the gap works: try to run an image that was never bundled and watch it fail.
    bash
    docker exec k3s kubectl -n demo run probe --image=nginx:1.27 --restart=Never
    sleep 20
    docker exec k3s kubectl -n demo get pod probe
    docker exec k3s kubectl -n demo delete pod probe --now
    Check: The probe pod shows ErrImagePull or ImagePullBackOff.
Phase 5

Deliver an upgrade offline

The next release applied through the same verified path, with rollback available.

  1. Verify and mirror the 6.15.0 bundle exactly as before.
    bash
    ./inside/verify-and-mirror.sh 6.15.0
  2. Upgrade atomically and check history.
    bash
    helm_in upgrade podinfo /w/bundle-6.15.0/charts/podinfo-6.15.0.tgz -n demo --atomic --timeout 3m
    docker exec k3s kubectl -n demo get deploy podinfo \
      -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'
    helm_in history podinfo -n demo
    Check: The image is now 6.15.0 and history shows revision 1 superseded, revision 2 deployed.
  3. Practise the rollback an operator would use if the new version misbehaved.
    bash
    helm_in rollback podinfo 1 -n demo
    docker exec k3s kubectl -n demo get deploy podinfo \
      -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'
    Check: The image is back to 6.14.0, still with no internet access.
Phase 6

Runbook, record and tear down

Operator documentation for offline delivery and a clean environment afterwards.

  1. Write RUNBOOK.md: prerequisites, how to verify a bundle, how to mirror, how to install and upgrade, how to roll back, and failure entries for checksum mismatch, ImagePullBackOff (image missing from bundle or mirror), and k3s failing to start with 'no default routes found'.
  2. Record a terminal session demonstrating the whole flow and commit scripts, configuration and the runbook (not the large image archives).
    bash
    printf 'bundle-*/images/\nk3s-images/\nkubeconfig\n' > .gitignore
    git init && git add -A && git commit -m "Air-gapped delivery lab: k3s + internal registry + verified bundles"
  3. Tear everything down.
    bash
    docker rm -f k3s registry
    docker network rm airgap-net
    Check: docker ps -a shows neither container and the network is gone.
Help

Troubleshooting

k3s exits immediately with 'no default routes found'
Air-gapped hosts need a default route; add the dummy-interface black-hole route as in the start command (this is the method k3s's air-gap docs describe).
Pods stay in ImagePullBackOff for an image you bundled
Check the image was pushed under the same repository path (stefanprodan/podinfo:6.14.0) and that registries.yaml mirrors the image's registry host. List the registry with docker run --rm --network airgap-net alpine wget -qO- http://registry:5000/v2/_catalog.
shasum -c reports SHA256SUMS: FAILED
The checksum file was included in itself; regenerate with find . -type f ! -name SHA256SUMS ....
Helm cannot connect to the cluster
Make sure the kubeconfig server is https://k3s:6443, the Helm container runs on airgap-net, and k3s was started with --tls-san k3s.
The cluster pulled an image you did not bundle
Your network is not isolated. Confirm the network was created with --internal and that k3s is attached only to it (docker inspect k3s).
Next

Where to go from here

Did a step fail or feel unclear? Tell me which one →