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 use kind to build k8s cluster

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly shows you "how to use kind to build k8s clusters". The content is simple and easy to understand and organized. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "how to use kind to build k8s clusters".

1 Create a k8s single-node cluster

1.1 creating a cluster

# kind create cluster --name k8s-single-node-cluster

1.2 View cluster information

# export KUBECONFIG="$(kind get kubeconfig-path --name="k8s-single-node-cluster")"

# echo $KUBECONFIG

# kubectl cluster-info

1.3 View cluster node information

# kubectl get nodes

1.4 View cluster component information

# kubectl get cs

1.5 Create deployments and pods

# kubectl run nginx --image=nginx:1.14-alpine --replicas=2

1.6 View pod information

# kubectl get pods

2 Create k8s multi-node cluster (1 master 1 worker)

2.1 Writing a multi-node cluster configuration file

# touch /opt/kind/config/k8s-multi-nodes-cluster.yaml

The document reads as follows:

kind: Cluster

apiVersion: kind.sigs.k8s.io/v1alpha3

nodes:

- role: control-plane

- role: worker

2.2 Create a multi-node cluster

# kind create cluster --config ./ k8s-multi-nodes-cluster.yaml --name k8s-multi-nodes-cluster

2.3 Set up and get multi-node cluster information

# export KUBECONFIG="$(kind get kubeconfig-path --name="k8s-multi-nodes-cluster")"

# kubectl cluster-info

2.4 View multi-node cluster information

# kubectl get nodes

3 Create HA high availability k8s cluster (multiple masters, multiple workers)

3.1 Writing a High Availability Cluster Profile

# touch /opt/kind/config/k8s-ha-cluster.yaml

The document reads as follows:

#Four nodes, two control-plane nodes, two workers nodes

kind: Cluster

apiVersion: kind.sigs.k8s.io/v1alpha3

kubeadmConfigPatches:- |

apiVersion: kubeadm.k8s.io/v1beta2

kind: ClusterConfiguration

metadata:

name: config

networking: serviceSubnet: 10.8.0.0/16

imageRepository: registry.aliyuncs.com/google_containers

nodeRegistration:

kubeletExtraArgs:

pod-infra-container-image: registry.aliyuncs.com/google_containers/pause:3.1

- |

apiVersion: kubeadm.k8s.io/v1beta2

kind: InitConfiguration

metadata: name: config

networking:

serviceSubnet: 10.8.0.0/16

imageRepository: registry.aliyuncs.com/google_containers

nodes:

- role: control-plane

- role: control-plane

- role: worker

- role: worker

3.2 Creating a High Availability Cluster

# kind create cluster --config ./ k8s-ha-cluster.yaml --name k8s-ha-cluster

3.3 Set up and get high availability cluster information

# export KUBECONFIG="$(kind get kubeconfig-path --name="k8s-ha-cluster")"

# kubectl cluster-info

3.4 View high availability cluster information

# kubectl get nodes

4 Delete clusters

# kind delete cluster --name k8s-single-node-cluster

Also note that clearing environment variables:

# unset KUBECONFIG

The above is "how to use kind to build k8s cluster" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

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