LoginSignup
2
1

More than 3 years have passed since last update.

Deployment/DaemonSet/StatefulSetのstrategy/updateStrategyについて

Last updated at Posted at 2019-09-16

これは何?

DeploymentDaemonSetStatefulSetに設定するstrategyupdateStrategyについて、毎回調べている気がするので自分用に整理する。
ほぼkubectl explainKubernetes公式の内容です。

バージョン

クラスタは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

DeploymentDaemonSetStatefulSetPodを更新する際に、"どう置き換えていくか"の戦略。

Deployment

strategyについて

strategy     <Object>
  type       <string>
  rollingUpdate     <Object>
    maxSurge        <string>
    maxUnavailable  <string>
  • Deploymentに設定するのはstrategyという名前。
  • strategyにはtyperollingUpdateが設定できる。
  • rollingUpdateにはmaxSurgemaxUnavailableが設定できる。

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.
  • typeRecreateRollingUpdateから選んで設定できる。デフォルトはRollingUpdate
    • Recreateは、Podを一気に全部止めて新バージョンで作り直す。サービス断が発生する。
    • RollingUpdateは、部分的にPodを置き換えていく。
      • 新旧Podが混在する期間中にPodが"どれだけ規定数を超過してよいか"を設定するのがmaxSurge。(個数 or %)
      • 最大何個までPodが止まってもいいかを設定するのがmaxUnavailable。(個数 or %)
  • rollingUpdateに値を設定するのは、typeRollingUpdateの場合のみ。

DaemonSet

updateStrategyについて

updateStrategy  <Object>
  type          <string>
  rollingUpdate     <Object>
    maxUnavailable  <string>
  • DaemonSetに設定するのはupdateStrategyという名前。
  • updateStrategyにはtyperollingUpdateが設定できる。
  • 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".
  • typeRollingUpdateOnDeleteから選んで設定できる。デフォルトはOnDelete
    • OnDeleteは、更新をapplyした後にPodを削除することで、初めて新バージョンのPodが作成される。
  • rollingUpdateに値を設定するのは、typeRollingUpdateの場合のみ。

StatefulSet

updateStrategyについて

updateStrategy  <Object>
  type          <string>
  rollingUpdate    <Object>
    partition      <integer>
  • StatefulSetに設定するのはupdateStrategyという名前。
  • updateStrategyにはtyperollingUpdateが設定できる。
  • rollingUpdateにはpartitionが設定できる。
    • partitonStatefulSetで管理するPod0から採番される始まる序数を対象とする。設定された値以上の序数の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.
  • typeRollingUpdateOnDeleteから選んで設定できる。デフォルトはRollingUpdate
  • rollingUpdateに値を設定するのは、typeRollingUpdateの場合のみ。

おわり

  • DeploymentstrategyDaemonSetStatefulSetupdateStrategyとなっていて、ここでいつもどっちだっけ?となっていた。
  • kubectl explainKubernetes公式で書いている内容にズレがあることがたまにあるので注意する。
2
1
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
1