CentOS 7
Sponsored Link

Kubernetes : ノードを追加する2018/04/15

既存の Kubernetes クラスターにノードを新規に追加する場合は以下のように設定します。
以下のように 3台のノードで構成している Kubernetes クラスターに [node03.srv.world] ノードを新規に追加します。
           |                           |                          |
       eth0|              eth0|             eth0|
+----------+-----------+   +-----------+----------+   +-----------+----------+
|   [ dlp.srv.world ]  |   | [ node01.srv.world ] |   | [ node02.srv.world ] |
|      Master Node     |   |      Worker Node     |   |      Worker Node     |
+----------------------+   +----------------------+   +----------------------+

[2] Master ノードで認証トークンを確認します。
[root@dlp ~]#
kubeadm token create --print-join-command

kubeadm join --token awkx6k.8ovqfwiwm76r5lci --discovery-token-ca-cert-hash sha256:f2caf4fe6f26dc6cc8188b55ee3c825e5b8d9779a61bfd4eda4b152627e56184
[3] 新規に追加するノードで、Master ノードで確認した認証トークン用コマンドを実行します。
[root@node03 ~]#
kubeadm join --token awkx6k.8ovqfwiwm76r5lci \
--discovery-token-ca-cert-hash sha256:f2caf4fe6f26dc6cc8188b55ee3c825e5b8d9779a61bfd4eda4b152627e56184

[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'
[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...
[  120.917765] ip6_tables: (C) 2000-2006 Netfilter Core Team

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.
[4] Master ノードでノード情報を確認しておきます。新規追加ノードが STATUS = Ready であれば OK です。
[root@dlp ~]#
kubectl get nodes

NAME               STATUS   ROLES                  AGE   VERSION
dlp.srv.world      Ready    control-plane,master   16h   v1.21.1
node01.srv.world   Ready    <none>                 16h   v1.21.1
node02.srv.world   Ready    <none>                 16h   v1.21.1
node03.srv.world   Ready    <none>                 81s   v1.21.1

[root@dlp ~]#
kubectl get pods -A -o wide | grep node03

kube-system            kube-flannel-ds-tv2zb                        1/1     Running   0          106s     node03.srv.world   <none>           <none>
kube-system            kube-proxy-sk97b                             1/1     Running   0          106s     node03.srv.world   <none>           <none>