(資料圖片僅供參考)
當我們在master節點、安裝部署完docker與Kubernetes / k8s 相關的軟件后,并啟動(docker,kubelet)后,接下來就是需要對master節點進行初始化操作了
如下,這里筆者使用的版本的為 Kubernetes-v1.23.6,初始化是使用kubeadm init命令,詳細的參數如下所示:
注意點:執行前需要先將docker的Cgroup Driver由默認的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
如果沒有相關的報錯,就算是正常了,命令執行完成后,可以看到一段提示
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
根據提示,如果要開始使用k8s cluster,還需要在master節點上執行如下幾條命令,這里筆者是使用root用戶,所以去掉了sudo,最終命令如下:
mkdir -p $HOME/.kubecp -i /etc/kubernetes/admin.conf $HOME/.kube/configchown $(id -u):$(id -g) $HOME/.kube/config
這樣,master節點的初始化,就算是完成了,上面的都執行了,也才可以通過kubectl get nodes命令看到k8s集群中的master節點
其他說明:初始化后,我們可以也可以通過docker命令看出來,拉取了如下7個鏡像:
[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 ~]#
尊重別人的勞動成果 轉載請務必注明出處:https://www.cnblogs.com/5201351/p/17381460.html
關于我們| 聯系方式| 版權聲明| 供稿服務| 友情鏈接
咕嚕網 www.fyuntv.cn 版權所有,未經書面授權禁止使用
Copyright©2008-2023 By All Rights Reserved 皖ICP備2022009963號-10
聯系我們: 39 60 29 14 2@qq.com