Kubernetes : Kubeadm : Workerノードの設定2018/10/22 |
|
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 nvr822.tjn09e85qw3a3vuz --discovery-token-ca-cert-hash sha256:866f645d9ec0da07f778b3c4abc4427e9967845d71add3252fbd691b86c0a9a7
[preflight] running pre-flight checks
[WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]
you can solve this problem with following methods:
1. Run 'modprobe -- ' to load missing kernel modules;
2. Provide the missing builtin kernel ipvs support
[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 17.12.1-ce. Latest validated version: 18.06
[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"
[kubelet] Downloading configuration for the kubelet from the "kubelet-config-1.12" ConfigMap in the kube-system namespace
[kubelet] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[preflight] Activating the kubelet service
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...
[patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "node01.srv.world" as an annotation
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 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 12m v1.12.1 node01.srv.world Ready <none> 6m59s v1.12.1 node02.srv.world Ready <none> 2m20s v1.12.1 |
| [4] | Pod をデプロイして動作確認しておきます。 |
|
root@dlp:~# kubectl create deployment test-nginx --image=nginx deployment.apps "test-nginx" created root@dlp:~# kubectl scale deployment test-nginx --replicas=3 deployment.extensions/test-nginx scaled root@dlp:~# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE test-nginx-677ccfd879-7pxdn 1/1 Running 0 14s 10.244.2.2 node02.srv.world <none> test-nginx-677ccfd879-hpvv5 1/1 Running 0 33s 10.244.1.2 node01.srv.world <none> test-nginx-677ccfd879-wjj7k 1/1 Running 0 14s 10.244.1.3 node01.srv.world <none>root@dlp:~# kubectl expose deployment test-nginx --port 80 service "test-nginx" exposed root@dlp:~# kubectl describe service test-nginx Name: test-nginx Namespace: default Labels: app=test-nginx Annotations: <none> Selector: app=test-nginx Type: ClusterIP IP: 10.106.41.54 Port: <unset> 80/TCP TargetPort: 80/TCP Endpoints: 10.244.1.2:80,10.244.1.3:80,10.244.2.2:80 Session Affinity: None Events: <none>root@dlp:~# curl 10.106.41.54 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> ..... ..... <p><em>Thank you for using nginx.</em></p> </body> </html> |
| Sponsored Link |
|
|