(資料圖片僅供參考)
當(dāng)我們?cè)趍aster節(jié)點(diǎn)、安裝部署完docker與Kubernetes / k8s 相關(guān)的軟件后,并啟動(dòng)(docker,kubelet)后,接下來(lái)就是需要對(duì)master節(jié)點(diǎn)進(jìn)行初始化操作了
如下,這里筆者使用的版本的為 Kubernetes-v1.23.6,初始化是使用kubeadm init命令,詳細(xì)的參數(shù)如下所示:
注意點(diǎn):執(zhí)行前需要先將docker的Cgroup Driver由默認(rèn)的cgroupfs修改成systemd,并重啟docker讓配置生效
[root@k8s-master qq-5201351]# kubeadm init \> --apiserver-advertise-address 192.18.106.87 \> --image-repository registry.aliyuncs.com/google_containers \> --kubernetes-version v1.23.6 \> --service-cidr=10.96.0.0/12 \> --pod-network-cidr=10.224.0.0/16
如果沒(méi)有相關(guān)的報(bào)錯(cuò),就算是正常了,命令執(zhí)行完成后,可以看到一段提示
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.18.106.87:6443 --token 8iz44r.cxj5duahe37wsdgq \ --discovery-token-ca-cert-hash sha256:08752ac13ae6f821c44abdf6eb1fa2481777b82d20335e4467829ac20b503e55
根據(jù)提示,如果要開(kāi)始使用k8s cluster,還需要在master節(jié)點(diǎn)上執(zhí)行如下幾條命令,這里筆者是使用root用戶(hù),所以去掉了sudo,最終命令如下:
mkdir -p $HOME/.kubecp -i /etc/kubernetes/admin.conf $HOME/.kube/configchown $(id -u):$(id -g) $HOME/.kube/config
這樣,master節(jié)點(diǎn)的初始化,就算是完成了,上面的都執(zhí)行了,也才可以通過(guò)kubectl get nodes命令看到k8s集群中的master節(jié)點(diǎn)
其他說(shuō)明:初始化后,我們可以也可以通過(guò)docker命令看出來(lái),拉取了如下7個(gè)鏡像:
[root@k8s-master ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEregistry.aliyuncs.com/google_containers/kube-apiserver v1.23.6 8fa62c12256d 12 months ago 135MBregistry.aliyuncs.com/google_containers/kube-scheduler v1.23.6 595f327f224a 12 months ago 53.5MBregistry.aliyuncs.com/google_containers/kube-proxy v1.23.6 4c0375452406 12 months ago 112MBregistry.aliyuncs.com/google_containers/kube-controller-manager v1.23.6 df7b72818ad2 12 months ago 125MBregistry.aliyuncs.com/google_containers/etcd 3.5.1-0 25f8c7f3da61 18 months ago 293MBregistry.aliyuncs.com/google_containers/coredns v1.8.6 a4ca41631cc7 19 months ago 46.8MBregistry.aliyuncs.com/google_containers/pause 3.6 6270bb605e12 20 months ago 683kB[root@k8s-master ~]#
尊重別人的勞動(dòng)成果 轉(zhuǎn)載請(qǐng)務(wù)必注明出處:https://www.cnblogs.com/5201351/p/17381460.html
最新資訊
關(guān)于我們| 聯(lián)系方式| 版權(quán)聲明| 供稿服務(wù)| 友情鏈接
咕嚕網(wǎng) www.ulq4xuwux.cn 版權(quán)所有,未經(jīng)書(shū)面授權(quán)禁止使用
Copyright©2008-2023 By All Rights Reserved 皖I(lǐng)CP備2022009963號(hào)-10
聯(lián)系我們: 39 60 29 14 2@qq.com