Kind

Kind helps you bring up local k8s cluster for testing and POC. Seamlessly working with kubectl and others: such as prometheus, operator, helmfile, etc.

Install Kind

The install is easy with go(1.17+), see this instruction:

1
2
3
# At the time of writing the kind stable version is 0.18.0, it will place the
# kind binary to $GOBIN(if exist) or $GOPATH
go install sigs.k8s.io/kind@v0.18.0

Basic Workflow

Cluster Creation

To spin up local k8s cluster:

1
2
3
4
5
6
7
8
9
10
11
12
13
# see options and flags
kind create cluster --help

# You can have multiple types of cluster such as dev, stg, prod, etc
# create one node cluster with dev as context name
kind create cluster --name dev

# Different cluster with specific configuration
kind create cluster --name stg --config stg_config.yaml

# Check k8s context
# Note the cluster name is not the same as context name
kubectl config get-contexts

Cluster Configuration

The advanced configuration please see this section. A simple multi-node cluster, can be used to test for example rolling upgrade:

1
2
3
4
5
6
7
8
9
10
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
# 1 control plane node and 3 workers
nodes:
# the control plane node config
- role: control-plane
# the three workers
- role: worker
- role: worker
- role: worker

Load Image

The kind k8s cluster uses containerd runtime, you can docker exec into node container and check with crictl command:

1
2
3
4
5
6
# list images
crictl images
# list containers
crictl ps
# list pods
crictl pods

To load image into the kind node, for example:

1
kind load docker-image busybox [--name dev] [--nodes x,y,z]

Then in the node container you will see busybox by crictl images.

Context Switch

To manage clusters:

1
2
3
4
5
6
7
8
# View kind clusters
kind get clusters

# Get cluster kubeconfig detail
kind get kubeconfig -n dev

# Switch context from dev to stg
kubectl config use-contexts kind-stg

Cluster Deletion

1
kind delete cluser --name dev

Kind Logging

To check kind logs:

1
kind export logs --name dev [./some_folder]

Ingress

For how to set up ingress for kind K8s cluster, please check: https://kind.sigs.k8s.io/docs/user/ingress/

Load Balancer

For how to set up LB service type in kind K8s cluster, please check: https://kind.sigs.k8s.io/docs/user/loadbalancer/

0%