安装Kind
参考:https://kind.sigs.k8s.io/docs/user/quick-start/#installation
Mac
建议使用Homebrew安装
brew install kind
Linux
# For AMD64 / x86_64
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
# For ARM64
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-arm64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
创建集群
创建单节点集群
kind create cluster --name [cluster_name]
创建多节点集群
可以通过编写yaml文件实现,并使用指令部署
kind: Cluster # 节点名称
apiVersion: kind.x-k8s.io/v1alpha4
nodes: # 节点列表,需要几个节点写几个
- role: control-plane # master节点
- role: worker # worker从节点
- role: worker
kind create cluster --config [yaml_file]
指定Kubernetes版本
通过配置image参数实现
kind create cluster --config [yaml_file] --image [image]
如:kind create cluster --config kind.yaml --image kindest/node:v1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab
安装成功
出现以下提示则说明安装成功
~/: kind create cluster --config kind.yaml --image kindest/node:v1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab
Creating cluster "kind" ...
✓ Ensuring node image (kindest/node:v1.24.15) 🖼
✓ Preparing nodes 📦 📦 📦 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
✓ Joining worker nodes 🚜
Set kubectl context to "kind-kind"
You can now use your cluster with:
kubectl cluster-info --context kind-kind
Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/quick-start/
设置kubectl
根据[安装成功]的提示中的指令执行
kubectl cluster-info --context [cluster_name]-kind