![](https://img.haomeiwen.com/i19317302/ca30cfc22b6619da.png)
服务器centos7
master1 172.16.20.53
master2 172.16.20.54
SLB+Mysql 172.16.20.57(真实生产建议分开)
系统初始化跳过(firewalld,selinux,ntpdate,hostname)
mysql5.7部署跳过,安装完毕创建一个库,例如:k8sdb
mater1和master2操作
curl -sfL https://docs.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -s - server --datastore-endpoint="mysql://root:123456@tcp(172.16.20.57:3306)/k8sdb"
![](https://img.haomeiwen.com/i19317302/898929caf7f6c86a.png)
查看系统信息
kubectl get nodes
kubectl get pods -A
![](https://img.haomeiwen.com/i19317302/a8b786c231da02fb.png)
![](https://img.haomeiwen.com/i19317302/7631d0d7fc7d54d5.png)
在master1操作
下载helm
wget https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz
tar -zxf helm-v3.2.4-linux-amd64.tar.gz
cp linux-amd64/helm /usr/local/bin/
chmod +x /usr/local/bin/helm
使用helm repo add命令添加含有 Rancher Chart 的 Helm Chart 仓库
helm repo add rancher-stable http://rancher-mirror.oss-cn-beijing.aliyuncs.com/server-charts/stable
为rancher创建命名空间
kubectl create namespace cattle-system
增加SSL认证,从阿里云申请免费的SSL证书,上传至服务器,然后执行
kubectl -n cattle-system create secret tls tls-rancher-ingress --cert=./4146911_rancher.pharmdfzx.com.pem --key=./4146911_rancher.pharmdfzx.com.key
helm install rancher rancher-stable/rancher --namespace cattle-system --set hostname=rancher.pharmdfzx.com --set ingress.tls.source=secret
验证 Rancher Server 是否已成功部署
kubectl -n cattle-system rollout status deploy/rancher
![](https://img.haomeiwen.com/i19317302/ccc89bd03c291b73.png)
负载均衡nginx配置
![](https://img.haomeiwen.com/i19317302/1e4a765d0f9f3053.png)
使用容器部署
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /etc/localtime:/etc/localtime -v /etc/nginx.conf:/etc/nginx/nginx.conf nginx:1.14
本地windows里hosts增加域名解析
172.16.20.57 rancher.pharmdfzx.com
然后直接访问
![](https://img.haomeiwen.com/i19317302/e07bb0d1413bead6.png)
![](https://img.haomeiwen.com/i19317302/b30203e388934e7e.png)
使用的外置mysql,这里显示etcd不适用
![](https://img.haomeiwen.com/i19317302/79e3d29e7a59a6b8.png)
关闭20.54服务器模拟故障
![](https://img.haomeiwen.com/i19317302/819969e2709cb985.png)
![](https://img.haomeiwen.com/i19317302/f5a1f2467d4077e4.png)
网友评论