MicroK8sでマルチノードクラスタをセットアップする
MicroK8sのインストール
VM1でmicrok8sをインストール
VM1 $ sudo snap install microk8s --classic VM1 $ sudo usermod -a -G microk8s $USER VM1 $ sudo chown -f -R $USER ~/.kube VM1 $ microk8s status --wait-ready
VM1 $ microk8s kubectl get nodes NAME STATUS ROLES AGE VERSION VM1 Ready <none> 80s v1.28.3
VM2でmicrok8sをインストール
VM2 $ sudo snap install microk8s --classic VM2 $ sudo usermod -a -G microk8s $USER VM2 $ sudo chown -f -R $USER ~/.kube VM2 $ microk8s status --wait-ready
VM1 $ microk8s kubectl get nodes NAME STATUS ROLES AGE VERSION VM2 Ready <none> 80s v1.28.3
nodeの追加
VM2をmasterにして、VM1をworkerとして動作させるようにしてみる。
joinコマンドを確認する。
VM2 $ microk8s add-node From the node you wish to join to this cluster, run the following: microk8s join 2.2.2.2:25000/xxxxxxxxxxxxxxxxxxx/xxxxxxxxxxx Use the '--worker' flag to join a node as a worker not running the control plane, eg: microk8s join 2.2.2.2:25000/xxxxxxxxxxxxxxxxxxx/xxxxxxxxxxx --worker If the node you are adding is not reachable through the default interface you can use one of the following: microk8s join 2.2.2.2:25000/xxxxxxxxxxxxxxxxxxx/xxxxxxxxxxx
上記で得られたjoinコマンドをVM1で実行する。
VM1 $ microk8s join 2.2.2.2:25000/xxxxxxxxxxxxxxxxxxx/xxxxxxxxxxx
上手くいったか確認
VM2 $ microk8s kubectl get nodes NAME STATUS ROLES AGE VERSION VM2 Ready <none> 5m36s v1.28.3 VM1 Ready <none> 25s v1.28.3