1. 修改主机名称和添加hosts
hostnamectl set-hostname master && bash
hostnamectl set-hostname worker1 && bash
hostnamectl set-hostname worker2 && bash
cat >> /etc/hosts << EOF
202.168.216.25 master
198.201.73.25 worker1
49.58.173.125 worker2
EOF
2.系统优化
yum install epel-release -y
yum install ntpdate -y
ntpdate time.windows.com
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
lsmod |grep br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config
setenforce 0
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 -y install docker-ce docker-ce-cli containerd.io
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安装
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步以后继续操作
点击阅读