一台是阿里云,一台是腾讯云,一台是华为云,一台是百度云等多种公有云混合安装K8S集群

1. 修改主机名称和添加hosts

bash 复制代码
#永久修改主机名
hostnamectl set-hostname  master  && bash     #在master01上操作,阿里云服务器
hostnamectl set-hostname  worker1   && bash   #在node01上操作,阿里腾讯云服务器
hostnamectl set-hostname  worker2   && bash   #在node02上操作,华为云服务器
bash 复制代码
cat >> /etc/hosts << EOF
202.168.216.25    master
198.201.73.25    worker1
49.58.173.125    worker2
EOF

2.系统优化

bash 复制代码
#时间同步:
yum install epel-release  -y
yum install ntpdate -y
ntpdate time.windows.com
bash 复制代码
#修改内核参数
cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF

cat >>  /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

modprobe br_netfilter #加载br_netfilter模块
lsmod |grep br_netfilter #验证模块是否加载成功
sysctl -p /etc/sysctl.d/k8s.conf  #使刚才修改的内核参数生效
bash 复制代码
systemctl stop firewalld # 关闭
systemctl disable firewalld # 禁止开机启动防火墙
sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久
setenforce 0 # 临时
bash 复制代码
yum install -y yum-utils device-mapper-persistent-data lvm2 wget curl

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
    

#yum list docker-ce --showduplicates | sort -r #查看yum仓库中可以安装的docker版本
#yum -y install docker-ce-18.06.1.ce-3.el7 #安装指定的版本
yum -y install docker-ce docker-ce-cli containerd.io #安装最新docker
systemctl enable docker
systemctl start docker
docker --version

cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://qj799ren.mirror.aliyuncs.com","https://4c99aa72f1a643edb02b13b93fec6a17.mirror.swr.myhuaweicloud.com"],
  "insecure-registries": ["0.0.0.0/0"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF
systemctl restart docker
systemctl status docker

3.rancher安装

bash 复制代码
#在master01上操作,阿里云服务器上安装rancher
docker run -d --name rancher_server --restart=unless-stopped --privileged   -p 8080:80 -p 8443:443 -v /rancher/rancher:/var/lib/rancher    rancher/rancher:v2.4.17 

浏览器访问 https://202.168.216.25:8443

4. 参考博客第5步以后继续操作

点击阅读

相关推荐
MX_93596 分钟前
阿里云参数配置化
阿里云·云计算
不久之13 小时前
大数据服务完全分布式部署- 其他组件(阿里云版)
分布式·阿里云·云计算
豆芽脚脚2 天前
docker compose再阿里云上无法使用的问题
阿里云·docker·容器
ciku2 天前
Spring AI 集成阿里云百炼平台
人工智能·spring·阿里云
Agome992 天前
Docker之自定义jkd镜像上传阿里云
阿里云·docker·容器
是乐谷3 天前
阿里云杭州 AI 产品法务岗位信息分享(2025 年 8 月)
java·人工智能·阿里云·面试·职场和发展·机器人·云计算
玩转以太网3 天前
3 种方式玩转网络继电器!W55MH32 实现网页 + 阿里云 + 本地控制互通
网络·物联网·阿里云
熊猫钓鱼>_>6 天前
腾讯云EdgeOne KV存储在游戏资源发布中的技术实践与架构解析
游戏·架构·腾讯云
百胜软件@百胜软件7 天前
百胜软件×华为云联合赋能,“超级国民品牌”海澜之家新零售加速前行
大数据·华为云·零售