1. 初始化master节点

 

这一步只在master节点上执行

 

kubeadm init --apiserver-advertise-address=172.31.117.40 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.20.6 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16

 

结果如下:

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/config

 

You 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 172.31.117.40:6443 --token mgcyi7.7i390l69h0zd5h5s \

    --discovery-token-ca-cert-hash sha256:7ce5cd911f90bc42885b55020968d10cd78755e6d790367f4b559a5485c059a3

 

 

  1. 使用kubectl工具

 

  mkdir -p $HOME/.kube

  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

  sudo chown $(id -u):$(id -g) $HOME/.kube/config

 

 

  1. 查看下master节点是否启动

要等master节点启动,需要几分钟

kubectl get nodes