You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice that, even though the update strategy is `RollingUpdate` the StatefulSet
714
-
restored the Pod with its original container. This is because the
723
+
restored the Pod with the original container image. This is because the
715
724
ordinal of the Pod is less than the `partition` specified by the
716
725
`updateStrategy`.
717
726
718
727
#### Rolling out a canary
719
728
720
-
You can roll out a canary to test a modification by decrementing the `partition`
729
+
You're now going to try a [canary rollout](https://glossary.cncf.io/canary-deployment/)
730
+
of that staged change.
731
+
732
+
You can roll out a canary (to test the modified template) by decrementing the `partition`
721
733
you specified [above](#staging-an-update).
722
734
723
735
Patch the StatefulSet to decrement the partition:
@@ -731,7 +743,10 @@ kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"RollingUpda
731
743
statefulset.apps/web patched
732
744
```
733
745
734
-
Wait for `web-2` to be Running and Ready.
746
+
The control plane triggers replacement for `web-2` (implemented by
747
+
a graceful **delete** followed by creating a new Pod once the deletion
748
+
is complete).
749
+
Wait for the new `web-2` Pod to be Running and Ready.
735
750
736
751
```shell
737
752
# This should already be running
@@ -863,18 +878,32 @@ continue the update process.
863
878
864
879
### OnDelete {#on-delete}
865
880
866
-
The `OnDelete` update strategy implements the legacy (1.6 and prior) behavior,
867
-
When you select this update strategy, the StatefulSet controller will not
868
-
automatically update Pods when a modification is made to the StatefulSet's
869
-
`.spec.template` field. This strategy can be selected by setting the
881
+
You select this update strategy for a StatefulSet by setting the
870
882
`.spec.template.updateStrategy.type` to `OnDelete`.
871
883
884
+
Patch the `web` StatefulSet to use the `OnDelete` update strategy:
885
+
886
+
```shell
887
+
kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"OnDelete"}}}'
888
+
```
889
+
```
890
+
statefulset.apps/web patched
891
+
```
892
+
893
+
When you select this update strategy, the StatefulSet controller does not
894
+
automatically update Pods when a modification is made to the StatefulSet's
895
+
`.spec.template` field. You need to manage the rollout yourself - either
896
+
manually, or using separate automation.
872
897
873
898
## Deleting StatefulSets
874
899
875
-
StatefulSet supports both Non-Cascading and Cascading deletion. In a
876
-
Non-Cascading Delete, the StatefulSet's Pods are not deleted when the StatefulSet is deleted. In a Cascading Delete, both the StatefulSet and its Pods are
877
-
deleted.
900
+
StatefulSet supports both _non-cascading_ and _cascading_ deletion. In a
901
+
non-cascading **delete**, the StatefulSet's Pods are not deleted when the
902
+
StatefulSet is deleted. In a cascading **delete**, both the StatefulSet and
903
+
its Pods are deleted.
904
+
905
+
Read [Use Cascading Deletion in a Cluster](/docs/tasks/administer-cluster/use-cascading-deletion/)
906
+
to learn about cascading deletion generally.
878
907
879
908
### Non-cascading delete
880
909
@@ -888,7 +917,7 @@ kubectl get pods --watch -l app=nginx
888
917
Use [`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands/#delete) to delete the
889
918
StatefulSet. Make sure to supply the `--cascade=orphan` parameter to the
890
919
command. This parameter tells Kubernetes to only delete the StatefulSet, and to
891
-
not delete any of its Pods.
920
+
**not** delete any of its Pods.
892
921
893
922
```shell
894
923
kubectl delete statefulset web --cascade=orphan
@@ -982,7 +1011,7 @@ with `replicas` equal to 2, once `web-0` had been recreated, and once
982
1011
`web-1` had been determined to already be Running and Ready, `web-2` was
983
1012
terminated.
984
1013
985
-
Let's take another look at the contents of the `index.html` file served by the
1014
+
Now take another look at the contents of the `index.html` file served by the
986
1015
Pods' webservers:
987
1016
988
1017
```shell
@@ -1051,7 +1080,7 @@ the Pod's successor to be completely terminated.
1051
1080
1052
1081
{{< note >}}
1053
1082
Although a cascading delete removes a StatefulSet together with its Pods,
1054
-
the cascade does not delete the headless Service associated with the StatefulSet.
1083
+
the cascade does **not** delete the headless Service associated with the StatefulSet.
1055
1084
You must delete the `nginx` Service manually.
1056
1085
{{< /note >}}
1057
1086
@@ -1114,14 +1143,11 @@ statefulset "web" deleted
1114
1143
1115
1144
For some distributed systems, the StatefulSet ordering guarantees are
1116
1145
unnecessary and/or undesirable. These systems require only uniqueness and
1117
-
identity. To address this, in Kubernetes 1.7, we introduced
1118
-
`.spec.podManagementPolicy` to the StatefulSet API Object.
1119
-
1120
-
### OrderedReady Pod management
1146
+
identity.
1121
1147
1122
-
`OrderedReady` pod management is the default for StatefulSets. It tells the
1123
-
StatefulSet controller to respect the ordering guarantees demonstrated
1124
-
above.
1148
+
You can specify a Pod management policy to avoid this strict ordering;
1149
+
either [`OrderedReady`](/docs/concepts/workloads/controllers/statefulset/#orderedready-pod-management) (the default)
1150
+
or [`Parallel`](/docs/concepts/workloads/controllers/statefulset/#parallel-pod-management).
1125
1151
1126
1152
### Parallel Pod management
1127
1153
@@ -1170,7 +1196,8 @@ web-0 1/1 Running 0 10s
1170
1196
web-1 1/1 Running 0 10s
1171
1197
```
1172
1198
1173
-
The StatefulSet controller launched both `web-0` and `web-1` at the same time.
1199
+
The StatefulSet controller launched both `web-0` and `web-1` at almost the
1200
+
same time.
1174
1201
1175
1202
Keep the second terminal open, and, in another terminal window scale the
0 commit comments