欧美另类亚洲日本一区二区_国产网友愉拍精品_国产精品欧美福利久久_亚洲人在线观看影院_国产无套乱子伦精彩是

您當前的位置:資訊 >  >> 
重新初始化k8s集群

時間:2023-06-26 17:15:49    來源:博客園

執(zhí)行如下命令,所有節(jié)點都執(zhí)行
kubeadm reset
初始化集群,僅在master(centos01)上執(zhí)行
[root@centos01 opt]# kubeadm init --apiserver-advertise-address 192.168.109.130 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.27.1 --pod-network-cidr=10.244.0.0/16.........Your Kubernetes control-plane has initialized successfully!To start using your cluster, you need to run the following as a regular user:  mkdir -p $HOME/.kube  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config  sudo chown $(id -u):$(id -g) $HOME/.kube/configAlternatively, if you are the root user, you can run:  export KUBECONFIG=/etc/kubernetes/admin.confYou should now deploy a pod network to the cluster.Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:  https://kubernetes.io/docs/concepts/cluster-administration/addons/Then you can join any number of worker nodes by running the following on each as root:kubeadm join 192.168.109.130:6443 --token osh87v.zvo010kamsr8esmp \--discovery-token-ca-cert-hash sha256:ff4607c7c194e9f756b1eb509e64d2d926b5f8f9556a85c3c14a2d25add28230

其中,–apiserver-advertise-address:通告?zhèn)陕牭刂法Cimage-repository:指定鏡像地址使用阿里云的,默認會使用谷歌鏡像–kubernetes-version:指定當前的kubernetes的版本–pod-network-cidr=10.244.0.0/16:flannel網(wǎng)絡(luò)的固定地址范圍

仔細閱讀kubeadm init執(zhí)行的結(jié)果,根據(jù)提示,還需要進行3步操作

1.筆者用的是root用戶,僅在master節(jié)點執(zhí)行


(相關(guān)資料圖)

[root@centos01 opt]# vim /etc/profile#在最后一行增加export KUBECONFIG=/etc/kubernetes/admin.conf

生效環(huán)境變量

[root@centos01 opt]# source /etc/profile

2.安裝網(wǎng)絡(luò)插件,可以選擇calico或flannel,這里選擇安裝flannel,僅在master節(jié)點執(zhí)行

下載安裝文件

[root@centos01 opt]# wget https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

修改配置

[root@centos01 opt]# vim kube-flannel.yml#修改Network項的值,改為和--pod-network-cidr一樣的值"Network": "10.244.0.0/16"#由于有時國內(nèi)網(wǎng)絡(luò)的問題,需要修改image的地址,把所有的docker.io改為dockerproxy.com#共需要修改3處,兩個值image: dockerproxy.com/flannel/flannel:v0.22.0image: dockerproxy.com/flannel/flannel-cni-plugin:v1.1.2

安裝網(wǎng)絡(luò)插件

[root@centos01 opt]# kubectl apply -f kube-flannel.yml

驗證安裝

[root@centos01 opt]# kubectl get pods -n kube-flannelNAME                    READY   STATUS    RESTARTS       AGEkube-flannel-ds-dfngh   1/1     Running   17 (13m ago)   6d1hkube-flannel-ds-qll8g   1/1     Running   12 (13m ago)   6d1h

3.其他節(jié)點加入集群,非master節(jié)點都執(zhí)行

[root@centos02 opt]# kubeadm join 192.168.109.130:6443 --token osh87v.zvo010kamsr8esmp --discovery-token-ca-cert-hash sha256:ff4607c7c194e9f756b1eb509e64d2d926b5f8f9556a85c3c14a2d25add28230
驗證安裝結(jié)果,僅在master節(jié)點執(zhí)行
[root@centos01 opt]# kubectl get nodesNAME       STATUS   ROLES           AGE    VERSIONcentos01   Ready    control-plane   134m   v1.27.1centos02   Ready              133m   v1.27.1
[root@centos01 opt]# kubectl get pods -n kube-systemNAME                               READY   STATUS    RESTARTS   AGEcoredns-7bdc4cb885-l4vs2           1/1     Running   0          9m3scoredns-7bdc4cb885-wzc8x           1/1     Running   0          9m3setcd-centos01                      1/1     Running   0          9m18skube-apiserver-centos01            1/1     Running   0          9m18skube-controller-manager-centos01   1/1     Running   0          9m19skube-proxy-m92hr                   1/1     Running   0          28skube-proxy-pv4hw                   1/1     Running   0          9m3skube-scheduler-centos01            1/1     Running   0          9m18s

重啟一遍所有服務(wù)器節(jié)點,有可能會暴露出來隱藏的問題,再次驗證以上結(jié)果,仍然正常。

最后,推薦一個發(fā)布應(yīng)用的平臺https://gitee.com/i512team/dhorse,是一個以應(yīng)用為中心的云原生DevOps系統(tǒng),能夠?qū)崿F(xiàn)持續(xù)集成、持續(xù)部署、微服務(wù)治理等功能,主要特點:部署簡單、操作簡潔、功能快速。

關(guān)鍵詞:

X 關(guān)閉

X 關(guān)閉