Kubernetes : Kubeadm : Workerノードの設定
2018/04/07 |
Kubeadm をインストールして、マルチノード Kubernetes クラスターを構成します。
当例では以下のように 3台のホストを使用して設定します。
前提条件として、それぞれのノードの Hostname, MAC address, Product_uuid は一意である必要があります。
MAC address と Product_uuid は、通常の物理マシンや一般的な方法で作成した仮想マシンであれば、すでに一意となっているはずです。 Product_uuid は [dmidecode -s system-uuid] コマンドで確認できます。 -----------+---------------------------+--------------------------+------------ | | | eth0|10.0.0.30 eth0|10.0.0.51 eth0|10.0.0.52 +----------+-----------+ +-----------+----------+ +-----------+----------+ | [ dlp.srv.world ] | | [ node01.srv.world ] | | [ node02.srv.world ] | | Master Node | | Worker Node | | Worker Node | +----------------------+ +----------------------+ +----------------------+ |
Worker ノードの設定を実施します。
|
|
[1] | |
[2] | Master ノードで初期セットアップしたクラスターに Join します。 Join する際のコマンドは、初期セットアップのコマンド実行時の最後に表示された [kubeadm join ~] コマンドをそのままコピーして実行するのみです。 |
[root@node01 ~]# kubeadm join 10.0.0.30:6443 --token ivcdtn.r9qt329oe49nb3b7 --discovery-token-ca-cert-hash sha256:2a2bdff5648e6f17bbc60889e8b47656795f2cb2ea959c8dc10b5dcb09d48be5 [preflight] Running pre-flight checks. [WARNING FileExisting-crictl]: crictl not found in system path Suggestion: go get github.com/kubernetes-incubator/cri-tools/cmd/crictl [preflight] Starting the kubelet service [discovery] Trying to connect to API Server "10.0.0.30:6443" [discovery] Created cluster-info discovery client, requesting info from "https://10.0.0.30:6443" [discovery] Requesting info from "https://10.0.0.30:6443" again to validate TLS against the pinned public key [discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server "10.0.0.30:6443" [discovery] Successfully established connection with API Server "10.0.0.30:6443" This node has joined the cluster: * Certificate signing request was sent to master and a response was received. * The Kubelet was informed of the new secure connection details. Run 'kubectl get nodes' on the master to see this node join the cluster. # Successfully established connection ~ と表示されれば OK |
[3] | Master ノードでノード情報を確認しておきます。全て STATUS = Ready であれば OK です。 |
[root@dlp ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION dlp.srv.world Ready master 1h v1.10.0 node01.srv.world Ready <none> 4m v1.10.0 node02.srv.world Ready <none> 2m v1.10.0 |
[4] | Pod をデプロイして動作確認しておきます。 |
[root@dlp ~]# kubectl run test-nginx --image=nginx --replicas=2 --port=80 deployment.apps "test-nginx" created [root@dlp ~]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE test-nginx-959dbd6b6-dkplf 1/1 Running 0 14m 10.244.1.2 node01.srv.world test-nginx-959dbd6b6-qhz55 1/1 Running 0 14m 10.244.2.2 node02.srv.world[root@dlp ~]# kubectl expose deployment test-nginx service "test-nginx" exposed [root@dlp ~]# kubectl describe service test-nginx Name: test-nginx Namespace: default Labels: run=test-nginx Annotations: <none> Selector: run=test-nginx Type: ClusterIP IP: 10.102.121.104 Port: <unset> 80/TCP TargetPort: 80/TCP Endpoints: 10.244.1.2:80,10.244.2.2:80 Session Affinity: None Events: <none>[root@dlp ~]# curl 10.102.121.104 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> ..... ..... <p><em>Thank you for using nginx.</em></p> </body> </html> |