前言:我都是按照官方文档一步一步往下走的
以下是kubernetes的文档地址
https://kubernetes.io/zh-cn/docs/home/
安装kubectl
在 Linux 系统中安装并设置 kubectl文章地址:
https://kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-linux/
- 用 curl 在 Linux 系统中安装 kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- 验证该可执行文件
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
- 验证 kubectl 的可执行文件:
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
验证通过时,输出为:
kubectl: OK
验证失败时,sha256 将以非零值退出,并打印如下输出:
kubectl: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match
说明:
出现上面的错误表示:下载的 kubectl 与校验和文件版本必须相同。
- 安装 kubectl:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- 执行测试,以保障你安装的版本是最新的:
kubectl version --client
或者使用如下命令来查看版本的详细信息:
kubectl version --client --output=yaml
安装kind
- 下载最新版本的 kind 二进制文件
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
- 添加可执行权限
chmod +x ./kind
- 移动到/usr/local/bin/下面
sudo mv ./kind /usr/local/bin/kind
- 验证安装成功
kind version
- 创建多节点集群(通过配置文件)
cat > kind-config.yaml <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
6.使用刚才创建的配置文件来初始化并启动一个多节点的 Kubernetes 集群
kind create cluster --config=kind-config.yaml
上面在启动的时候会用docker拉取镜像,docker的安装教程有很多,我给一个教程的连接
https://blog.csdn.net/Stromboli/article/details/142486692
Docker 镜像拉取超时
[root@hcss-ecs-97dc downloads]# kind create cluster --config=kind-config.yaml
Creating cluster "kind" ...
✗ Ensuring node image (kindest/node:v1.27.3) 🖼
ERROR: failed to create cluster: failed to pull image "kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72": command "docker pull kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72" failed with error: exit status 1
Command Output: Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
还没有写完,先保存着。。。