Kubernetes集群( 二 )

$ vi /etc/keepalived/keepalived.conf>>global_defs {router_id LVS_DEVEL}vrrp_script chk_apiserver {script "/etc/keepalived/check_apiserver.sh"interval 2weight-5fall3rise2}vrrp_instance VI_1{stateMASTER # 一主(MASTER)两从(BACKUP)interfaceens33mcast_src_ip192.168.2.200 #所在主机IP 192.168.2.200、192.168.2.201、192.168.2.202virtual_router_id51priority100# 需修改100、101、102advert_int2authentication {auth_typePASSauth_passK8S}virtual_ipaddress {192.168.2.205}#track_script {#chk_apiserver# }}# k8s-master01、k8s-master02、k8s-master03配置健康检查$ vi /etc/keepalived/check_apiserver.sh>># !/bin/basherr=0for k in $(seq 1 5)docheck_code=$(pgrep kube-apiserver)if [[ $check_code == "" ]]; thenerr=$(expr $err + 1)sleep 5continueelseerr=0breakfidoneif [[ $err != "0" ]]; thenecho "systemctl stop keepalived"/usr/bin/systemctl stop keepalivedexit 1elseexit 0fi# 启动haproxy和keepalivedsystemctl enable --now haproxysystemctl enable --now keepalivedKubeadm集群初始化# 只有master01和初始化的时候才使用$ vi kubeadm-config.yaml


【Kubernetes集群】


推荐阅读