kubeadm 线上集群部署(二) apiserver高可用部署方案
在nginx01上安装git
请确保nginx01能免秘钥登录nginx02
yum install -y git git clone https://github.com/qq676596084/ansible-playbook.git cd ansible-playbook/Keeplived-Nginx
修改host文件
vim hosts
# This is the default ansible 'hosts' file. [master] 172.16.100.251 [backup] 172.16.100.252 [nginx] 172.16.100.251 172.16.100.252
修改变量vim group_vars/all 没有特别说明的无需修改参数,默认即可
# The global variable file mongodb installation MASTER: "MASTER" BACKUP: "BACKUP" PRIOTIRY_MASTER: "100" PRIOTIRY_BACKUP: "90" VIRTUAL_ROUTE_ID: "80" # VIP地址,因部署在腾讯云上,需要在私有网络申请VIP地址,如果找不到可以提交工单申请 VIRTUAL_IP: "172.16.100.254" AUTH_TYPE: "pass" AUTH_PASS: "awzhXylxy.T" ROUTE_ID: "HA_K8S" # master/backup网卡请保持一致 INTERFACE: "eth0"
修改nginx配置
vim roles/nginx/files/nginx.conf
worker_processes auto; user root; events { worker_connections 65535; use epoll; } error_log /var/log/nginx_error.log info; stream { upstream kube-servers { hash consistent;
server 172.16.100.31:6443 weight=6 max_fails=1 fail_timeout=10s;
server 172.16.100.32:6443 weight=6 max_fails=1 fail_timeout=10s;
server 172.16.100.33:6443 weight=6 max_fails=1 fail_timeout=10s;
server 172.16.100.34:6443 weight=6 max_fails=1 fail_timeout=10s;
server 172.16.100.35:6443 weight=6 max_fails=1 fail_timeout=10s; } server { listen 8443; proxy_connect_timeout 30s; proxy_timeout 60s; proxy_pass kube-servers; } }
执行ansible-playbook
ansible-playbook -i hosts site.yml