OpenKruise:解放 DaemonSet 運(yùn)維之路
作者?| 王思宇(酒祝)

前言

背景
apiVersion: apps/v1kind: DaemonSetspec:updateStrategy:type: RollingUpdaterollingUpdate:maxUnavailable: 2# ...
apiVersion: apps/v1kind: DaemonSetspec:updateStrategy:type: OnDelete# ...

能力解析
const (+ // StandardRollingUpdateType replace the old daemons by new ones using rolling update i.e replace them on each node one after the other.+ // this is the default type for RollingUpdate.+ StandardRollingUpdateType RollingUpdateType = "Standard"+ // SurgingRollingUpdateType replaces 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.+ SurgingRollingUpdateType RollingUpdateType = "Surging")// Spec to control the desired behavior of daemon set rolling update.type RollingUpdateDaemonSet struct {+ // Type is to specify which kind of rollingUpdate.+ Type RollingUpdateType `json:"rollingUpdateType,omitempty" protobuf:"bytes,1,opt,name=rollingUpdateType"`// ...MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,2,opt,name=maxUnavailable"`+ // A label query over nodes that are managed by the daemon set RollingUpdate.+ // Must match in order to be controlled.+ // It must match the node's labels.+ Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,3,opt,name=selector"`+ // The number of DaemonSet pods remained to be old version.+ // Default value is 0.+ // Maximum value is status.DesiredNumberScheduled, which means no pod will be updated.+ // +optional+ Partition *int32 `json:"partition,omitempty" protobuf:"varint,4,opt,name=partition"`+ // Indicates that the daemon set is paused and will not be processed by the+ // daemon set controller.+ // +optional+ Paused *bool `json:"paused,omitempty" protobuf:"varint,5,opt,name=paused"`+ // Only when type=SurgingRollingUpdateType, it works.+ // The maximum number of DaemonSet pods that can be scheduled above the desired number of pods+ // during the update. 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.+ // +optional+ MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,7,opt,name=maxSurge"`}type DaemonSetSpec struct {// ...+ // BurstReplicas is a rate limiter for booting pods on a lot of pods.+ // The default value is 250+ BurstReplicas *intstr.IntOrString `json:"burstReplicas,omitempty" protobuf:"bytes,5,opt,name=burstReplicas"`}
1. 按節(jié)點(diǎn)灰度
apiVersion: apps.kruise.io/v1alpha1kind: DaemonSetspec:# ...updateStrategy:type: RollingUpdaterollingUpdate:selector:matchLabels:nodeType: canary
2. 按數(shù)量灰度
apiVersion: apps.kruise.io/v1alpha1kind: DaemonSetspec:# ...updateStrategy:type: RollingUpdaterollingUpdate:partition: 100
status.DesiredNumberScheduled - partition 數(shù)量的 Pod 滾動(dòng)升級(jí)為新版本。3. 多維度灰度
apiVersion: apps.kruise.io/v1alpha1kind: DaemonSetspec:# ...updateStrategy:type: RollingUpdaterollingUpdate:maxUnavailable: 5partition: 100selector:matchLabels:nodeType: canary
4. 熱升級(jí)
apiVersion: apps.kruise.io/v1alpha1kind: DaemonSetspec:# ...updateStrategy:rollingUpdate:type: Surging # defaults to StandardmaxSurge: 30%
type: Surging,這個(gè)類(lèi)型默認(rèn)是 Standard -- 也就是先刪再擴(kuò),而一旦設(shè)置為 Surging 則變?yōu)橄葦U(kuò)再縮。也就是在滾動(dòng)升級(jí)時(shí),DaemonSet 會(huì)先在要發(fā)布的 Node 上新建一個(gè) Pod,等這個(gè)新版本 Pod 變?yōu)?ready 之后再把舊版本 Pod 刪除掉。5. 發(fā)布暫停
apiVersion: apps.kruise.io/v1alpha1kind: DaemonSetspec:# ...updateStrategy:rollingUpdate:paused: true

總結(jié)

評(píng)論
圖片
表情
