01_安装负载均衡器
负载均衡器最好也部署成高可用(主/备),可参考本文中的nginx高可用部分内容 https://cloud.tencent.com/developer/article/1633991
1.配置 nginx官方的 Yum 源
负载均衡需要stream模块,所以本次安装最新1.18版本nginx
vim /etc/yum.repos.d/nginx.repo
添加如下内容:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
2.安装最新 nignx
yum -y install nginx
3.配置 nginx
[root@rancher-slb ~]# cd /etc/nginx
[root@rancher-slb ~]# rm -rf conf.d
[root@rancher-slb ~]# mv nginx.conf nginx.conf.bak
创建nginx.conf
[root@rancher-slb ~]# vim /etc/nginx/nginx.conf
把下面内容加入
worker_processes 4;
worker_rlimit_nofile 40000;
events {
worker_connections 8192;
}
stream {
upstream rancher_servers_http {
least_conn;
server 172.16.7.201:80 max_fails=3 fail_timeout=5s;
server 172.16.7.202:80 max_fails=3 fail_timeout=5s;
server 172.16.7.203:80 max_fails=3 fail_timeout=5s;
}
server {
listen 80;
proxy_pass rancher_servers_http;
}
upstream rancher_servers_https {
least_conn;
server 172.16.7.201:443 max_fails=3 fail_timeout=5s;
server 172.16.7.202:443 max_fails=3 fail_timeout=5s;
server 172.16.7.203:443 max_fails=3 fail_timeout=5s;
}
server {
listen 443;
proxy_pass rancher_servers_https;
}
}
4.启动 nginx
systemctl start nginx && systemtl enable nginx
5.打开防火墙端口
80/443
----------------------其它,下面内容不需要安装---------------------------------------------
1、在nginx机器安装helm
1.1 helm安装包下载
https://github.com/helm/helm/releases
在页的Installation and Upgrading下(如图),复制下载链接或直接点击下载
https://get.helm.sh/helm-v3.4.1-linux-amd64.tar.gz
1.2 在线下载并安装
[root@rancher0 ~]# wget https://get.helm.sh/helm-v3.4.1-linux-amd64.tar.gz \
&& tar xf helm-v3.0.3-linux-amd64.tar.gz \
&& cd linux-amd64 \
&& mv helm /usr/sbin/