Rancher2.0搭建kubernetes(K8S)集群

Rancher2.0搭建kubernetes(K8S)集群 一、环境准备4台都执行如下命令1.准备至少4台CentOS7版本服务器# IP地址 主机名称172.16.0.75 rancher 172.16.0.76 master 172.16.0.77 node1 172.16.0.78 node22.每台虚拟机上需要做的配置1.安装Dockeryum install -y docker2.设置hostname主机名hostnamectl --static set-hostname rancher hostnamectl --static set-hostname master hostnamectl --static set-hostname node1 hostnamectl --static set-hostname node23.设置host域名映射vim /etc/hosts# 粘贴配置172.16.0.75 rancher 172.16.0.76 master 172.16.0.77 node1 172.16.0.78 node24.关闭防火墙systemctl disable firewalld.service systemctl stop firewalld.service5.开启docker,可以不执行默认docker已启动systemctl start docker到这里准备工作已完成二、搭建rancher在你主机名rancher上执行不建议rancher和master配置在同一台机器上1.使用docker安装rancherdocker run -d --restartunless-stopped -p 80:80 -p 443:443 rancher/rancher:stable 如果上面报错使用docker logs -f 容器id 查看容器错误日志 , 使用下面特权模式执行 docker run --privileged -d --restartunless-stopped -p 80:80 -p 443:443 rancher/rancher:stable2.查看rancher容器是否安装完成启动docker ps3.访问rancherhttps://120.55.81.46/dashboard默认用户名是admin,密码通过登录页面提示的命令去服务器日志中查询到这里rancher已经安装完成三、新建集群设置需要扩展的主节点和工作节点1. 只有master节点需要勾选etcd,Controlworker然后copy对应命令到主节点服务器执行2. 其他node节点只需勾选worker然后copy对应命令到主节点服务器执行四、部署Nginx端口映射选择节点端口自动生成对应service通过节点外网ip直接访问nginxnginx 访问地址Welcome to nginx!http://120.26.78.224:30008/