2019-02-12 17:52:16 -08:00
---
title: "Quick Start"
menu:
main:
parent: "user"
identifier: "user-quick-start"
weight: 1
---
2019-02-08 11:39:04 -08:00
# Quick Start
This guide covers getting started with the `kind` command.
**If you are having problems please see the [known issues] guide.**
2018-11-13 16:30:09 -06:00
2019-02-08 08:30:55 -08:00
## Installation
2020-02-28 14:21:26 -08:00
**NOTE**: `kind` does not require [`kubectl` ](https://kubernetes.io/docs/reference/kubectl/overview/ ),
but you will not be able to perform some of the examples in our docs without it.
To install `kubectl` see the upstream reference here https://kubernetes.io/docs/tasks/tools/install-kubectl/
2020-02-28 14:15:04 -08:00
2020-05-15 17:47:02 +02:00
You can either install kind with `GO111MODULE="on" go get sigs.k8s.io/kind@v0.8.1` or clone this repo
2019-05-16 16:02:35 -07:00
and run `make build` from the repository.
2019-05-08 18:32:16 -07:00
2020-02-28 14:25:01 -08:00
Please use the latest Go when installing KIND from source, ideally go 1.14 or greater.
2019-05-08 18:32:16 -07:00
This will put `kind` in `$(go env GOPATH)/bin` . You may need to add that directory to your `$PATH` as
2019-02-08 08:30:55 -08:00
shown [here ](https://golang.org/doc/code.html#GOPATH ) if you encounter the error
`kind: command not found` after installation.
2020-02-28 14:18:52 -08:00
Without installing Go, kind can be built reproducibly with docker using `make build` .
2019-05-08 18:32:16 -07:00
2019-09-13 20:54:56 +01:00
Stable binaries are also available on the [releases] page.
2019-09-11 21:06:31 +01:00
Stable releases are generally recommended for CI usage in particular.
2019-05-08 18:32:16 -07:00
To install, download the binary for your platform from "Assets" and place this
2020-02-28 14:18:52 -08:00
into your `$PATH` .
2019-05-08 18:32:16 -07:00
2019-08-20 11:43:57 -07:00
On macOS / Linux:
2019-07-10 12:24:50 -07:00
2019-12-13 13:01:11 -08:00
{{< codeFromInline lang = "bash" > }}
2020-05-15 17:47:02 +02:00
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.8.1/kind-$(uname)-amd64
2019-08-20 11:43:57 -07:00
chmod +x ./kind
mv ./kind /some-dir-in-your-PATH/kind
2019-12-13 13:01:11 -08:00
{{< / codeFromInline > }}
2019-02-08 08:30:55 -08:00
2020-02-28 14:18:52 -08:00
On Mac / Linux via Homebrew:
2019-11-19 10:20:43 -08:00
2019-12-13 13:01:11 -08:00
{{< codeFromInline lang = "bash" > }}
2019-11-19 10:20:43 -08:00
brew install kind
2019-12-13 13:01:11 -08:00
{{< / codeFromInline > }}
2019-07-10 12:24:50 -07:00
2019-08-20 11:43:57 -07:00
On Windows:
2019-07-10 12:24:50 -07:00
2019-12-13 13:01:11 -08:00
{{< codeFromInline lang = "powershell" > }}
2020-05-15 17:47:02 +02:00
curl.exe -Lo kind-windows-amd64.exe https://kind.sigs.k8s.io/dl/v0.8.1/kind-windows-amd64
2019-07-10 12:24:50 -07:00
Move-Item .\kind-windows-amd64.exe c:\some-dir-in-your-PATH\kind.exe
2019-12-13 13:01:11 -08:00
{{< / codeFromInline > }}
2019-11-21 11:48:45 -06:00
2020-02-28 14:18:52 -08:00
On Windows via Chocolatey (https://chocolatey.org/packages/kind)
2019-12-13 13:01:11 -08:00
{{< codeFromInline lang = "powershell" > }}
2019-11-21 11:48:45 -06:00
choco install kind
2019-12-13 13:01:11 -08:00
{{< / codeFromInline > }}
2019-07-10 12:24:50 -07:00
2018-11-20 15:01:45 -06:00
## Creating a Cluster
2019-02-08 08:30:55 -08:00
Creating a Kubernetes cluster is as simple as `kind create cluster` .
2018-11-20 15:01:45 -06:00
2019-10-31 07:55:31 +01:00
This will bootstrap a Kubernetes cluster using a pre-built
2018-11-20 15:01:45 -06:00
[node image][node image] - you can find it on docker hub
2019-10-31 07:55:31 +01:00
[`kindest/node` ][kindest/node].
If you desire to build the node image yourself see the
2018-11-20 15:01:45 -06:00
[building image ](#building-images ) section.
To specify another image use the `--image` flag.
2019-02-03 03:50:11 +02:00
By default, the cluster will be given the name `kind` .
2018-11-20 15:01:45 -06:00
Use the `--name` flag to assign the cluster a different context name.
2019-01-16 09:41:36 +00:00
If you want the `create cluster` command to block until the control plane
reaches a ready status, you can use the `--wait` flag and specify a timeout.
To use `--wait` you must specify the units of the time to wait. For example, to
wait for 30 seconds, do `--wait 30s` , for 5 minutes do `--wait 5m` , etc.
2018-11-30 14:57:54 -06:00
## Interacting With Your Cluster
2019-10-31 07:55:31 +01:00
2018-11-30 14:57:54 -06:00
After [creating a cluster ](#creating-a-cluster ), you can use [kubectl][kubectl]
2019-10-31 07:55:31 +01:00
to interact with it by using the [configuration file generated by kind][access multiple clusters].
2018-11-20 15:01:45 -06:00
2019-10-31 07:55:31 +01:00
By default, the cluster access configuration is stored in ${HOME}/.kube/config
if $KUBECONFIG environment variable is not set.
If $KUBECONFIG environment variable is set, then it is used as a list of paths
(normal path delimiting rules for your system). These paths are merged. When a value
is modified, it is modified in the file that defines the stanza. When a value is created,
it is created in the first file that exists. If no files in the chain exist,
then it creates the last file in the list.
You can use the `--kubeconfig` flag when creating the cluster, then only that file is loaded.
The flag may only be set once and no merging takes place.
2018-11-30 14:57:54 -06:00
To see all the clusters you have created, you can use the `get clusters`
command.
For example, let's say you create two clusters:
```
2019-02-08 08:30:55 -08:00
kind create cluster # Default cluster context name is `kind` .
2018-11-30 14:57:54 -06:00
...
2019-02-08 08:30:55 -08:00
kind create cluster --name kind-2
2018-11-30 14:57:54 -06:00
```
2019-02-03 03:50:11 +02:00
When you list your kind clusters, you will see something like the following:
2018-11-30 14:57:54 -06:00
```
2019-02-08 08:30:55 -08:00
kind get clusters
2019-02-03 03:50:11 +02:00
kind
kind-2
2018-11-30 14:57:54 -06:00
```
2019-10-31 09:50:14 +01:00
In order to interact with a specific cluster, you only need to specify the
2019-10-31 07:55:31 +01:00
cluster name as a context in kubectl:
2018-11-30 14:57:54 -06:00
```
2019-10-31 09:50:14 +01:00
kubectl cluster-info --context kind-kind
2020-03-22 14:51:30 +05:30
kubectl cluster-info --context kind-kind-2
2018-11-30 14:57:54 -06:00
```
## Deleting a Cluster
If you created a cluster with `kind create cluster` then deleting is equally
simple:
```
2019-02-08 08:30:55 -08:00
kind delete cluster
2018-11-30 14:57:54 -06:00
```
2018-11-20 15:01:45 -06:00
2019-02-03 03:50:11 +02:00
If the flag `--name` is not specified, kind will use the default cluster
context name `kind` and delete that cluster.
2018-11-20 15:01:45 -06:00
2019-02-15 17:37:01 -08:00
## Loading an Image Into Your Cluster
Docker images can be loaded into your cluster nodes with:
`kind load docker-image my-custom-image`
2019-11-20 17:11:58 +00:00
**Note**: If using a named cluster you will need to specify the name of the
cluster you wish to load the image into:
`kind load docker-image my-custom-image --name kind-2`
2019-02-15 17:37:01 -08:00
Additionally, image archives can be loaded with:
`kind load image-archive /my-image-archive.tar`
This allows a workflow like:
```
docker build -t my-custom-image:unique-tag ./my-image-dir
kind load docker-image my-custom-image:unique-tag
kubectl apply -f my-manifest-using-my-image:unique-tag
```
2020-03-10 14:43:12 +00:00
**Note**: You can get a list of images present on a cluster node by
using `docker exec` :
```
docker exec -it my-node-name crictl images
```
Where `my-node-name` is the name of the Docker container.
2019-02-27 15:14:16 +08:00
**Note**: The Kubernetes default pull policy is `IfNotPresent` unless
the image tag is `:latest` in which case the default policy is `Always` .
`IfNotPresent` causes the Kubelet to skip pulling an image if it already exists.
If you want those images loaded into node to work as expected, please:
- don't use a `:latest` tag
and / or:
- specify `imagePullPolicy: IfNotPresent` or `imagePullPolicy: Never` on your container(s).
See [Kubernetes imagePullPolicy][Kubernetes imagePullPolicy] for more information.
2019-03-28 18:45:59 -07:00
See also: [Using kind with Private Registries][Private Registries].
2018-11-20 15:01:45 -06:00
## Building Images
2019-11-17 17:45:34 -08:00
> Note: If you're using Docker Desktop, be sure to read [Settings for Docker Desktop](#settings-for-docker-desktop) first.
2019-02-03 03:50:11 +02:00
kind runs a local Kubernetes cluster by using Docker containers as "nodes".
kind uses the [`node-image` ][node image] to run Kubernetes artifacts, such
2018-11-13 16:30:09 -06:00
as `kubeadm` or `kubelet` .
The `node-image` in turn is built off the [`base-image` ][base image], which
installs all the dependencies needed for Docker and Kubernetes to run in a
container.
2018-12-12 00:37:23 +01:00
See [building the base image ](#building-the-base-image ) for more advanced information.
2018-11-20 15:01:45 -06:00
2019-08-16 14:19:20 -07:00
Currently, kind supports two different ways to build a `node-image`
if you have the [Kubernetes][kubernetes] source in your host machine
2018-11-20 15:01:45 -06:00
(`$GOPATH/src/k8s.io/kubernetes` ), by using `docker` or `bazel` .
To specify the build type use the flag `--type` .
2019-02-23 09:59:43 -05:00
Note however that using `--type=bazel` on Windows or MacOS will not work
currently due to Kubelet using [CGO] which requires GCC/glibc for linux.
A workaround may be enabled in the future.
2019-02-03 03:50:11 +02:00
kind will default to using the build type `docker` if none is specified.
2018-11-20 15:01:45 -06:00
```
2019-08-16 14:19:20 -07:00
kind build node-image --type bazel
2018-11-20 15:01:45 -06:00
```
Similarly as for the base-image command, you can specify the name and tag of
the resulting node image using the flag `--image` .
If you previously changed the name and tag of the base image, you can use here
the flag `--base-image` to specify the name and tag you used.
2019-11-17 17:45:34 -08:00
### Settings for Docker Desktop
2019-11-18 14:38:01 -08:00
If you are building Kubernetes (for example - `kind build node-image` ) on MacOS or Windows then you need a minimum of 6GB of RAM
2019-11-17 17:45:34 -08:00
dedicated to the virtual machine (VM) running the Docker engine. 8GB is recommended.
2019-05-05 15:32:16 -07:00
2019-07-10 12:24:50 -07:00
To change the resource limits for the Docker on Mac, you'll need to open the
2019-05-05 15:32:16 -07:00
**Preferences** menu.
< img src = "/docs/user/images/docker-pref-1.png" / >
Now, go to the **Advanced** settings page, and change the
settings there, see [changing Docker's resource limits][Docker resource lims].
2019-07-10 12:24:50 -07:00
< img src = "/docs/user/images/docker-pref-2.png" alt = "Setting 8Gb of memory in Docker for Mac" / >
To change the resource limits for the Docker on Windows, you'll need to right-click the Moby
icon on the taskbar, and choose "Settings". If you see "Switch to Linux Containers", then you'll need
to do that first before opening "Settings"
< img src = "/docs/user/images/docker-pref-1-win.png" / >
Now, go to the **Advanced** settings page, and change the
settings there, see [changing Docker's resource limits][Docker resource lims].
< img src = "/docs/user/images/docker-pref-build-win.png" alt = "Setting 8Gb of memory in Docker for Windows" / >
2019-05-05 15:32:16 -07:00
You may also try removing any unused data left by the Docker engine - e.g.,
`docker system prune` .
2018-11-30 14:57:54 -06:00
2018-11-20 15:01:45 -06:00
## Advanced
### Building The Base Image
2020-01-02 15:48:09 -08:00
2020-02-29 16:29:04 +08:00
To build the `base-image` we use the `make quick` command in `images/base` directory:
2018-11-13 16:30:09 -06:00
```
2020-02-29 16:29:04 +08:00
make quick
2018-11-13 16:30:09 -06:00
```
2020-02-29 16:29:04 +08:00
By default, the base image will be tagged as `kindest/base:$(date +v%Y%m%d)-$(git describe --always --dirty)` format.
If you want to change this, you can set `TAG` environment variable.
2018-11-13 16:30:09 -06:00
```
2020-02-29 16:29:04 +08:00
TAG=v0.1.0 make quick
2018-11-13 16:30:09 -06:00
```
2019-02-03 03:50:11 +02:00
### Configuring Your kind Cluster
2020-01-02 15:48:09 -08:00
2018-11-30 14:57:54 -06:00
For a sample kind configuration file see [kind-example-config][kind-example-config].
2019-05-14 11:45:12 +02:00
To specify a configuration file when creating a cluster, use the `--config`
flag:
```
kind create cluster --config kind-example-config.yaml
```
2018-11-30 14:57:54 -06:00
2019-04-08 16:40:53 +02:00
#### Multi-node clusters
2020-01-02 15:48:09 -08:00
2019-01-17 21:51:08 -08:00
In particular, many users may be interested in multi-node clusters. A simple
2019-02-22 03:42:27 +02:00
configuration for this can be achieved with the following config file contents:
2019-01-17 21:51:08 -08:00
```yaml
2019-02-08 08:30:55 -08:00
# three node (two workers) cluster config
2019-03-14 05:20:43 +02:00
kind: Cluster
2019-12-13 14:53:55 -08:00
apiVersion: kind.x-k8s.io/v1alpha4
2019-01-17 21:51:08 -08:00
nodes:
- role: control-plane
- role: worker
2019-03-14 05:20:43 +02:00
- role: worker
```
2019-04-08 16:40:53 +02:00
#### Control-plane HA
2019-03-14 05:20:43 +02:00
You can also have a cluster with multiple control-plane nodes:
```yaml
# a cluster with 3 control-plane nodes and 3 workers
kind: Cluster
2019-12-13 14:53:55 -08:00
apiVersion: kind.x-k8s.io/v1alpha4
2019-03-14 05:20:43 +02:00
nodes:
- role: control-plane
- role: control-plane
- role: control-plane
- role: worker
- role: worker
- role: worker
2019-01-17 21:51:08 -08:00
```
2018-11-30 14:57:54 -06:00
2019-06-23 18:55:38 +02:00
#### Mapping ports to the host machine
You can map extra ports from the nodes to the host machine with `extraPortMappings` :
```yaml
kind: Cluster
2019-12-13 14:53:55 -08:00
apiVersion: kind.x-k8s.io/v1alpha4
2019-06-23 18:55:38 +02:00
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 80
hostPort: 80
2019-10-02 11:17:06 -07:00
listenAddress: "0.0.0.0" # Optional, defaults to "0.0.0.0"
2019-06-26 18:34:28 +04:00
protocol: udp # Optional, defaults to tcp
2019-06-23 18:55:38 +02:00
```
This can be useful if using `NodePort` services or daemonsets exposing host ports.
2019-10-02 11:17:06 -07:00
Note: binding the `listenAddress` to `127.0.0.1` may affect your ability to access the service.
2020-01-23 10:20:04 -06:00
#### Setting Kubernetes version
2020-01-29 19:53:45 -06:00
You can also set a specific Kubernetes version by setting the `node` 's container image. You can find available image tags on the [releases page ](https://github.com/kubernetes-sigs/kind/releases ). Please use the `sha256` shasum for your desired kubernetes version, as seen in this example:
2020-01-23 10:20:04 -06:00
```yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
2020-01-29 19:53:45 -06:00
image: kindest/node:v1.16.4@sha256:b91a2c2317a000f3a783489dfb755064177dbc3a0b2f4147d50f04825d016f55
2020-01-23 10:20:04 -06:00
- role: worker
2020-01-29 19:53:45 -06:00
image: kindest/node:v1.16.4@sha256:b91a2c2317a000f3a783489dfb755064177dbc3a0b2f4147d50f04825d016f55
2020-01-23 10:20:04 -06:00
```
2019-10-02 11:17:06 -07:00
2019-05-29 10:44:12 +02:00
### Enable Feature Gates in Your Cluster
Feature gates are a set of key=value pairs that describe alpha or experimental features. In order to enable a gate you have to [customize your kubeadm configuration][customize control plane with kubeadm], and it will depend on what gate and component you want to enable. An example kind config can be:
2020-01-02 15:48:09 -08:00
{{< codeFromInline lang = "yaml" > }}
2019-05-29 10:44:12 +02:00
kind: Cluster
2019-12-13 14:53:55 -08:00
apiVersion: kind.x-k8s.io/v1alpha4
2020-05-10 11:49:38 -04:00
featureGates:
2020-05-12 11:04:18 -04:00
FeatureGateName: true
2020-01-02 15:48:09 -08:00
{{< / codeFromInline > }}
2019-04-08 16:40:53 +02:00
#### IPv6 clusters
2020-04-29 23:48:30 -07:00
You can run IPv6 single-stack clusters using `kind` , if the host that runs the docker containers support IPv6.
Most operating systems / distros have IPv6 enabled by defualt, but you can check on Linux with the following command:
2020-04-29 16:20:54 +02:00
```sh
sudo sysctl net.ipv6.conf.all.disable_ipv6
2020-04-29 23:48:30 -07:00
```
You should see:
```sh
2020-04-29 16:20:54 +02:00
net.ipv6.conf.all.disable_ipv6 = 0
```
2020-04-29 23:48:30 -07:00
If you are using Docker on Windows or Mac, you will need to use an IPv4 port
forward for the API Server from the host because IPv6 port forwards don't work
on these platforms, you can do this with the following config:
```yaml
# an ipv6 cluster
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: ipv6
apiServerAddress: 127.0.0.1
```
2019-04-08 16:40:53 +02:00
2020-04-29 23:48:30 -07:00
On Linux all you need is:
2019-04-08 16:40:53 +02:00
```yaml
# an ipv6 cluster
kind: Cluster
2019-12-13 14:53:55 -08:00
apiVersion: kind.x-k8s.io/v1alpha4
2019-04-08 16:40:53 +02:00
networking:
ipFamily: ipv6
2019-05-29 10:44:12 +02:00
```
2019-04-03 04:29:41 +02:00
### Configure kind to use a proxy
If you are running kind in an environment that requires a proxy, you may need to configure kind to use it.
You can configure kind to use a proxy using one or more of the following [environment variables][proxy environment variables] (uppercase takes precedence):
2019-12-19 15:44:31 -08:00
* `HTTP_PROXY` or `http_proxy`
* `HTTPS_PROXY` or `https_proxy`
* `NO_PROXY` or `no_proxy`
2019-04-03 04:29:41 +02:00
2019-06-24 14:50:44 -07:00
**Note**: If you set a proxy it would be used for all the connection requests.
2019-04-03 04:29:41 +02:00
It's important that you define what addresses doesn't need to be proxied with the NO_PROXY variable, typically you should avoid to proxy your docker network range `NO_PROXY=172.17.0.0/16`
2019-02-09 16:01:29 -08:00
### Exporting Cluster Logs
2019-02-03 03:50:11 +02:00
kind has the ability to export all kind related logs for you to explore.
To export all logs from the default cluster (context name `kind` ):
2018-11-30 14:57:54 -06:00
```
2019-02-08 08:30:55 -08:00
kind export logs
2018-11-30 14:57:54 -06:00
Exported logs to: /tmp/396758314
```
Like all other commands, if you want to perform the action on a cluster with a
different context name use the `--name` flag.
2019-02-03 03:50:11 +02:00
As you can see, kind placed all the logs for the cluster `kind` in a
2018-11-30 14:57:54 -06:00
temporary directory. If you want to specify a location then simply add the path
to the directory after the command:
```
2019-02-08 08:30:55 -08:00
kind export logs ./somedir
2018-11-30 14:57:54 -06:00
Exported logs to: ./somedir
```
The structure of the logs will look more or less like this:
```
.
├── docker-info.txt
2019-02-03 03:50:11 +02:00
└── kind-control-plane/
2018-11-30 14:57:54 -06:00
├── containers
├── docker.log
├── inspect.json
├── journal.log
├── kubelet.log
├── kubernetes-version.txt
└── pods/
```
The logs contain information about the Docker host, the containers running
2019-02-03 03:50:11 +02:00
kind, the Kubernetes cluster itself, etc.
2018-11-30 14:57:54 -06:00
2019-08-05 12:49:23 -07:00
[go-supported]: https://golang.org/doc/devel/release.html#policy
2019-02-09 15:50:34 -08:00
[known issues]: /docs/user/known-issues
2019-09-13 20:54:56 +01:00
[releases]: https://github.com/kubernetes-sigs/kind/releases
2019-02-09 15:50:34 -08:00
[node image]: /docs/design/node-image
[base image]: /docs/design/base-image
2019-02-26 17:11:56 +08:00
[kind-example-config]: https://raw.githubusercontent.com/kubernetes-sigs/kind/master/site/content/docs/user/kind-example-config.yaml
2019-11-18 16:07:08 +08:00
[pkg/build/base/base.go]: https://github.com/kubernetes-sigs/kind/tree/master/pkg/build/base/base.go
2018-11-13 16:30:09 -06:00
[kubernetes]: https://github.com/kubernetes/kubernetes
2018-11-20 15:01:45 -06:00
[kindest/node]: https://hub.docker.com/r/kindest/node/
[kubectl]: https://kubernetes.io/docs/reference/kubectl/overview/
2018-12-10 11:44:00 -06:00
[Docker resource lims]: https://docs.docker.com/docker-for-mac/#advanced
2019-02-08 08:30:55 -08:00
[install docker]: https://docs.docker.com/install/
2019-04-03 04:29:41 +02:00
[proxy environment variables]: https://docs.docker.com/network/proxy/#use -environment-variables
2019-02-23 09:59:43 -05:00
[CGO]: https://golang.org/cmd/cgo/
2019-02-27 15:14:16 +08:00
[Kubernetes imagePullPolicy]: https://kubernetes.io/docs/concepts/containers/images/#updating -images
2019-03-28 18:45:59 -07:00
[Private Registries]: /docs/user/private-registries
2019-05-29 10:44:12 +02:00
[customize control plane with kubeadm]: https://kubernetes.io/docs/setup/independent/control-plane-flags/
2019-10-31 09:50:14 +01:00
[access multiple clusters]: https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/