Working Offline

This guide covers how to work with KIND in an offline / airgapped environment.

You you should first install kind before continuing.

Using a pre-built node image

KIND provides some pre-built images, these images contain everything necessary to create a cluster and can be used in an offline environment.

You can find available image tags on the releases page. Please include the @sha256: image digest from the image in the release notes.

You can pull it when you have network access, or pull it on another machine and then transfer it to the target machine.

  1. ~ docker pull kindest/node:v1.17.0@sha256:9512edae126da271b66b990b6fff768fbb7cd786c7d39e86bdf55906352fdf62
  2. sha256:9512edae126da271b66b990b6fff768fbb7cd786c7d39e86bdf55906352fdf62: Pulling from kindest/node
  3. cc5a81c29aab: Pull complete
  4. 81c62728355f: Pull complete
  5. ed9cffdd962a: Pull complete
  6. 6a46f000fce2: Pull complete
  7. 6bd890da28be: Pull complete
  8. 0d88bd219ffe: Pull complete
  9. af5240f230f0: Pull complete
  10. Digest: sha256:9512edae126da271b66b990b6fff768fbb7cd786c7d39e86bdf55906352fdf62
  11. Status: Downloaded newer image for kindest/node@sha256:9512edae126da271b66b990b6fff768fbb7cd786c7d39e86bdf55906352fdf62
  12. docker.io/kindest/node:v1.17.0@sha256:9512edae126da271b66b990b6fff768fbb7cd786c7d39e86bdf55906352fdf62

You can save node image to a tarball.

  1. ~ docker save -o kind.v1.17.0.tar kindest/node:v1.17.0@sha256:9512edae126da271b66b990b6fff768fbb7cd786c7d39e86bdf55906352fdf62
  2. # or
  3. ~ docker save kindest/node:v1.17.0@sha256:9512edae126da271b66b990b6fff768fbb7cd786c7d39e86bdf55906352fdf62 | gzip > kind.v1.17.0.tar.gz

When you transport image tarball to the machine, you can load the node image by docker load command.

  1. ~ docker load -i kind.v1.17.0.tar
  2. Loaded image ID: sha256:ec6ab22d89efc045f4da4fc862f6a13c64c0670fa7656fbecdec5307380f9cb0
  3. # or
  4. ~ docker load -i kind.v1.17.0.tar.gz
  5. Loaded image ID: sha256:ec6ab22d89efc045f4da4fc862f6a13c64c0670fa7656fbecdec5307380f9cb0

And create a tag for it.

  1. ~ docker image tag kindest/node:v1.17.0@sha256:9512edae126da271b66b990b6fff768fbb7cd786c7d39e86bdf55906352fdf62 kindest/node:v1.17.0
  2. ~ docker image ls kindest/node
  3. REPOSITORY TAG IMAGE ID CREATED SIZE
  4. kindest/node v1.17.0 ec6ab22d89ef 3 weeks ago 1.23GB

Finally, you can create a cluster by specifying the --image flag.

  1. ~ kind create cluster --image kindest/node:v1.17.0
  2. Creating cluster "kind" ...
  3. Ensuring node image (kindest/node:v1.17.0) 🖼
  4. Preparing nodes 📦
  5. Writing configuration 📜
  6. Starting control-plane 🕹️
  7. Installing CNI 🔌
  8. Installing StorageClass 💾
  9. Set kubectl context to "kind-kind"
  10. You can now use your cluster with:
  11. kubectl cluster-info --context kind-kind
  12. Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂

Building the node image

In addition to using pre-built node image, KIND also provides the ability to build node image from Kubernetes source code.

Please note that during the image building process, you need to download many dependencies. It is recommended that you build at least once online to ensure that these dependencies are downloaded to your local. See building the node image for more detail.

The node-image in turn is built off the base image.

Prepare Kubernetes source code

You can clone Kubernetes source code.

  1. ~ mkdir -p $GOPATH/src/k8s.io
  2. ~ cd $GOPATH/src/k8s.io
  3. ~ git clone https://github.com/kubernetes/kubernetes

Building image

  1. ~ kind build node-image --image kindest/node:main --kube-root $GOPATH/src/k8s.io/kubernetes
  2. Starting to build Kubernetes
  3. ...
  4. Image build completed.

When the image build is complete, you can create a cluster by passing the --image flag.

  1. ~ kind create cluster --image kindest/node:main
  2. Creating cluster "kind" ...
  3. Ensuring node image (kindest/node:main) 🖼
  4. Preparing nodes 📦
  5. Writing configuration 📜
  6. Starting control-plane 🕹️
  7. Installing CNI 🔌
  8. Installing StorageClass 💾
  9. Set kubectl context to "kind-kind"
  10. You can now use your cluster with:
  11. kubectl cluster-info --context kind-kind
  12. Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂

HA cluster

If you want to create a control-plane HA cluster then you need to create a config file and use this file to start the cluster.

  1. ~ cat << EOF | kind create cluster --config=-
  2. kind: Cluster
  3. apiVersion: kind.x-k8s.io/v1alpha4
  4. # 3 control plane node and 1 workers
  5. nodes:
  6. - role: control-plane
  7. - role: control-plane
  8. - role: control-plane
  9. - role: worker
  10. EOF

Note that in an offline environment, in addition to preparing the node image, you also need to prepare HAProxy image in advance.

You can find the specific tag currently in use at loadbalancer source code.