cetos7搭建部署k8s 版本1.28

主机分配

内存最少是4G cpu个数最少两个

|-----------------|----|-----|-----|
| IP | 内存 | CPU | 主机名 |
| 192.168.231.120 | 4 | 4 | K1 |
| 192.168.231.121 | 4 | 4 | K2 |
| 192.168.231.122 | 4 | 4 | K3 |

关闭防火墙

systemctl stop firewalled

关闭swap

vim /etc/fstab

设置主机名称

hostnameset

安装docker 三个主机

初始化集群

在master上面执行

kubeadm init

初始化成功后

在 K1上面执行

在master上安装 flanel 网络插件

github上面 k8s官网 flannel 网络通信组件 对于版本 kubenetes 1.17+

复制代码
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

K1 成功

获取节点信息

加入node节点进入集群

即把 K2 K3主机加入到k8s集群中

生成 K1主节点的token

复制代码
# 在K1 master上面生成  
kubeadm token create --print-join-command

# 创建一个永不过期的token 
kubeadm token create --ttl 0 --print-join-command



#  在k2 k3 wokenode上执行下面命令  加入k8s集群 
生成的结果如下 不过期的token 

kubeadm join 192.168.241.131:6443 --token 5ajtxi.sx49u7jyygnmw0c4 --discovery-token-ca-cert-hash sha256:ada6bf229e93d346c4af69f953c96040c12c30b1f2b10eb2993052fbfaa48651

k8s集群搭建完成

复制代码
kubectl get nodes

测试集群环境

K2节点加入报错

复制代码
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR CRI]: container runtime is not running: output: time="2024-01-18T10:41:00-05:00" level=fatal msg="validate service connection: validate CRI v1 runtime API for endpoint \"unix:///var/run/containerd/containerd.sock\": rpc error: code = Unimplemented desc = unknown service runtime.v1.RuntimeService"
, error: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

解决办法:

在master端 重启 systemctl restart containerd

在node 端 删除 rm /etc/containerd/config.toml 重启 systemctl restart containerd

加入之后 如果没有 ready 在重启 master端的node

相关推荐
Codigger官方6 分钟前
Linux 基金会牵头成立 React 基金会:前端开源生态迎来里程碑式变革
linux·前端·react.js
武文斌777 分钟前
项目学习总结:LVGL图形参数动态变化、开发板的GDB调试、sqlite3移植、MQTT协议、心跳包
linux·开发语言·网络·arm开发·数据库·嵌入式硬件·学习
爱吃喵的鲤鱼11 分钟前
仿mudou——Connection模块(连接管理)
linux·运维·服务器·开发语言·网络·c++
让子弹飞0220 分钟前
永久解决ubuntu网络连接问题
linux·运维·ubuntu
-L731 分钟前
【Kubernetes】常见面试题汇总(十九)
云原生·容器·kubernetes
郝学胜-神的一滴43 分钟前
使用Linux的read和write系统函数操作文件
linux·服务器·开发语言·数据库·c++·程序人生·软件工程
七七七七072 小时前
【Linux 系统】打开文件和文件系统
linux·运维·spring
DeeplyMind2 小时前
第二章:模块的编译与运行-7 Loading and Unloading Modules
linux·驱动开发
---学无止境---3 小时前
Linux中驱动程序通过fasync异步通知应用程序的实现
linux
cccyi73 小时前
Linux 进程间通信机制详解
linux·进程通信