標籤(空格分隔): kubernetes系列html
一: kubernetes master 節點的 高可用node
二: 配置nginx 服務器linux
- 三: 配置nginx 的LB 的 keepalived 高可用
kubernetes 的多master集羣架構 kubernetes 高可用主要在於apiserver
部署master01 IP 地址: 192.168.100.12 在 192.168.100.12 部署與 master01 同樣的 服務 scp -r /opt/kubernetes/ root@192.168.100.12:/opt/ scp -r /opt/etcd/ root@192.168.100.12:/opt/ scp /usr/bin/kubectl root@192.168.20.12:/usr/bin/ scp /usr/lib/systemd/system/kube-* root@192.168.100.12:/usr/lib/systemd/system/
修改 配置文件 cd /opt/kubernetes/cfg vim kube-apiserver --- --bind-address=192.168.100.12 --advertise-address=192.168.100.12
啓動服務: service kube-apiserver start service kube-controller-manager start service kube-scheduler start
login : 192.168.20.12 kubectl get cs
nginx 服務器 地址: 192.168.100.15 nginx 的yum 包地址 http://nginx.org/en/linux_packages.html cd /etc/yum.repos.d/ vim nginx.repo --- [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key ---
yum install nignx
cd /etc/nginx/ vim nginx.conf 增長: --- stream { log_format main "$remote_addr $upstream_addr $time_local $status"; access_log /var/log/nginx/k8s-access.log main; upstream k8s-apiserver { server 192.168.100.11:6443; server 192.168.100.12:6443; } server { listen 192.168.100.15:6443; proxy_pass k8s-apiserver; } }
修改node 節點的 master 服務器指向 login : 192.168.20.13 cd /opt/kubernetes/cfg/ vim bootstrap.kubeconfig --- server: https://192.168.100.11:6443 改爲: server: https://192.168.100.15:6443 --- vim kubelet.kubeconfig ---- server: https://192.168.100.11:6443 改爲: server: https://192.168.100.15:6443 ---- vim kube-proxy.kubeconfig ---- server: https://192.168.100.11:6443 改爲: server: https://192.168.100.15:6443 ---- scp bootstrap.kubeconfig kubelet.kubeconfig kube-proxy.kubeconfig root@192.168.100.14:/opt/kubernetes/cfg/
從新啓動 node 節點的 kubelet 和 kube-proxy service kubelet restart service kube-proxy restart
使用 主節點 配置 測試 kubectl get nodes
login 192.168.100.16 安裝nginx 服務器 同上 192.168.100.15 同樣 修改 : vim /etc/nginx/nginx.conf ---- stream { log_format main "$remote_addr $upstream_addr $time_local $status"; access_log /var/log/nginx/k8s-access.log main; upstream k8s-apiserver { server 192.168.100.11:6443; server 192.168.100.12:6443; } server { listen 192.168.100.16:6443; proxy_pass k8s-apiserver; } } --- service nginx start
配置keepalive 高可用 yum install keepalived keepalived 的配置文件 cd /etc/keepalived/ vim keepalived.conf --- ! Configuration File for keepalived global_defs { # 接收郵件地址 notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } # 郵件發送地址 notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id NGINX_MASTER } vrrp_script check_nginx { script "/etc/keepalived/check_nginx.sh" } vrrp_instance VI_1 { state MASTER interface ens33 virtual_router_id 51 # VRRP 路由 ID實例,每一個實例是惟一的 priority 100 # 優先級,備192.168.100.16服務器設置 90 advert_int 1 # 指定VRRP 心跳包通告間隔時間,默認1秒 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.100.70/24 } track_script { check_nginx } } ---- 配置 檢查 nginx 進程 檢查 cd /etc/keepalived/ vim check_nginx.sh --- #!/bin/bash count=$(ps -ef |grep nginx |egrep -cv "grep|$$") if [ "$count" -eq 0 ];then /etc/init.d/keepalived stop fi ---
service keepalived start ps -ef |grep keepalived
cd /etc/keepalived scp check_nginx.sh keepalived.conf root@192.168.100.16:/etc/keepalived/
login: 192.168.100.16 cd /etc/keepalived/ vim keepalived.conf --- 改 priority 100 爲 priority 90 ---- serivice keepalived start ps -ef |grep keepalived
改 node 節點的 IP 地址 修改node 節點的 master 服務器指向 login : 192.168.20.13 cd /opt/kubernetes/cfg/ vim bootstrap.kubeconfig --- server: https://192.168.100.15:6443 改爲: server: https://192.168.100.70:6443 --- vim kubelet.kubeconfig ---- server: https://192.168.100.15:6443 改爲: server: https://192.168.100.70:6443 ---- vim kube-proxy.kubeconfig ---- server: https://192.168.100.15:6443 改爲: server: https://192.168.100.70:6443 ---- scp bootstrap.kubeconfig kubelet.kubeconfig kube-proxy.kubeconfig root@192.168.100.14:/opt/kubernetes/cfg/
從新啓動 node 節點的 kubelet 和 kube-proxy service kubelet restart service kube-proxy restart
login: 192.168.100.15 修改 nginx 的 配置文件 cd /etc/nginx/ vim nginx.conf ---- 將linsten 192.168.100.15:6443 改成: 0.0.0.0:6443 ---- service nginx restart
login: 192.168.100.16 修改 nginx 的 配置文件 cd /etc/nginx/ vim nginx.conf ---- 將linsten 192.168.100.16:6443 改成: 0.0.0.0:6443 ---- service nginx restart
去master01 節點上面查看 kubectl get svc kubectl get svc,pods -n kube-system --all-namespaces
去master02 節點上面查看 kubectl get svc kubectl get svc,pods -n kube-system --all-namespaces