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
2019-06-25 18:03:26 -07:00
You can either install kind with `GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0` 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
2019-08-15 15:13:37 -07:00
**NOTE**: please use the latest Go to do this, ideally go 1.12.9 or greater.
2019-08-05 12:49:23 -07:00
A version of Go officially [supported upstream][go-supported] by the Go project must be used.
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.
2019-05-16 14:53:10 -07:00
Without installing go, kind can be built reproducibly with docker using `make build` .
2019-05-08 18:32:16 -07:00
Stable binaries are also available on the [releases] page. Stable releases are
generally recommended for CI usage in particular.
To install, download the binary for your platform from "Assets" and place this
2019-07-10 12:24:50 -07:00
into your `$PATH` .
2019-05-08 18:32:16 -07:00
2019-07-10 12:24:50 -07:00
E.G. for macOS:
```bash
2019-06-25 18:03:26 -07:00
curl -Lo ./kind-darwin-amd64 https://github.com/kubernetes-sigs/kind/releases/download/v0.4.0/kind-darwin-amd64
2019-05-20 06:22:55 -07:00
chmod +x ./kind-darwin-amd64
mv ./kind-darwin-amd64 /some-dir-in-your-PATH/kind
2019-05-08 18:32:16 -07:00
```
2019-02-08 08:30:55 -08:00
2019-07-10 12:24:50 -07:00
E.G. for Windows:
```powershell
curl.exe -Lo kind-windows-amd64.exe https://github.com/kubernetes-sigs/kind/releases/download/v0.4.0/kind-windows-amd64
Move-Item .\kind-windows-amd64.exe c:\some-dir-in-your-PATH\kind.exe
```
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
This will bootstrap a Kubernetes cluster using a pre-built
[node image][node image] - you can find it on docker hub
[`kindest/node` ][kindest/node].
If you desire to build the node image yourself see the
[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
After [creating a cluster ](#creating-a-cluster ), you can use [kubectl][kubectl]
2019-02-03 03:50:11 +02:00
to interact with it by using the configuration file generated by kind:
2018-11-20 15:01:45 -06:00
```
export KUBECONFIG="$(kind get kubeconfig-path)"
kubectl cluster-info
```
`kind get kubeconfig-path` returns the location of the generated confguration
file.
2018-11-30 14:57:54 -06:00
If you gave a non-default cluster context name to your cluster, then you can
specify the name by using the `--name` flag.
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
```
Both of these clusters will have a kubeconfig file to go along with them:
```
2019-02-08 08:30:55 -08:00
kind get kubeconfig-path
2019-02-03 03:50:11 +02:00
/home/user/.kube/kind-config-kind
2018-11-30 14:57:54 -06:00
2019-02-08 08:30:55 -08:00
kind get kubeconfig-path --name kind-2
2019-02-03 03:50:11 +02:00
/home/user/.kube/kind-config-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`
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
```
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-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-02-03 03:50:11 +02:00
Currently, kind supports three different ways to build a `node-image` : via
2018-11-20 15:01:45 -06:00
`apt` , or if you have the [Kubernetes][kubernetes] source in your host machine
(`$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-02-08 08:30:55 -08:00
kind build node-image --type apt
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-05-05 15:32:16 -07:00
**Note**: If you are running kind on MacOS or Windows then it is recommended
2019-07-10 12:24:50 -07:00
that you have at least 8GB of RAM dedicated to the virtual machine (VM) running
2019-05-05 15:32:16 -07:00
the Docker engine otherwise Building Kubernetes may fail.
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
2018-11-13 16:30:09 -06:00
To build the `base-image` we use the `build` command:
```
2019-02-08 08:30:55 -08:00
kind build base-image
2018-11-13 16:30:09 -06:00
```
If you want to specify the path to the base image source files you can use the
`--source` flag.
2019-05-05 15:32:16 -07:00
If `--source` is not specified, kind will attempt to automatically locate
the `images/base` base source directory.
2018-11-13 16:30:09 -06:00
By default, the base image will be tagged as `kindest/base:latest` .
If you want to change this, you can use the `--image` flag.
```
2019-02-08 08:30:55 -08:00
kind build base-image --image base:v0.1.0
2018-11-13 16:30:09 -06:00
```
2019-02-03 03:50:11 +02:00
### Configuring Your kind Cluster
When creating your kind cluster, via `create cluster` , you can use a
2018-11-30 14:57:54 -06:00
configuration file to run specific commands before or after systemd or kubeadm
run.
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
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
apiVersion: kind.sigs.k8s.io/v1alpha3
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
apiVersion: kind.sigs.k8s.io/v1alpha3
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
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
- role: control-plane
- role: worker
extraPortMappings:
- containerPort: 80
hostPort: 80
listenAddress: "127.0.0.1" # 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-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:
```
# this config file contains all config fields with comments
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
# patch the generated kubeadm config with some extra settings
kubeadmConfigPatches:
- |
2019-06-27 17:27:37 +02:00
apiVersion: kubeadm.k8s.io/v1beta2
2019-05-29 10:44:12 +02:00
kind: ClusterConfiguration
metadata:
name: config
apiServer:
extraArgs:
2019-06-02 20:38:53 +02:00
"feature-gates": "FeatureGateName=true"
2019-05-29 10:44:12 +02:00
scheduler:
extraArgs:
2019-06-02 20:38:53 +02:00
"feature-gates": "FeatureGateName=true"
2019-05-29 10:44:12 +02:00
controllerManager:
extraArgs:
2019-06-02 20:38:53 +02:00
"feature-gates": "FeatureGateName=true"
2019-05-29 10:44:12 +02:00
- |
2019-06-27 17:27:37 +02:00
apiVersion: kubeadm.k8s.io/v1beta2
2019-05-29 10:44:12 +02:00
kind: InitConfiguration
metadata:
name: config
nodeRegistration:
kubeletExtraArgs:
2019-06-02 20:38:53 +02:00
"feature-gates": "FeatureGateName=true"
2019-05-29 10:44:12 +02:00
# 1 control plane node and 3 workers
nodes:
# the control plane node config
- role: control-plane
# the three workers
- role: worker
2019-04-08 16:40:53 +02:00
```
#### IPv6 clusters
You can run ipv6 only clusters using `kind` , but first you need to
[enable ipv6 in your docker daemon][docker enable ipv6].
```yaml
# an ipv6 cluster
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
networking:
ipFamily: ipv6
nodes:
# the control plane node
- role: control-plane
2019-05-29 10:44:12 +02:00
- role: worker
- role: worker
```
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):
* HTTP_PROXY or http_proxy
* HTTPS_PROXY or https_proxy
* NO_PROXY or no_proxy
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
[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-02-09 15:50:34 -08:00
[pkg/build/base/sources]: https://github.com/kubernetes-sigs/kind/tree/master/pkg/build/base/sources
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-04-08 16:40:53 +02:00
[docker enable ipv6]: https://docs.docker.com/config/daemon/ipv6/