これは何?
Deployment
、DaemonSet
、StatefulSet
に設定するstrategy
、updateStrategy
について、毎回調べている気がするので自分用に整理する。
ほぼkubectl explain
とKubernetes公式の内容です。
バージョン
クラスタはkubeadm
産です。
# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:11:18Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
# kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:13:54Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:05:50Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
strategy/updateStrategy
Deployment
、DaemonSet
、StatefulSet
がPod
を更新する際に、"どう置き換えていくか"の戦略。
Deployment
strategyについて
strategy <Object>
type <string>
rollingUpdate <Object>
maxSurge <string>
maxUnavailable <string>
-
Deployment
に設定するのはstrategy
という名前。 -
strategy
にはtype
とrollingUpdate
が設定できる。 -
rollingUpdate
にはmaxSurge
とmaxUnavailable
が設定できる。
typeとrollingUpdateについて
type <string>
Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.
rollingUpdate <Object>
Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate.
-
type
はRecreate
とRollingUpdate
から選んで設定できる。デフォルトはRollingUpdate
。-
Recreate
は、Pod
を一気に全部止めて新バージョンで作り直す。サービス断が発生する。 -
RollingUpdate
は、部分的にPod
を置き換えていく。- 新旧
Pod
が混在する期間中にPod
が"どれだけ規定数を超過してよいか"を設定するのがmaxSurge
。(個数 or %) - 最大何個まで
Pod
が止まってもいいかを設定するのがmaxUnavailable
。(個数 or %)
- 新旧
-
-
rollingUpdate
に値を設定するのは、type
がRollingUpdate
の場合のみ。
DaemonSet
updateStrategyについて
updateStrategy <Object>
type <string>
rollingUpdate <Object>
maxUnavailable <string>
-
DaemonSet
に設定するのはupdateStrategy
という名前。 -
updateStrategy
にはtype
とrollingUpdate
が設定できる。 -
rollingUpdate
にはmaxUnavailable
が設定できる。
typeとrollingUpdateについて
type <string>
Type of daemon set update. Can be "RollingUpdate" or "OnDelete". Default is OnDelete.
rollingUpdate <Object>
Rolling update config params. Present only if type = "RollingUpdate".
-
type
はRollingUpdate
とOnDelete
から選んで設定できる。デフォルトはOnDelete
。-
OnDelete
は、更新をapply
した後にPod
を削除することで、初めて新バージョンのPod
が作成される。
-
-
rollingUpdate
に値を設定するのは、type
がRollingUpdate
の場合のみ。
StatefulSet
updateStrategyについて
updateStrategy <Object>
type <string>
rollingUpdate <Object>
partition <integer>
-
StatefulSet
に設定するのはupdateStrategy
という名前。 -
updateStrategy
にはtype
とrollingUpdate
が設定できる。 -
rollingUpdate
にはpartition
が設定できる。-
partiton
はStatefulSet
で管理するPod
に0
から採番される始まる序数を対象とする。設定された値以上の序数のPod
は更新され、未満のPod
は更新されない。段階的に更新したい時に用いる。
-
typeとrollingUpdateについて
type <string>
Type indicates the type of the StatefulSetUpdateStrategy. Default is RollingUpdate.
rollingUpdate <Object>
RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType.
-
type
はRollingUpdate
とOnDelete
から選んで設定できる。デフォルトはRollingUpdate
。 -
rollingUpdate
に値を設定するのは、type
がRollingUpdate
の場合のみ。
おわり
-
Deployment
はstrategy
、DaemonSet
とStatefulSet
はupdateStrategy
となっていて、ここでいつもどっちだっけ?となっていた。 -
kubectl explain
とKubernetes公式で書いている内容にズレがあることがたまにあるので注意する。