Advanced DaemonSet

This controller enhances the rolling update workflow of default DaemonSet controller from aspects, such as partition, selector, pause and surging strategies.

Note that Advanced DaemonSet extends the same CRD schema of default DaemonSet with newly added fields. The CRD kind name is still DaemonSet. This is done on purpose so that user can easily migrate workload to the Advanced DaemonSet from the default DaemonSet. For example, one may simply replace the value of apiVersion in the DaemonSet yaml file from apps/v1 to apps.kruise.io/v1alpha1 after installing Kruise manager.

  1. - apiVersion: apps/v1
  2. + apiVersion: apps.kruise.io/v1alpha1
  3. kind: DaemonSet
  4. metadata:
  5. name: sample-ds
  6. spec:
  7. #...

Enhanced strategies

These new fields have been added into RollingUpdateDaemonSet:

  1. const (
  2. + // StandardRollingUpdateType replace the old daemons by new ones using rolling update i.e replace them on each node one after the other.
  3. + // this is the default type for RollingUpdate.
  4. + StandardRollingUpdateType RollingUpdateType = "Standard"
  5. + // SurgingRollingUpdateType replaces the old daemons by new ones using rolling update i.e replace them on each node one
  6. + // after the other, creating the new pod and then killing the old one.
  7. + SurgingRollingUpdateType RollingUpdateType = "Surging"
  8. )
  9. // Spec to control the desired behavior of daemon set rolling update.
  10. type RollingUpdateDaemonSet struct {
  11. + // Type is to specify which kind of rollingUpdate.
  12. + Type RollingUpdateType `json:"rollingUpdateType,omitempty" protobuf:"bytes,1,opt,name=rollingUpdateType"`
  13. // ...
  14. MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,2,opt,name=maxUnavailable"`
  15. + // A label query over nodes that are managed by the daemon set RollingUpdate.
  16. + // Must match in order to be controlled.
  17. + // It must match the node's labels.
  18. + Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,3,opt,name=selector"`
  19. + // The number of DaemonSet pods remained to be old version.
  20. + // Default value is 0.
  21. + // Maximum value is status.DesiredNumberScheduled, which means no pod will be updated.
  22. + // +optional
  23. + Partition *int32 `json:"partition,omitempty" protobuf:"varint,4,opt,name=partition"`
  24. + // Indicates that the daemon set is paused and will not be processed by the
  25. + // daemon set controller.
  26. + // +optional
  27. + Paused *bool `json:"paused,omitempty" protobuf:"varint,5,opt,name=paused"`
  28. + // ...
  29. + MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,7,opt,name=maxSurge"`
  30. }

Type for rolling update

Advanced DaemonSet has a rollingUpdateType field in spec.updateStrategy.rollingUpdate which controls the way to rolling update.

  • Standard: controller will replace the old daemons by new ones using rolling update i.e replace them on each node one after the other. It is the same behavior as default DaemonSet.
  • Surging: controller will replace the old daemons by new ones using rolling update i.e replace them on each node one after the other, creating the new pod and then killing the old one.
  1. apiVersion: apps.kruise.io/v1alpha1
  2. kind: DaemonSet
  3. spec:
  4. # ...
  5. updateStrategy:
  6. type: RollingUpdate
  7. rollingUpdate:
  8. rollingUpdateType: Standard

Selector for rolling update

It helps users to update Pods on specific nodes whose labels could be matched with the selector.

  1. apiVersion: apps.kruise.io/v1alpha1
  2. kind: DaemonSet
  3. spec:
  4. # ...
  5. updateStrategy:
  6. type: RollingUpdate
  7. rollingUpdate:
  8. selector:
  9. matchLabels:
  10. nodeType: canary

Partition for rolling update

This strategy defines rules for calculating the priority of updating pods. Partition is the number of DaemonSet pods that should be remained to be old version.

  1. apiVersion: apps.kruise.io/v1alpha1
  2. kind: DaemonSet
  3. spec:
  4. # ...
  5. updateStrategy:
  6. type: RollingUpdate
  7. rollingUpdate:
  8. partition: 10

MaxSurge for rolling update

MaxSurge is the maximum number of DaemonSet pods that can be scheduled above the desired number of pods during the update. Only when rollingUpdateType=Surging, it works.

Value can be an absolute number (ex: 5) or a percentage of the total number of DaemonSet pods at the start of the update (ex: 10%). The absolute number is calculated from the percentage by rounding up. This cannot be 0. The default value is 1.

Example: when this is set to 30%, at most 30% of the total number of nodes that should be running the daemon pod (i.e. status.desiredNumberScheduled) can have 2 pods running at any given time. The update starts by starting replacements for at most 30% of those DaemonSet pods. Once the new pods are available it then stops the existing pods before proceeding onto other DaemonSet pods, thus ensuring that at most 130% of the desired final number of DaemonSet pods are running at all times during the update.

  1. apiVersion: apps.kruise.io/v1alpha1
  2. kind: DaemonSet
  3. spec:
  4. # ...
  5. updateStrategy:
  6. rollingUpdate:
  7. rollingUpdateType: Surging
  8. maxSurge: 30%

Paused for rolling update

paused indicates that Pods updating is paused, controller will not update Pods but just maintain the number of replicas.

  1. apiVersion: apps.kruise.io/v1alpha1
  2. kind: DaemonSet
  3. spec:
  4. # ...
  5. updateStrategy:
  6. rollingUpdate:
  7. paused: true