Skip to content

Commit 2151c12

Browse files
authored
Merge pull request #36763 from atiratree/apps-new-features
Add blog article about minReadySeconds for StatefulSets and maxSurge for DaemonSets
2 parents 6d45af7 + 1ae414f commit 2151c12

File tree

1 file changed

+86
-0
lines changed
  • content/en/blog/_posts/2022-09-15-sig-apps-GA-1.25

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
layout: blog
3+
title: "Kubernetes 1.25: Two Features for Apps Rollouts Graduate to Stable"
4+
date: 2022-09-15
5+
slug: "app-rollout-features-reach-stable"
6+
---
7+
8+
**Authors:** Ravi Gudimetla (Apple), Filip Křepinský (Red Hat), Maciej Szulik (Red Hat)
9+
10+
This blog describes the two features namely `minReadySeconds` for StatefulSets and `maxSurge` for DaemonSets that SIG Apps is happy to graduate to stable in Kubernetes 1.25.
11+
12+
Specifying `minReadySeconds` slows down a rollout of a StatefulSet, when using a `RollingUpdate` value in `.spec.updateStrategy` field, by waiting for each pod for a desired time.
13+
This time can be used for initializing the pod (e.g. warming up the cache) or as a delay before acknowledging the pod.
14+
15+
`maxSurge` allows a DaemonSet workload to run multiple instances of the same pod on a node during a rollout when using a `RollingUpdate` value in `.spec.updateStrategy` field.
16+
This helps to minimize the downtime of the DaemonSet for consumers.
17+
18+
These features were already available in a Deployment and other workloads. This graduation helps to align this functionality across the workloads.
19+
20+
## What problems do these features solve?
21+
22+
### minReadySeconds for StatefulSets {#solved-problem-statefulset-minreadyseconds}
23+
`minReadySeconds` ensures that the StatefulSet workload is `Ready` for the given number of seconds before reporting the
24+
pod as `Available`. The notion of being `Ready` and `Available` is quite important for workloads. For example, some workloads, like Prometheus with multiple instances of Alertmanager, should be considered `Available` only when the Alertmanager's state transfer is complete. `minReadySeconds` also helps when using loadbalancers with cloud providers. Since the pod should be `Ready` for the given number of seconds, it provides buffer time to prevent killing pods in rotation before new pods show up.
25+
26+
27+
### maxSurge for DaemonSets {#how-use-daemonset-maxsurge}
28+
Kubernetes system-level components like CNI, CSI are typically run as DaemonSets. These components can have impact on the availability of the workloads if those DaemonSets go down momentarily during the upgrades. The feature allows DaemonSet pods to temporarily increase their number, thereby ensuring zero-downtime for the DaemonSets.
29+
30+
Please note that the usage of `hostPort` in conjunction with `maxSurge` in DaemonSets is not allowed as DaemonSet pods are tied to a single node and two active pods cannot share the same port on the same node.
31+
32+
33+
## How does it work?
34+
35+
### minReadySeconds for StatefulSets {#how-does-statefulset-minreadyseconds-work}
36+
37+
The StatefulSet controller watches for the StatefulSet pods and counts how long a particular pod has been in the `Running` state, if this value is greater than or equal to the time specified in `.spec.minReadySeconds` field of the StatefulSet, the StatefulSet controller updates the `AvailableReplicas` field in the StatefulSet's status.
38+
39+
40+
### maxSurge for DaemonSets {#how-does-daemonset-maxsurge-work}
41+
42+
The DaemonSet controller creates the additional pods (above the desired number resulting from DaemonSet spec) based on the value given in `.spec.strategy.rollingUpdate.maxSurge`. The additional pods would run on the same node where the old DaemonSet pod is running till the old pod gets killed.
43+
44+
- The default value is 0.
45+
- The value cannot be `0` when `MaxUnavailable` is 0.
46+
- The value can be specified either as an absolute number of pods, or a percentage (rounded up) of desired pods.
47+
48+
## How do I use it?
49+
50+
### minReadySeconds for StatefulSets {#how-use-statefulset-minreadyseconds}
51+
52+
Specify a value for `minReadySeconds` for any StatefulSet and check if pods are available or not by inspecting
53+
`AvailableReplicas` field using:
54+
55+
`kubectl get statefulset/<name_of_the_statefulset> -o yaml`
56+
57+
Please note that the default value of `minReadySeconds` is 0.
58+
59+
### maxSurge for DaemonSets {#how-use-daemonset-maxsurge}
60+
61+
Specify a value for `.spec.updateStrategy.rollingUpdate.maxSurge` and set `.spec.updateStrategy.rollingUpdate.maxUnavailable` to `0`.
62+
63+
Then observe a faster rollout and higher number of pods running at the same time in the next rollout.
64+
65+
```
66+
kubectl rollout restart daemonset <name_of_the_daemonset>
67+
kubectl get pods -w
68+
```
69+
70+
## How can I learn more?
71+
72+
### minReadySeconds for StatefulSets {#learn-more-statefulset-minreadyseconds}
73+
74+
- Documentation: https://k8s.io/docs/concepts/workloads/controllers/statefulset/#minimum-ready-seconds
75+
- KEP: https://github.com/kubernetes/enhancements/issues/2599
76+
- API Changes: https://github.com/kubernetes/kubernetes/pull/100842
77+
78+
### maxSurge for DaemonSets {#learn-more-daemonset-maxsurge}
79+
80+
- Documentation: https://k8s.io/docs/tasks/manage-daemon/update-daemon-set/
81+
- KEP: https://github.com/kubernetes/enhancements/issues/1591
82+
- API Changes: https://github.com/kubernetes/kubernetes/pull/96375
83+
84+
## How do I get involved?
85+
86+
Please reach out to us on [#sig-apps](https://kubernetes.slack.com/archives/C18NZM5K9) channel on Slack, or through the SIG Apps mailing list [[email protected]](https://groups.google.com/g/kubernetes-sig-apps).

0 commit comments

Comments
 (0)