kubeadm init --apiserver-advertise-address $(hostname -i) --pod-network-cidr 10.5.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:
Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
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 192.168.0.23:6443 --token 221f6u.1r9leb1snw0fngbo \ --discovery-token-ca-cert-hash sha256:dc7108dbbe961ecddada53f6597459e7bbccd046dc60900330d24ee94dbcb216 Waiting for api server to startup Warning: resource daemonsets/kube-proxy is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically. daemonset.apps/kube-proxy configured
6 kubectl get nodes 查看集群信息
1 2 3
[node1 ~]$ kubectl get nodes NAME STATUS ROLES AGE VERSION node1 NotReady control-plane,master 111s v1.20.1
configmap/kube-router-cfg created daemonset.apps/kube-router created serviceaccount/kube-router created clusterrole.rbac.authorization.k8s.io/kube-router created clusterrolebinding.rbac.authorization.k8s.io/kube-router created
8 kubectl get nodes 查看集群信息
1 2 3
[node1 ~]$ kubectl get nodes NAME STATUS ROLES AGE VERSION node1 Ready control-plane,master 27m v1.20.1
... This node has joined the cluster: * Certificate signing request was sent to apiserver and a response was received. * The Kubelet was informed of the new secure connection details.
Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
12 在node1控制台中执行 kubectl get nodes命令
1 2 3 4
[node1 ~]$ kubectl get nodes NAME STATUS ROLES AGE VERSION node1 Ready control-plane,master 41m v1.20.1 node2 Ready <none> 2m13s v1.20.1