Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create a local cluster in kind

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to create a local cluster in kind. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Installation

Download and install the Kind binaries using the following command:

GO111MODULE= "on" go get sigs.k8s.io/kind@v0.8.1 ensures that kind binaries exist > kind versionkind v0.8.1 go1.14.2 darwin/amd64

We should now be able to start a Kubernetes cluster using kind CLI:

Usage: kind [command] Available Commands: build Build one of [node-image] completion Output shell completion code for the specified shell create Creates one of [cluster] delete Deletes one of [cluster] export Exports one of [kubeconfig, logs] get Gets one of [clusters, nodes, kubeconfig] help Help about any command load Loads images into nodes version Prints the kind CLI version

In this article, we will focus on the create, get, and delete commands.

Create a cluster

You can create a cluster by executing the following command:

Kind create cluster

> kind create clusterCreating cluster "kind"... ✓ Ensuring node image (kindest/node:v1.18.2)? ✓ 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!?

A Kubernetes cluster will be created by pulling the latest Kubernetes node (v 1.18.2). We have just created a Kubernetes cluster of v1.18.2.

If we do not have the-- name parameter during the cluster creation process, the cluster name will be set to kind by default.

Create a specific version of K8S cluster

We can deploy a specific version of the Kubernetes cluster by passing the-- image parameter.

The commands used are:

Kind create cluster-image kindest/node:v1.15.6

> kind create cluster--image kindest/node:v1.15.6-- name kind-1.15.6Creating cluster "kind"... ✓ Ensuring node image (kindest/node:v1.15.6)? ✓ 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!? List deployed clusters

Enter command: kind get clusters

> kind get clusterskindkind-1.15.6

This should list the two different K8S versions of the clusters we created earlier.

Set the context for kubectl

After the cluster is created, kubectl points to the recently created K8S cluster.

Let's check all the available contexts.

> kubectl config get-contextsCURRENT NAME CLUSTER kind-kind kind-kind * kind-kind-1.15.6 kind-kind-1.15.6

From the output, we can conclude that the kubectl context is currently set to the latest cluster, kind-1.15.6. (the context name is prefixed with kind)

To set the kubectl context to a kind cluster with version 1.18.2, we need to do the following:

> kubectl config set-context kind-kind Context "kind-kind" modified.

To verify that kubectl points to the correct cluster, we need to check the nodes:

> kubectl get nodesNAME STATUS ROLES AGE VERSIONkind-1.18.2-control-plane Ready master 8m20s v1.18.2 delete a cluster

To delete a specific cluster, pass the cluster name to the delete command in the-- name parameter.

The command is: kind delete cluster-- name kind

Kind delete cluster-- name kindDeleting cluster "kind"... Delete all clusters

If you want to delete all clusters at once, execute:

Kind delete clusters-all

> kind delete clusters-- allDeleted clusters: ["kind-1.15.6"] this is the end of how to create a local cluster in kind. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report