這篇文章主要介紹k8s中如何使用kubeadm,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括信豐網(wǎng)站建設(shè)、信豐網(wǎng)站制作、信豐網(wǎng)頁(yè)制作以及信豐網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,信豐網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到信豐省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
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/v1beta1kind: ClusterConfigurationkubernetesVersion: v1.14.0controlPlaneEndpoint: "apiserver.cluster.local:6443" # 使用解析名去訪問(wèn)APIserverapiServer: 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/v1alpha1kind: KubeProxyConfigurationmode: "ipvs"ipvs: excludeCIDRs: - "10.103.97.2/32" # 如果不加這個(gè)k8s會(huì)定時(shí)清理用戶創(chuàng)建的IPVS規(guī)則,導(dǎo)致代理失敗
echo "10.103.97.200 apiserver.cluster.local" >> /etc/hostskubeadm init --config=kubeadm-config.yaml --experimental-upload-certs mkdir ~/.kube && cp /etc/kubernetes/admin.conf ~/.kube/configkubectl 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需要用的命令
# 注意,在安裝之前解析到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ī)地址
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 vipkubeadm 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
+----------+ +---------------+ 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)。類似kube-proxy的ipvs實(shí)現(xiàn).
然后起一個(gè)守護(hù)進(jìn)程就健康檢查apiservers /etc/kubernetes/manifests/sealyun-lvscare.yaml
以上是“k8s中如何使用kubeadm”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!