Rke集群
172.19.0.4
centos7.x
172.19.0.9
centos7.x
172.19.0.12
centos7.x
1、初始化所有节点环境
cat init_rke_env.sh🤗
## 桥接的IPv4流量传递到iptables的链
cat > /etc/sysctl.conf << EFO
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EFO
## 生效
sysctl -p /etc/sysctl.conf
## 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
## 关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config
setenforce 0 # 临时
## 关闭swap
swapoff -a && sed -ri 's/.*swap.*/#&/' /etc/fstab
## 时间同步
yum install ntpdate -y
ntpdate time.windows.com
## 删除已安装的Docker
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
## 配置repo源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum -y install epel-release
## 显示软件包的多个版本
yum list docker --show-duplicates
## 安装依赖包
yum -y install yum-utils device-mapper-persistent-data lvm2
## 添加软件源信息
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
## 更新并安装Docker-CE
yum makecache fast
yum list docker-ce --show-duplicates
yum -y install docker-ce-24.0.7-1.el7
## 更新xfsprogs
yum -y update xfsprogs
## 启动,设置开机启动
systemctl enable docker
systemctl start docker
## 检查
docker info
docker -v
## 添加 rke 用户, 添加到 docker 组
useradd rke
usermod -aG docker rke
echo "rke" |passwd rke --stdin
#passwd rancher
# 修改ulimit参数
cp /etc/security/limits.conf /etc/security/limits.conf.bak
cat >>/etc/security/limits.conf <<EOF
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
EOF
echo "ulimit -SHn 65535" >> /etc/profile
echo "ulimit -SHn 65535" >> /etc/rc.local
reboot2、部署集群(主节点执行)
返回的最后一行信息应该是 Finished building Kubernetes cluster successfully,表示成功部署集群,可以开始使用集群。在创建 Kubernetes 集群的过程中,会创建一个kubeconfig 文件,它的文件名称是 kube_config_cluster.yml,您可以使用它控制 Kubernetes 集群。
记得保存好你的集群文件
3、安装 kubectl(主节点执行)
加载k8s环境
查看节点
4、发布应用测试
5、存储相关
OpenEBS: https://weiliang-ms.github.io/wl-awesome/2.%E5%AE%B9%E5%99%A8/k8s/storage/OpenEBS.html
Rook-Ceph: https://weiliang-ms.github.io/wl-awesome/2.%E5%AE%B9%E5%99%A8/k8s/storage/rook.html
6、集群更新(增加节点、删除节点)
1、初始化新节点、设置免密(不能是root)
2、修改cluster.yml文件的内容,添加(删除)额外的节点,并指定它们在 Kubernetes 集群中的角色
3、rke up --update-only (可能会触发插件或其他组件的重新部署或更新)
6、备份和恢复
注: 上面我们设置了备份策略,每5分钟备份一次,保存时长 24 小时,默认是保存到: /opt/rke/etcd-snapshots
官网详细内容: https://docs.rancher.cn/docs/rke/etcd-snapshots/one-time-snapshots/_index/
手动备份到本地
手动备份到 S3 (minio)
从本地快照恢复集群
从S3 (minio)快照恢复集群
7、千万注意
千万不要执行: rke remove😲 , 会删除所有数据和备份数据 (除非你做了二次备份)
8、Rancher控制面板😁
尽量不在master 和 worker运行: 耗费资源, 最好单独搞台集群去弄
Last updated