1 已安装docker,版本信息如下
[root@my_ob ~]# docker version
Client:
Version: 1.13.1
API version: 1.26
Package version: docker-1.13.1-209.git7d71120.el7.centos.x86_64
Go version: go1.10.3
Git commit: 7d71120/1.13.1
Built: Wed Mar 2 15:25:43 2022
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: docker-1.13.1-209.git7d71120.el7.centos.x86_64
Go version: go1.10.3
Git commit: 7d71120/1.13.1
Built: Wed Mar 2 15:25:43 2022
OS/Arch: linux/amd64
Experimental: false
2 下载kubectl,配置权限,移动到相应目录下
[root@my_ob ~]# curl -LO
https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/linux/amd64/kubectl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 40.9M 100 40.9M 0 0 351k 0 0:01:59 0:01:59 --:--:-- 344k
###设置kubectl执行权限,移动到/usr/local/bin 目录
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
###看一下kubectl的版本
[root@my_ob ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:40:16Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
3 下载kind的二进制版本
使用二进制版本比较简单,也省时间,不过这里下载的版本比较老,导致后面出现了不少问题
[root@my_ob ~]# curl -Lo ./kind
https://github.com/kubernetes-sigs/kind/releases/download/v0.5.1/kind-linux-amd64
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 39.1M 100 39.1M 0 0 86639 0 0:07:54 0:07:54 --:--:-- 327k
####赋予执行权限,移动到可执行文件目录下
[root@my_ob ~]# chmod +x ./kind
[root@my_ob ~]# mv ./kind /usr/local/bin/kind
####看一下版本
[root@my_ob ~]# kind --version
kind version v0.5.1
4 创建kubenetes集群
因为想使用helm,所以指定了kind节点映像版本,导致后面出现了问题
[root@my_ob ~]# kind create cluster --image kindest/node:v1.21.1 --name my_cluster
Creating cluster "my_cluster" ...
✓ Ensuring node image (kindest/node:v1.21.1) 🖼
✓ Preparing nodes 📦
✓ Creating kubeadm config 📜
✗ Starting control-plane 🕹️
Error: failed to create cluster: failed to init node with kubeadm: exit status 1
4 创建集群在最后一步启动控制面失败,加上retain选项,后面可以查看日志
[root@my_ob ~]# kind create cluster --image kindest/node:v1.21.1 --name my_cluster --retain
Creating cluster "my_cluster" ...
✓ Ensuring node image (kindest/node:v1.21.1) 🖼
✓ Preparing nodes 📦
✓ Creating kubeadm config 📜
✗ Starting control-plane 🕹️
Error: failed to create cluster: failed to init node with kubeadm: exit status 1
导出日志,这里需要指定name为my_cluster,默认为kind
[root@my_ob ~]# kind export logs --name my_cluster
Exported logs to: /tmp/258278204
cd /tmp/258278204/my_cluster-control-plane
[root@my_ob my_cluster-control-plane]# more containerd.log
May 31 05:41:55 mycluster-control-plane containerd[214]: time="2022-05-31T05:41:55.731796446Z" level=error msg="failed t
o load cni during init, please check CRI plugin status before setting up network for pods" error="cni config load failed
: no network config found in /etc/cni/net.d: cni plugin not initialized: failed to load cni config"
5 重新下载最新版的kind二进制文件,删除以前的集群
curl -Lo ./kind
https://kind.sigs.k8s.io/dl/v0.14.0/kind-linux-amd6
###删除以前的集群
kind delete cluster --name my_cluster
####重新创建cluster,新版本下集群名字不能带_了,改成-
[root@my_ob ~]# kind create cluster --image kindest/node:v1.21.1 --name my-cluster
Creating cluster "my-cluster" ...
✓ Ensuring node image (kindest/node:v1.21.1) 🖼
✓ Preparing nodes 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
Set kubectl context to "kind-my-cluster"
You can now use your cluster with:
kubectl cluster-info --context kind-my-cluster
6 检查一下集群信息
[root@my_ob ~]# kubectl cluster-info --context kind-my-cluster
Kubernetes master is running at
https://127.0.0.1:6879
CoreDNS is running at
https://127.0.0.1:6879/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.