使用KubeKey新增worker节点
1.更改主机名
hostnamectl set-hostname worker3
2.验证主机名
切入新的终端会话,验证主机名修改成功
bash
3.配置DNS
echo "nameserver 114.114.114.114" > /etc/resolv.conf
4.配置服务器时区
配置服务器时区为 Asia/Shanghai。
timedatectl set-timezone Asia/Shanghai
5.配置时间同步
yum install chrony -y
修改配置文件 /etc/chrony.conf,修改 ntp 服务器配置。
vi /etc/chrony.conf
# 删除所有的 server 配置
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
# 增加国内的 ntp 服务器,或是指定其他常用的时间服务器
pool cn.pool.ntp.org iburst
# 可以使用 sed 自动替换生成
sed -i '/centos.pool.ntp.org/d' /etc/chrony.conf
sed -i "2a pool cn.pool.ntp.org iburst" /etc/chrony.conf
重启并设置 chrony 服务开机自启动。
systemctl enable chronyd --now
验证 chrony 同步状态。
执行查看命令
chronyc sourcestats -v
6.关闭系统防火墙
systemctl stop firewalld && systemctl disable firewalld
7.禁用 SELinux
# 使用 sed 修改配置文件,实现彻底的禁用
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
# 使用命令,实现临时禁用,这一步其实不做也行,KubeKey 会自动配置
setenforce 0
8.新增节点
查看当前节点
[root@master1 ~]# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master1 Ready control-plane 8d v1.26.15 192.168.100.201 <none> CentOS Linux 7 (Core) 3.10.0-1160.119.1.el7.x86_64 containerd://1.6.33
worker1 Ready worker 8d v1.26.15 192.168.100.202 <none> CentOS Linux 7 (Core) 3.10.0-1160.119.1.el7.x86_64 containerd://1.7.13
worker2 Ready worker 8d v1.26.15 192.168.100.203 <none> CentOS Linux 7 (Core) 3.10.0-1160.119.1.el7.x86_64 containerd://1.7.13
新增节点
export KKZONE=cn
./kk add nodes -f ksp-v341-v126.yaml