Skip to content

Commit d723817

Browse files
authored
Merge pull request #44390 from sftim/20231216_revise_statefulset_tutorial
Add comments to shell snippets in StatefulSet tutorial
2 parents 87618b5 + 939c2f5 commit d723817

File tree

1 file changed

+56
-23
lines changed

1 file changed

+56
-23
lines changed

content/en/docs/tutorials/stateful-application/basic-stateful-set.md

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ You will need to use at least two terminal windows. In the first terminal, use
8181
of the StatefulSet's Pods.
8282

8383
```shell
84-
kubectl get pods -w -l app=nginx
84+
# use this terminal to run commands that specify --watch
85+
# end this watch when you are asked to start a new watch
86+
kubectl get pods --watch -l app=nginx
8587
```
8688

8789
In the second terminal, use
@@ -122,7 +124,9 @@ created sequentially, ordered from _{0..n-1}_. Examine the output of the
122124
look like the example below.
123125

124126
```shell
125-
kubectl get pods -w -l app=nginx
127+
# Do not start a new watch;
128+
# this should already be running
129+
kubectl get pods --watch -l app=nginx
126130
```
127131
```
128132
NAME READY STATUS RESTARTS AGE
@@ -221,7 +225,9 @@ contain the Pods' IP addresses.
221225
In one terminal, watch the StatefulSet's Pods:
222226

223227
```shell
224-
kubectl get pod -w -l app=nginx
228+
# Start a new watch
229+
# End this watch when you've seen that the delete is finished
230+
kubectl get pod --watch -l app=nginx
225231
```
226232
In a second terminal, use
227233
[`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands/#delete) to delete all
@@ -239,7 +245,8 @@ Wait for the StatefulSet to restart them, and for both Pods to transition to
239245
Running and Ready:
240246

241247
```shell
242-
kubectl get pod -w -l app=nginx
248+
# This should already be running
249+
kubectl get pod --watch -l app=nginx
243250
```
244251
```
245252
NAME READY STATUS RESTARTS AGE
@@ -364,7 +371,9 @@ before retrying the `curl` command above.
364371
In one terminal, watch the StatefulSet's Pods:
365372

366373
```shell
367-
kubectl get pod -w -l app=nginx
374+
# End this watch when you've reached the end of the section.
375+
# At the start of "Scaling a StatefulSet" you'll start a new watch.
376+
kubectl get pod --watch -l app=nginx
368377
```
369378

370379
In a second terminal, delete all of the StatefulSet's Pods:
@@ -380,7 +389,8 @@ Examine the output of the `kubectl get` command in the first terminal, and wait
380389
for all of the Pods to transition to Running and Ready.
381390

382391
```shell
383-
kubectl get pod -w -l app=nginx
392+
# This should already be running
393+
kubectl get pod --watch -l app=nginx
384394
```
385395
```
386396
NAME READY STATUS RESTARTS AGE
@@ -421,7 +431,10 @@ This is accomplished by updating the `replicas` field. You can use either
421431
In one terminal window, watch the Pods in the StatefulSet:
422432

423433
```shell
424-
kubectl get pods -w -l app=nginx
434+
# If you already have a watch running, you can continue using that.
435+
# Otherwise, start one.
436+
# End this watch when there are 5 healthy Pods for the StatefulSet
437+
kubectl get pods --watch -l app=nginx
425438
```
426439

427440
In another terminal window, use `kubectl scale` to scale the number of replicas
@@ -438,7 +451,8 @@ Examine the output of the `kubectl get` command in the first terminal, and wait
438451
for the three additional Pods to transition to Running and Ready.
439452

440453
```shell
441-
kubectl get pods -w -l app=nginx
454+
# This should already be running
455+
kubectl get pod --watch -l app=nginx
442456
```
443457
```
444458
NAME READY STATUS RESTARTS AGE
@@ -470,7 +484,8 @@ subsequent Pod.
470484
In one terminal, watch the StatefulSet's Pods:
471485

472486
```shell
473-
kubectl get pods -w -l app=nginx
487+
# End this watch when there are only 3 Pods for the StatefulSet
488+
kubectl get pod --watch -l app=nginx
474489
```
475490

476491
In another terminal, use `kubectl patch` to scale the StatefulSet back down to
@@ -486,7 +501,8 @@ statefulset.apps/web patched
486501
Wait for `web-4` and `web-3` to transition to Terminating.
487502

488503
```shell
489-
kubectl get pods -w -l app=nginx
504+
# This should already be running
505+
kubectl get pods --watch -l app=nginx
490506
```
491507
```
492508
NAME READY STATUS RESTARTS AGE
@@ -565,7 +581,10 @@ statefulset.apps/web patched
565581
In another terminal, watch the Pods in the StatefulSet:
566582

