0
0

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 1 year has passed since last update.

kubernetesのtaintと和解したい

0
Last updated at Posted at 2023-12-13

スケジュールとは

あるNodeにPodを割り当てること

Taintとは

ある条件を満たさないとPodをスケジュールさせないようにする機能。想定しないPodの作成を防ぐ。
Taintはkey,value,effectの3つの要素からなる。マニュフェストファイルに記入されているkeyvalueが一致しない場合、effectが発揮される(Podがスケジュールされないなど)

NodeにTaintを設定する方法

node01に、appというキーの値がbatchじゃないとスケジュールしませんよ〜(=NoScheduleという効果が発揮されますよ〜)というTaintを設定する例

$ kubectl taint node node01 app=batch:NoSchedule

ここに以下のようなyamlファイルでpod01というPodを作成しようとする

apiVersion: v1
kind: Pod
metadata:
  name: pod01
spec:
  containers:
  - image: nginx
    name: pod01
$ kubectl create -f pod01.yaml

ステータスを見るとpendingになる

$ kubectl get pod
NAME    READY   STATUS    RESTARTS   AGE
pod01   1/1     Pending   0          4s

taintをちゃんと設定する

apiVersion: v1
kind: Pod
metadata:
  name: pod01
spec:
  containers:
  - image: nginx
    name: pod01
  tolerations:
  - key: "app"
    operator: "Equal"
    value: "batch"
    effect: "NoSchedule"

Runningになる

$ kubectl get pod
NAME    READY   STATUS    RESTARTS   AGE
pod01   1/1     Running   0          4s
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?