2.6 其他节点加入集群
其他 master
节点执行
kubeadm join 192.168.122.100:8443 --token abcdef.0123456789abcdef \
--discovery-token-ca-cert-hash sha256:2ece2de72e3d9f41e8fcf736163aad8a8c1494790143802c0837a352abcef38f \
--control-plane --certificate-key 107397fb9f4b5ee3c6b2656282ced2b9846cff21738a89e29a9ef04a3c50652b
输出如下
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[preflight] Running pre-flight checks before initializing the new control plane instance
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[download-certs] Downloading the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [k8s-m1 k8s-m2 k8s-m3 localhost] and IPs [192.168.122.20 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [k8s-m1 k8s-m2 k8s-m3 localhost] and IPs [192.168.122.20 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [k8s-m1 k8s-m2 k8s-m3 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.122.20 192.168.122.100 127.0.0.1]
[certs] Generating "front-proxy-client" certificate and key
[certs] Valid certificates and keys now exist in "/etc/kubernetes/pki"
[certs] Using the existing "sa" key
[kubeconfig] Generating kubeconfig files
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[endpoint] WARNING: port specified in controlPlaneEndpoint overrides bindPort in the controlplane address
[kubeconfig] Writing "admin.conf" kubeconfig file
[endpoint] WARNING: port specified in controlPlaneEndpoint overrides bindPort in the controlplane address
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[endpoint] WARNING: port specified in controlPlaneEndpoint overrides bindPort in the controlplane address
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[check-etcd] Checking that the etcd cluster is healthy
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...
[etcd] Announced new etcd member joining to the existing etcd cluster
[etcd] Creating static Pod manifest for "etcd"
[etcd] Waiting for the new etcd member to join the cluster. This can take up to 40s
The 'update-status' phase is deprecated and will be removed in a future release. Currently it performs no operation
[mark-control-plane] Marking the node k8s-m2 as control-plane by adding the labels: [node-role.kubernetes.io/master(deprecated) node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node k8s-m2 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]
This node has joined the cluster and a new control plane instance was created:
* Certificate signing request was sent to apiserver and approval was received.
* The Kubelet was informed of the new secure connection details.
* Control plane (master) label and taint were applied to the new node.
* The Kubernetes control plane instances scaled up.
* A new etcd member was added to the local/stacked etcd cluster.
To start administering your cluster from this node, 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
Run 'kubectl get nodes' to see this node join the cluster.
其他 node
节点加入执行
kubeadm join 192.168.122.100:8443 --token abcdef.0123456789abcdef \
--discovery-token-ca-cert-hash sha256:2ece2de72e3d9f41e8fcf736163aad8a8c1494790143802c0837a352abcef38f
查看集群状态
kubectl get nodes
输出结果
NAME STATUS ROLES AGE VERSION
k8s-m1 NotReady control-plane,master 3m35s v1.22.6
k8s-m2 NotReady control-plane,master 90s v1.22.6
k8s-m3 NotReady control-plane,master 20s v1.22.6
集群状态都是 NotReady
,是因为还没有部署网络插件
检查pod,可以看到 apiserver
、 controller-manager
、 scheduler
和 etcd
都运行了3份
kubectl get po -n kube-system
输出如下
NAME READY STATUS RESTARTS AGE
coredns-78fcd69978-f94rm 0/1 Pending 0 3m36s
coredns-78fcd69978-pzcz6 0/1 Pending 0 3m36s
etcd-k8s-m1 1/1 Running 1 3m51s
etcd-k8s-m2 1/1 Running 0 101s
etcd-k8s-m3 1/1 Running 0 31s
kube-apiserver-k8s-m1 1/1 Running 0 3m50s
kube-apiserver-k8s-m2 1/1 Running 0 106s
kube-apiserver-k8s-m3 1/1 Running 0 36s
kube-controller-manager-k8s-m1 1/1 Running 1 (89s ago) 3m50s
kube-controller-manager-k8s-m2 1/1 Running 0 106s
kube-controller-manager-k8s-m3 1/1 Running 0 36s
kube-proxy-bw425 1/1 Running 0 107s
kube-proxy-g294k 1/1 Running 0 3m36s
kube-proxy-p48f6 1/1 Running 0 36s
kube-scheduler-k8s-m1 1/1 Running 1 (89s ago) 3m50s
kube-scheduler-k8s-m2 1/1 Running 0 107s
kube-scheduler-k8s-m3 1/1 Running 0 36s