地址sealos, 讓kubernetes高可用不再需要keepalived haproxy和ansible,sealyun定制超級(jí)版kubeadm通過(guò)ipvs代理多個(gè)master,優(yōu)雅解決k8s高可用問(wèn)題。
成都創(chuàng)新互聯(lián)專(zhuān)注于羅定企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,成都做商城網(wǎng)站。羅定網(wǎng)站建設(shè)公司,為羅定等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站,專(zhuān)業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)專(zhuān)業(yè)和態(tài)度為您提供的服務(wù)
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解析名
在每個(gè)節(jié)點(diǎn)上初始化
tar zxvf kube1.14.0.tar.gz && cd kube/shell && sh init.sh
用下載的kubeadm替換掉包內(nèi)的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" # 使用解析名去訪問(wèn)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等都加入到證書(shū)中 --- apiVersion: kubeproxy.config.k8s.io/v1alpha1 kind: KubeProxyConfiguration mode: "ipvs" ipvs: excludeCIDRs: - "10.103.97.2/32" # 如果不加這個(gè)k8s會(huì)定時(shí)清理用戶創(chuàng)建的IPVS規(guī)則,導(dǎo)致代理失敗
在 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
執(zhí)行完會(huì)輸出一些日志,里面包含join需要用的 命令
在 master1 10.103.97.201 上
# 注意,在安裝之前解析到master0, 安裝成功后解析改成自己,因?yàn)閗ubelet kube-proxy配置的都是這個(gè)解析名,如果不改解析master0宕機(jī)整個(gè)集群就不可用了 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 # 解析改也自己本機(jī)地址
在 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
通過(guò)虛擬IP join到master上, 這個(gè) 命令 會(huì)在node節(jié)點(diǎn)上創(chuàng)建一條ipvs規(guī)則,virturl server就是虛擬IP, realserver就是三個(gè)master。 然后再以一個(gè)static pod起一個(gè)守護(hù)進(jìn)程守護(hù)這些規(guī)則,一旦哪個(gè)apiserver不可訪問(wèn)了就清除realserver, apiserver通了之后再次添加回來(lái)
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 |<---------------------+ +----------+
集群每個(gè)node節(jié)點(diǎn)都會(huì)創(chuàng)建一條ipvs規(guī)則用于代理所有的master節(jié)點(diǎn)。類(lèi)似kube-proxy的ipvs實(shí)現(xiàn)。
然后起一個(gè)守護(hù)進(jìn)程就健康檢查
apiservers /etc/kubernetes/manifests/sealyun-lvscare.yaml
網(wǎng)頁(yè)標(biāo)題:k8s高可用架構(gòu)
分享網(wǎng)址:http://www.rwnh.cn/article18/gopcgp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營(yíng)銷(xiāo)、動(dòng)態(tài)網(wǎng)站、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)