567583
```shell
568-
kubectl get pod -l app=nginx -w
584+
# End this watch when the rollout is complete
585+
#
586+
# If you're not sure, leave it running one more minute
587+
kubectl get pod -l app=nginx --watch
569588
```
570589
The output is similar to:
571590
```
@@ -671,7 +690,8 @@ pod "web-2" deleted
671690
Wait for the Pod to be Running and Ready.
672691

673692
```shell
674-
kubectl get pod -l app=nginx -w
693+
# End the watch when you see that web-2 is healthy
694+
kubectl get pod -l app=nginx --watch
675695
```
676696
```
677697
NAME READY STATUS RESTARTS AGE
@@ -703,6 +723,8 @@ you specified [above](#staging-an-update).
703723
Patch the StatefulSet to decrement the partition:
704724

705725
```shell
726+
# The value of "partition" should match the highest existing ordinal for
727+
# the StatefulSet
706728
kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":2}}}}'
707729
```
708730
```
@@ -712,7 +734,8 @@ statefulset.apps/web patched
712734
Wait for `web-2` to be Running and Ready.
713735

714736
```shell
715-
kubectl get pod -l app=nginx -w
737+
# This should already be running
738+
kubectl get pod -l app=nginx --watch
716739
```
717740
```
718741
NAME READY STATUS RESTARTS AGE
@@ -748,7 +771,8 @@ pod "web-1" deleted
748771
Wait for the `web-1` Pod to be Running and Ready.
749772

750773
```shell
751-
kubectl get pod -l app=nginx -w
774+
# This should already be running
775+
kubectl get pod -l app=nginx --watch
752776
```
753777
The output is similar to:
754778
```
@@ -801,7 +825,8 @@ statefulset.apps/web patched
801825
Wait for all of the Pods in the StatefulSet to become Running and Ready.
802826

803827
```shell
804-
kubectl get pod -l app=nginx -w
828+
# This should already be running
829+
kubectl get pod -l app=nginx --watch
805830
```
806831
The output is similar to:
807832
```
@@ -856,7 +881,8 @@ deleted.
856881
In one terminal window, watch the Pods in the StatefulSet.
857882

858883
```
859-
kubectl get pods -w -l app=nginx
884+
# End this watch when there are no Pods for the StatefulSet
885+
kubectl get pods --watch -l app=nginx
860886
```
861887

862888
Use [`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands/#delete) to delete the
@@ -909,7 +935,8 @@ As the `web` StatefulSet has been deleted, `web-0` has not been relaunched.
909935
In one terminal, watch the StatefulSet's Pods.
910936

911937
```shell
912-
kubectl get pods -w -l app=nginx
938+
# Leave this watch running until the next time you start a watch
939+
kubectl get pods --watch -l app=nginx
913940
```
914941

915942
In a second terminal, recreate the StatefulSet. Note that, unless
@@ -930,7 +957,8 @@ headless Service even though that Service already exists.
930957
Examine the output of the `kubectl get` command running in the first terminal.
931958

932959
```shell
933-
kubectl get pods -w -l app=nginx
960+
# This should already be running
961+
kubectl get pods --watch -l app=nginx
934962
```
935963
```
936964
NAME READY STATUS RESTARTS AGE
@@ -977,7 +1005,8 @@ PersistentVolume was remounted.
9771005
In one terminal window, watch the Pods in the StatefulSet.
9781006

9791007
```shell
980-
kubectl get pods -w -l app=nginx
1008+
# Leave this running until the next page section
1009+
kubectl get pods --watch -l app=nginx
9811010
```
9821011

9831012
In another terminal, delete the StatefulSet again. This time, omit the
@@ -995,7 +1024,8 @@ Examine the output of the `kubectl get` command running in the first terminal,
9951024
and wait for all of the Pods to transition to Terminating.
9961025

9971026
```shell
998-
kubectl get pods -w -l app=nginx
1027+
# This should already be running
1028+
kubectl get pods --watch -l app=nginx
9991029
```
10001030

10011031
```
@@ -1108,7 +1138,8 @@ of the `web` StatefulSet is set to `Parallel`.
11081138
In one terminal, watch the Pods in the StatefulSet.
11091139

11101140
```shell
1111-
kubectl get pod -l app=nginx -w
1141+
# Leave this watch running until the end of the section
1142+
kubectl get pod -l app=nginx --watch
11121143
```
11131144

11141145
In another terminal, create the StatefulSet and Service in the manifest:
@@ -1124,7 +1155,8 @@ statefulset.apps/web created
11241155
Examine the output of the `kubectl get` command that you executed in the first terminal.
11251156

11261157
```shell
1127-
kubectl get pod -l app=nginx -w
1158+
# This should already be running
1159+
kubectl get pod -l app=nginx --watch
11281160
```
11291161
```
11301162
NAME READY STATUS RESTARTS AGE
@@ -1177,7 +1209,8 @@ kubectl delete sts web
11771209

11781210
You can watch `kubectl get` to see those Pods being deleted.
11791211
```shell
1180-
kubectl get pod -l app=nginx -w
1212+
# end the watch when you've seen what you need to
1213+
kubectl get pod -l app=nginx --watch
11811214
```
11821215
```
11831216
web-3 1/1 Terminating 0 9m

0 commit comments

Comments
 (0)