一台是阿里云,一台是腾讯云,一台是华为云,一台是百度云等多种公有云混合安装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步以后继续操作

点击阅读

相关推荐
2401_861678621 小时前
阿里云远程连接
阿里云·云计算
迪康coolmu2 小时前
企业文件外发防泄漏实践:从通道封堵到三层全链路管控
大数据·运维·网络·人工智能·安全·阿里云
tg_xianheyun2 天前
阿里云国际账号注册代充值怎么选服务商?
服务器·阿里云·云计算·全球访问优化
翼龙云_cloud2 天前
腾讯云国际代理商:CDB数据库自动备份和异地灾备配置 从快照到跨区域恢复
运维·数据库·云计算·腾讯云
Debug 熊猫2 天前
【环境变量中阿里云通义API认证失败】WebClientResponseException$Unauthorized: 401 Unauthorized
阿里云·云计算
故乡dee云3 天前
华为云国际服务器连不上怎么办?安全组、端口、IP 和网络排查方法
服务器·网络·华为云
真上帝的左手3 天前
19. 大数据- 湖仓一体&BI - 阿里云实践
大数据·阿里云·云计算
小新讲网安4 天前
云安全攻防实战:AWS与阿里云渗透测试全流程指南
安全·web安全·网络安全·阿里云·自动化·云计算·aws
行业研究员4 天前
腾讯云ADP:智能体平台封神榜
人工智能·microsoft·腾讯云·智能体·智能体平台·腾讯云adp