X

CentOS 8でKubernetes Clusterを構築してみた_2

前回CentOS 8でKubernetes Clusterを構築してみた_1でmaster nodeの構築が終わったので、Worker Nodeサーバーを構築します。

selinux・firewalld・swapは無効・hostsに追記・docker・kubeadm をインストールする所まではmasterサーバーと同様です。
自分はKVMのcloneでnode用のサーバーを2台構築しました。

前回masterサーバーでkubeadm initを実行して表示されたkubeadm join~の結果をコピペします。

# kubeadm join 192.168.5.101:6443 –token vb94zf.j2un0ry3aunvx9y3 –discovery-token-ca-cert-hash sha256:f42734223e79931159a470fe37a27677c51bcca051feccefbb8a050fbbfcad43
W0318 23:57:21.802582 1546 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.
[preflight] Running pre-flight checks
[WARNING IsDockerSystemdCheck]: detected “cgroupfs” as the Docker cgroup driver. The recommended driver is “systemd”. Please follow the guide at https://kubernetes.io/docs/setup/cri/
[WARNING FileExisting-tc]: tc not found in system path

error execution phase preflight: couldn’t validate the identity of the API Server: abort connecting to API servers after timeout of 5m0s
To see the stack trace of this error execute with –v=5 or higher

コケました。。

nodeからmasterへのpingの疎通は問題ありません。
masterでtokenを再確認します。

[root@master ~]# kubeadm token list

何も表示されません。
tokenを再作成します。

[root@master ~]# kubeadm token create –ttl 0
W0319 00:23:48.794101 21520 validation.go:28] Cannot validate kube-proxy config – no validator is available
W0319 00:23:48.794139 21520 validation.go:28] Cannot validate kubelet config – no validator is available
77m1r6.thccq5p3w9a0513z
[root@master ~]# kubeadm token list
TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS
77m1r6.thccq5p3w9a0513z authentication,signing system:bootstrappers:kubeadm:default-node-token

出来たようなので再度nodeサーバーでjoinしてみます。

# kubeadm join 192.168.5.101:6443 –token 77m1r6.thccq5p3w9a0513z –discovery-token-ca-cert-hash sha256:f42734223e79931159a470fe37a27677c51bcca051feccefbb8a050fbbfcad43
W0319 21:59:35.792352 1067 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.
[preflight] Running pre-flight checks
[WARNING IsDockerSystemdCheck]: detected “cgroupfs” as the Docker cgroup driver. The recommended driver is “systemd”. Please follow the guide at https://kubernetes.io/docs/setup/cri/
[WARNING FileExisting-tc]: tc not found in system path
[preflight] Reading configuration from the cluster…
[preflight] FYI: You can look at this config file with ‘kubectl -n kube-system get cm kubeadm-config -oyaml’
[kubelet-start] Downloading configuration for the kubelet from the “kubelet-config-1.17” ConfigMap in the kube-system namespace
[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…

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.

うまく行ったようなのでmasterで確認します。

[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master.hoge.net Ready master 2d22h v1.17.4
node-01.hoge.net Ready 21h v1.17.4

無事にnodeが追加されました。

同様にもう一台node用のサーバーを構築しjoinをします。

[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master.hoge.net Ready master 6d22h v1.17.4
node-01.hoge.net Ready 4d21h v1.17.4
node-02.hoge.net Ready 4d v1.17.4

これで、master1台node2台のKubernetes Clusterができました。

Categories: kubernetes linux
Tags: kubernetes
higherhope: