环境

序号主机系统作用版本
1192.168.3.111centos7.9最小化K8S-master1.23.1
2192.168.3.112centos7.9最小化k8s-node1.23.1
3192.168.3.113centos7.9最小化k8s-node1.23.1
4192.168.3.71centos7.9最小化rancher2.6.4

一、rancher安装

1、环境准备

关闭防火墙及selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl stop firewalld ; systemctl disable firewalld
reboot

修改内核参数

modprobe br_netfilter
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
sysctl -p /etc/sysctl.d/k8s.conf

修改yum源

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 https://mirrors.aliyun.com/repo/Centos-7.repo
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装软件包

yum install -y vim net-tools bash-completion wget lrzsz gcc gcc-c++ make \
cmake libxml2-devel openssl-devel curl-devel unzip libaio-devel ncurses-devel \
autoconf automake python-devel openssh-server socat ipvsadm conntrack

2、安装docker

yum install docker-ce -y
systemctl daemon-reload
systemctl start docker && systemctl enable docker.service

配置镜像加速器

tee /etc/docker/daemon.json << 'EOF'
{
"registry-mirrors":["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://dockerhub.azk8s.cn","http://hub-mirror.c.163.com","http://qtid6917.mirror.aliyuncs.com", "https://rncxm540.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
systemctl status docker

3、安装rancher

下载镜像

docker pull rancher/rancher:v2.6.4
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:v2.6.4
docker ps | grep rancher

docker logs b2a2b89efe1a
docker logs  b2a2b89efe1a  2>&1 | grep "Bootstrap Password:"

 http://192.168.3.71

 

 

 192.168.3.111   192.168.3.112  192.168.3.113

docker pull rancher/rancher-agent:v2.6.4

4、rancher管理k8s

 

 

192.168.3.111

curl --insecure -sfL https://192.168.3.71/v3/import/5w8gpfm8wxh4gv2lzm49gvcjstg8msjmkfhgj5kkccjmdrzrjm5k4m_c-m-7wxr5fm2.yaml | kubectl apply -f -
kubectl get pods -n cattle-system

 

 5、创建资源

deployment

 

 创建service

 

访问     https://192.168.3.111:32090

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