LoginSignup
1
0

More than 3 years have passed since last update.

[kubernetes]masterノードにpodを配置できるようにする

Posted at

概要

kubernetesでは、デフォルト設定でmasterノードにはpodを配置できないようになっているようです。

手元の検証用環境のためリソースが十分に無く、masterノードでもpodを作成できるようにしてリソースを節約したいことがありました。
そこで、以下の作業を実施したので、記録として残しておきます。

現在の状況

・バージョン

vagrant@master:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1", GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean", BuildDate:"2019-04-08T17:11:31Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:14:56Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

・masterノードの確認

vagrant@master:~$ kubectl describe node master
︙
Taints:             node-role.kubernetes.io/master:NoSchedule
︙

コマンド実行

masterノードにpodを配置できるようにする。
コマンドの最後の「-」を忘れないようにします。

vagrant@master:~$ kubectl taint nodes master node-role.kubernetes.io/master:NoSchedule-
node/master untainted

結果確認

Taintsがnoneになっていれば成功です。

vagrant@master:~$ kubectl describe node master
︙
Taints:             <none>
︙

補足

逆にmasterノードへpodを配置できないようにする場合は以下を実行します。

vagrant@master:~$ kubectl taint nodes master node-role.kubernetes.io/master=:NoSchedule
node/master untainted

NoSchedule部分はeffectと呼ばれており、全3種類から選択が可能です。

Taints and Tolerationsから引用(2020/05/07)

・if there is at least one un-ignored taint with effect NoSchedule then Kubernetes will not schedule the pod onto that node
・if there is no un-ignored taint with effect NoSchedule but there is at least one un-ignored taint with effect PreferNoSchedule then Kubernetes will try to not schedule the pod onto the node
・if there is at least one un-ignored taint with effect NoExecute then the pod will be evicted from the node (if it is already running on the node), and will not be scheduled onto the node (if it is not yet running on the node).

また、今回は実施していませんが、PodSpecにtolerations行を追加することで、podごとに各ノードへの配置可能不可能を設定できます。(上記のリンクを参照)

参考

・Qiita記事
KubernetesのTaintsとTolerationsについて
KubernetesのTaint / Tolerationの使い方
・公式ドキュメント
Taints and Tolerations
Control plane node isolation

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