您好,登錄后才能下訂單哦!
地址sealos, 讓kubernetes高可用不再需要keepalived haproxy和ansible,sealyun定制超級版kubeadm通過ipvs代理多個master,優雅解決k8s高可用問題。
ip role 10.103.97.200 master0 10.103.97.201 master0 10.103.97.202 master0 10.103.97.2 virtulIP
apiserver.cluster.local apiserver解析名
在每個節點上初始化
tar zxvf kube1.14.0.tar.gz && cd kube/shell && sh init.sh
用下載的kubeadm替換掉包內的kubeadm:
cp kubeadm /usr/bin/kubeadm
cat kubeadm-config.yaml :
apiVersion: kubeadm.k8s.io/v1beta1 kind: ClusterConfiguration kubernetesVersion: v1.14.0 controlPlaneEndpoint: "apiserver.cluster.local:6443" # 使用解析名去訪問APIserver apiServer: certSANs: - 127.0.0.1 - apiserver.cluster.local - 172.20.241.205 - 172.20.241.206 - 172.20.241.207 - 172.20.241.208 - 10.103.97.2 # 虛擬IP等都加入到證書中 --- apiVersion: kubeproxy.config.k8s.io/v1alpha1 kind: KubeProxyConfiguration mode: "ipvs" ipvs: excludeCIDRs: - "10.103.97.2/32" # 如果不加這個k8s會定時清理用戶創建的IPVS規則,導致代理失敗
在 master0 10.103.97.200 上
echo "10.103.97.200 apiserver.cluster.local" >> /etc/hosts kubeadm init --config=kubeadm-config.yaml --experimental-upload-certs mkdir ~/.kube && cp /etc/kubernetes/admin.conf ~/.kube/config kubectl apply -f https://docs.projectcalico.org/v3.6/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml # 安裝calico
執行完會輸出一些日志,里面包含join需要用的 命令
在 master1 10.103.97.201 上
# 注意,在安裝之前解析到master0, 安裝成功后解析改成自己,因為kubelet kube-proxy配置的都是這個解析名,如果不改解析master0宕機整個集群就不可用了 echo "10.103.97.200 apiserver.cluster.local" >> /etc/hosts kubeadm join 10.103.97.200:6443 --token 9vr73a.a8uxyaju799qwdjv \ --discovery-token-ca-cert-hash sha256:7c2e69131a36ae2a042a339b33381c6d0d43887e2de83720eff5359e26aec866 \ --experimental-control-plane \ --certificate-key f8902e114ef118304e561c3ecd4d0b543adc226b7a07f675f56564185ffe0c07 sed "s/10.103.97.200/10.103.97.201/g" -i /etc/hosts # 解析改也自己本機地址
在 master2 10.103.97.202 上,同master1
echo "10.103.97.200 apiserver.cluster.local" >> /etc/hosts kubeadm join 10.103.97.200:6443 --token 9vr73a.a8uxyaju799qwdjv \ --discovery-token-ca-cert-hash sha256:7c2e69131a36ae2a042a339b33381c6d0d43887e2de83720eff5359e26aec866 \ --experimental-control-plane \ --certificate-key f8902e114ef118304e561c3ecd4d0b543adc226b7a07f675f56564185ffe0c07 sed "s/10.103.97.200/10.103.97.201/g" -i /etc/hosts
通過虛擬IP join到master上, 這個 命令 會在node節點上創建一條ipvs規則,virturl server就是虛擬IP, realserver就是三個master。 然后再以一個static pod起一個守護進程守護這些規則,一旦哪個apiserver不可訪問了就清除realserver, apiserver通了之后再次添加回來
echo "10.103.97.2 apiserver.cluster.local" >> /etc/hosts # using vip kubeadm join 10.103.97.2:6443 --token 9vr73a.a8uxyaju799qwdjv \ --master 10.103.97.200:6443 \ --master 10.103.97.201:6443 \ --master 10.103.97.202:6443 \ --discovery-token-ca-cert-hash sha256:7c2e69131a36ae2a042a339b33381c6d0d43887e2de83720eff5359e26aec866 Architecture
+----------+ +---------------+ virturl server: 10.103.97.2:6443 | mater0 |< ----------------------| ipvs nodes | real servers: +----------+ |+---------------+ 10.103.97.200:6443 | 10.103.97.201:6443 +----------+ | 10.103.97.202:6443 | mater1 |<---------------------+ +----------+ | | +----------+ | | mater2 |<---------------------+ +----------+
集群每個node節點都會創建一條ipvs規則用于代理所有的master節點。類似kube-proxy的ipvs實現。
然后起一個守護進程就健康檢查
apiservers /etc/kubernetes/manifests/sealyun-lvscare.yaml
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。