1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Kubernetes】初期構築時以降にNodeをクラスタにjoinさせる方法

Posted at

Kubernetesの環境構築をした際に、途中からNodeを追加でjoinしたいと思ったときに躓いたので対処方法をメモします。

初期構築時にjoinさせる方法

Kubernetesを使うための事前設定をした後に、Masterで以下コマンドを実行するとランダムな文字列が記載されたjoin用のコマンドが出力される。そのコマンドをNodeで実行することで、当該Master配下のクラスタにjoinさせることができる。

Masterで実行
# kubeadm init --apiserver-advertise-address=X.X.X.X - -pod-network-cidr=Y.Y.Y.Y/Z
~~~(略)~~~
Then you can join any number of worker nodes by running the following on each as root:

kubeadm join X.X.X.X:6443 --token <生成されたランダム文字列> \
    --discovery-token-ca-cert-hash <生成されたランダム文字列> 

ただし、上記コマンドには有効期限(?)があるらしく、数日後に同じコマンドを実行したらjoinされなかった。

初期構築時以降にjoinさせる方法

おそらくtoken(ランダム文字列)に有効期限が設定されているためと思われるので、以下コマンドでtokenごと新たにjoinコマンドを生成すればよい。

Masterで実行
# kubeadm token generate
<ランダム文字列が出力される>
# kubeadm token create <上記で出力されたランダム文字列> --print-join-command --ttl=0
kubeadm join X.X.X.X:6443 --token <上記で出力されたランダム文字列>     --discovery-token-ca-cert-hash <ランダム文字列>

初期構築時に出力されるjoinコマンドのメモをなくしたりしたときにも、この方法で新たにjoinコマンドを発行できます。

1
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?