@zhangyy
2021-04-12T16:34:18.000000Z
字数 2529
阅读 168
rancher系列
- 一: 环境说明:
- 二:部署准备:
# 操作系统:centos7
# docker版本:19.03.5
# rancher版本: latest
# rancher server 节点IP :192.168.100.11
# rancher agent节点IP: 192.168.100.12
# K8S master 节点IP:192.168.100.11---192.168.100.14
# K8S worker节点IP: 192.168.100.11---192.168.100.14
# K8S etcd 节点IP:192.168.100.11--192.168.100.13
# 操作在所有节点进行
# 修改内核参数:
关闭swap
vim /etc/sysctl.conf
vm.swappiness=0
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
sysctl -p
临时生效
swapoff -a && sysctl -w vm.swappiness=0
# 修改 fstab 不在挂载 swap
vi /etc/fstab
# /dev/mapper/centos-swap swap swap defaults 0 0
# 安装docker
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 添加docker配置
mkdir -p /etc/docker
vim /etc/docker/daemon.json
{
"max-concurrent-downloads": 20,
"data-root": "/opt/docker/data",
"exec-root": "/opt/docker/root",
"registry-mirrors": ["https://fy707np5.mirror.aliyuncs.com"],
"log-driver": "json-file",
"bridge": "docker0",
"oom-score-adjust": -1000,
"debug": false,
"log-opts": {
"max-size": "100M",
"max-file": "10"
},
"default-ulimits": {
"nofile": {
"Name": "nofile",
"Hard": 1024000,
"Soft": 1024000
},
"nproc": {
"Name": "nproc",
"Hard": 1024000,
"Soft": 1024000
},
"core": {
"Name": "core",
"Hard": -1,
"Soft": -1
}
}
}
# 安装依赖
yum install -y yum-utils ipvsadm telnet wget net-tools conntrack ipset jq iptables curl sysstat libseccomp socat nfs-utils fuse fuse-devel
# 安装docker依赖
yum install -y python-pip python-devel yum-utils device-mapper-persistent-data lvm2
# 安装docker
yum install -y docker-ce
# reload service 配置
systemctl daemon-reload
# 重启docker
systemctl restart docker
# 设置开机启动
systemctl enable docker
#自动加载ipvs 创建开机加载
cat << EOF > /etc/sysconfig/modules/ipvs.modules
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4
EOF
# /etc/sysconfig/modules/ipvs.modules 可执行权限
chmod +x /etc/sysconfig/modules/ipvs.modules
# 执行 /etc/sysconfig/modules/ipvs.modules
/etc/sysconfig/modules/ipvs.modules
# 操作IP: 192.168.100.11
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:latest
# 等待镜像拉取完成启动好容器
打开浏览器输入:192.168.100.11 浏览器会自动跳转到https选择 继续前往192.168.100.11(不安全)
kubeproxy:
extra_args:
proxy-mode: "ipvs"
配置 kube-proxy 数据转发模式 这里我修改为IPVS 模式当然如果默认是iptables 配置完成选择下一步
sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.4.3 --server https://192.168.100.11 --token 4q66cvt6gdmqb2nc76jlt6g884lnpfrppz5fb42d2qzxbq5pftwp8n --ca-checksum bb0a1bc022960b372681aef2888dac5770e546bce82c69e77b1e1d0604a8490b --etcd --controlplane --worker