您好,登錄后才能下訂單哦!
這篇文章主要介紹k8s中如何使用kubeadm,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
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/v1beta1kind: ClusterConfigurationkubernetesVersion: v1.14.0controlPlaneEndpoint: "apiserver.cluster.local:6443" # 使用解析名去訪問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" # 如果不加這個k8s會定時清理用戶創建的IPVS規則,導致代理失敗
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
執行完會輸出一些日志,里面包含join需要用的命令
# 注意,在安裝之前解析到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 # 解析改也自己本機地址
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 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 |<---------------------+ +----------+
集群每個node節點都會創建一條ipvs規則用于代理所有的master節點。類似kube-proxy的ipvs實現.
然后起一個守護進程就健康檢查apiservers /etc/kubernetes/manifests/sealyun-lvscare.yaml
以上是“k8s中如何使用kubeadm”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。