LoginSignup
2
2

More than 5 years have passed since last update.

Raspberry Piでkubernetesクラスタを組んでみる③

Posted at

Master/Worker Nodeの準備

まずはMasterの初期化を行います

kubeadm init

なんか色々ログが出てくるけど、最後の方にこんなコマンドが出てくると思います。

mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config

言われた通り、このコマンドを実行してみます。
で、さらにノードを追加するためのコマンドも出てくるのでこれをコピっておいて、残り2台のworkerで実行してやります。

kubeadm join xxx.xxx.xxx.xxx:6443 --token xxxxxxxxxxxxxxxx

しばらく待って、ノードの様子を見てみます

$ kubectl get nodes
NAME           STATUS     ROLES     AGE       VERSION
raspberrypi0   NotReady   master    1d        v1.11.1
raspberrypi1   NotReady   <none>    1d        v1.11.1
raspberrypi2   NotReady   <none>    1d        v1.11.1

あ、困った!ノードは追加できてるけどNotReadyだ!!
では、まずMasterNodeの様子を見てみましょう。

$ kubectl describe node raspberrypi0 
  Type             Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----             ------  -----------------                 ------------------                ------                       -------
  Ready            False   Sun, 16 Sep 2018 04:47:34 +0000   Tue, 11 Sep 2018 15:01:33 +0000   KubeletNotReady              runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized. WARNING: CPU hardcapping unsupported

ほんとは他にも色々出てくるけど、とりあえずReady状態になっていないのはネットワークの問題のようです。

StatusをReadyにしよう

こちらの記事なんかを見ているとflannelを入れてコンテナ同士(Pod同士)の通信をさせれば良いとのことでした。
そのへんはKubernetesがよしなにやってくれるのかと思っていたのですが、GCE上でしか使えないとか(まじかよ・・・)

ということでflannelを入れてみました。

kubectl apply -f <(curl -s https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml |sed 's/amd64/arm/g')

そうするとうまくいきました

$ kubectl get nodes
NAME           STATUS    ROLES     AGE       VERSION
raspberrypi0   Ready     master    4h        v1.11.1
raspberrypi1   Ready     <none>    4h        v1.11.1
raspberrypi2   Ready     <none>    4h        v1.11.1
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2