在 CentOS 上安装 K8S(kubernetes) 的完整指南

在 CentOS 上安装 K8S(kubernetes) 的完整指南

前言:我都是按照官方文档一步一步往下走的

以下是kubernetes的文档地址

https://kubernetes.io/zh-cn/docs/home/

安装kubectl

在 Linux 系统中安装并设置 kubectl文章地址:

https://kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-linux/

  1. 用 curl 在 Linux 系统中安装 kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  1. 验证该可执行文件
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
  1. 验证 kubectl 的可执行文件:
echo "$(cat kubectl.sha256)  kubectl" | sha256sum --check

验证通过时,输出为:

kubectl: OK

验证失败时,sha256 将以非零值退出,并打印如下输出:

kubectl: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match

说明:
出现上面的错误表示:下载的 kubectl 与校验和文件版本必须相同。

  1. 安装 kubectl:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
  1. 执行测试,以保障你安装的版本是最新的:
kubectl version --client

或者使用如下命令来查看版本的详细信息:

kubectl version --client --output=yaml

安装kind

  1. 下载最新版本的 kind 二进制文件
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
  1. 添加可执行权限
chmod +x ./kind
  1. 移动到/usr/local/bin/下面
sudo mv ./kind /usr/local/bin/kind
  1. 验证安装成功
kind version
  1. 创建多节点集群(通过配置文件)
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)

在这里插入图片描述
还没有写完,先保存着。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值