In the previous article, we told how to install kind y how to create a cluster with this tool (you can see it here Kubernetes Cluster with Kind), now we will talk about how we can Interact with a Kubernetes Cluster using Kind.
Create a Cluster
To create a cluster with Kind we can use the command create cluster
, by default kind create a cluster called kind (If you do not use --name
parameter)
For example, to create a cluster with a default name and a cluster with a custom name we can use the next commands:
kind create cluster # Default cluster context name is `kind`.
# creating a custom name cluster
kind create cluster --name kind-2
we will see something like the following:
$ kind create cluster
Creating cluster "kind" ...
β Ensuring node image (kindest/node:v1.21.1) πΌ
β Preparing nodes π¦
β Writing configuration π
β Starting control-plane πΉοΈ
β Installing CNI π
β Installing StorageClass πΎ
Set kubectl context to "kind-kind"
You can now use your cluster with:
kubectl cluster-info --context kind-kind
Have a nice day! π
$ kind create cluster --name kind-2
Creating cluster "kind-2" ...
β Ensuring node image (kindest/node:v1.21.1) πΌ
β Preparing nodes π¦
β Writing configuration π
β Starting control-plane πΉοΈ
β Installing CNI π
β Installing StorageClass πΎ
Set kubectl context to "kind-kind-2"
You can now use your cluster with:
kubectl cluster-info --context kind-kind-2
Not sure what to do next? π
Check out https://kind.sigs.k8s.io/docs/user/quick-start/
Listing our Clusters
Using the command get clusters
we can see the name of the clusters we have.
For example:
kind get clusters
we obtain something like this:
$ kind get clusters
kind
kind-2
Loading an Image Into a Cluster
With Kind also we can load our docker images into our cluster nodes, to do that we can use the command load docker-image
, previous to use this command we need to have the docker image.
we can use docker build
command to create our image, for example:
docker build -t my-image:my-tag .
Now we can load our image into a cluster
kind load docker-image my-image:my-tag
we will see this result:
$ kind load docker-image lab-1:latest
Image: "lab-1:latest" with ID "sha256:019302746a926ab8fd93400a0be0ea4ffc5e9e6a6f6b645258f96391fce7995b" not yet present on node "kind-control-plane", loading...
Also kind allows loading docker images with a file using kind load image-archive my-image-file.tar
command, the result is like `docker-image
Note: we can use
load
command with the param--name
to specify a cluster, by default Kind uses the cluster called kind if we do not specify a name
Deleting a Cluster
To delete a cluster with Kind we can use the command delete cluster
, this command also uses the parameter --name
to indicate a specific cluster's name (by default Kind uses the name 'kind').
For example, we can delete the two clusters previously created with these commands:
kind delete cluster
kind delete cluster --name kind-2
if everything is right, we will see something like this:
$ kind delete cluster
Deleting cluster "kind" ...
$ kind delete cluster --name kind-2
Deleting cluster "kind-2" ...
Conslusion
In this post, we saw some commands to interact with our cluster create with Kind, existing other commands, and more parameters that we can use but we focussed on the basics.
Top comments (0)