IP | 主机名 | 操作系统 | 应用 | 说明 |
---|---|---|---|---|
10.10.114.100 | k8s-rke2-worker | 三台server的vip | ||
10.10.114.101 | k8s-rke2-worker01 | rocky9.3 | keepalive+haproxy,control-plane,etcd,master | |
10.10.114.102 | k8s-rke2-worker02 | rocky9.3 | keepalive+haproxy,control-plane,etcd,master | |
10.10.114.103 | k8s-rke2-worker03 | rocky9.3 | keepalive+haproxy,control-plane,etcd,master | |
10.10.114.104 | k8s-rke2-node01 | rocky9.3 | agent | 工作节点 |
#配置主机名
hostnamectl set-hostname k8s-rke2-worker01
#配置hosts
cat >> /etc/hosts << EOF
10.10.114.100 k8s-rke2-worker
10.10.114.101 k8s-rke2-worker01
10.10.114.102 k8s-rke2-worker02
10.10.114.103 k8s-rke2-worker03
EOF
#常用软件包安装
dnf -y install epel-release
dnf -y install lrzsz vim gcc glibc openssl openssl-devel net-tools http-tools wget curl yum-utils telnet
dnf-y update
关闭swap分区
swapoff -a
修改/etc/fstab配置文件,把swap分区挂载的那一行注释掉
vim /etc/fstab
参考:
echo "
net.bridge.bridge-nf-call-ip6tables=1
net.bridge.bridge-nf-call-iptables=1
net.ipv4.ip_forward=1
f.all.forwarding=1
_thresh1=4096
_thresh2=6144
_thresh3=8192
_interval=60
_stale_time=120# 参考
kernel.perf_event_paranoid=-1#sysctls for k8s node config
p_slow_start_after_idle=0
_max=16777216
fs.inotify.max_user_watches=524288
kernel.softlockup_all_cpu_backtrace=1kernel.softlockup_panic=0kernel.watchdog_thresh=30
fs.file-max=2097152
fs.inotify.max_user_instances=8192
fs.inotify.max_queued_events=16384
vm.max_map_count=262144
fs.may_detach_mounts=1
dev_max_backlog=16384
p_wmem=4096 12582912 16777216
wmem_max=16777216
somaxconn=32768
net.ipv4.ip_forward=1
p_max_syn_backlog=8096
p_rmem=4096 12582912 f.all.disable_ipv6=1
f.default.disable_ipv6=1
f.lo.disable_ipv6=1kernel.yama.ptrace_scope=0
vm.swappiness=0# 可以控制core文件的文件名中是否添加pid作为扩展。
_uses_pid=1# Do not accept source routing
f.default.accept_source_route=0
f.all.accept_source_route=0# Promote secondary addresses when the primary address is removed
f.default.promote_secondaries=1
f.all.promote_secondaries=1# Enable hard and soft link protection
fs.protected_hardlinks=1
fs.protected_symlinks=1# 源路由验证
# see details in .html
f.all.rp_filter=0
f.default.rp_filter=0
f.default.arp_announce = 2
f.lo.arp_announce=2
f.all.arp_announce=2# see details in .html
p_max_tw_buckets=5000
p_syncookies=1
p_fin_timeout=30
p_synack_retries=2
kernel.sysrq=1" >> /f
modprobe br_netfilter
sysctl -p
cat >> /etc/f <<EOF
* soft nofile 65535
* hard nofile 65536
EOF
如果使用NetworkManager管理网络,需要进行如下配置
参考:
systemctl status NetworkManager
cat >> /etc/NetworkManager/conf.f << EOF
[keyfile]
unmanaged-devices=interface-name:cali*;interface-name:flannel*
EOF
systemctl daemon-reload
systemctl restart NetworkManager
#关闭firewalld
systemctl stop firewalld
systemctl disable firewalld
systemctl disable iptables
systemctl stop iptables
#关闭selinux
getenforce
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
getenforce
yum -y install chrony
mv /f /f_bak
cat > /f <<EOF
pool ntp.aliyun iburst
pool ntp1.aliyun iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
keyfile /etc/chrony.keys
leapsectz right/UTC
logdir /var/log/chrony
EOFsystemctl enable chronyd
systemctl restart chronyd
timedatectl status
chronyc sources -v
以上设置完成后,重启主机,确认所有配置都已经生效。
设置一个 HA 集群需要以下步骤:
参考:/
注意:由于主机有限,我们就把第一个启动的节点设置为注册地址,下面只进行2、3步骤。
rke2版本信息:
使用国内镜像地址下载启动脚本
在每个节点都执行下面的脚本
参考:
wget .sh
INSTALL_RKE2_CHANNEL=stable
INSTALL_RKE2_TYPE=server
# INSTALL_RKE2_VERSION=v1.26.10+rke2r2
/bin/bash install.sh# 执行完之后执行命令,如下
# rke2 --version
rke2 version v1.26.10+rke2r2 (21e3a8c82da71473f2b846065dcab197a9b2c9d8)
go version go1.20.10 X:boringcrypto
#上面主要是下载一些必要的安装包
systemctl start rke2-server
systemctl enable rke2-server
# 第一次启动可能会比较慢,因为要初始化、生成各种文件
#查看第一次启动后生成的文件
ll /var/lib/rancher/rke2/
ll /var/lib/rancher/rke2/bin/
ll /etc/rancher/rke2/
本文发布于:2024-02-01 19:48:06,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170678808839033.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |