@@ -447,100 +447,12 @@ caused by scaling the StatefulSet down.
447
447
448
448
## Updating StatefulSets
449
449
450
- In Kubernetes 1.7, the StatefulSet controller supports automated updates. The
450
+ In Kubernetes 1.7 and later , the StatefulSet controller supports automated updates. The
451
451
strategy used is determined by the ` spec.updateStrategy ` field of the
452
452
StatefulSet API Object. This feature can be used to upgrade the container
453
453
images, resource requests and/or limits, labels, and annotations of the Pods in a
454
- StatefulSet. There are two valid update strategies, ` OnDelete ` and
455
- ` RollingUpdate ` .
456
-
457
- ### On Delete
458
- The ` OnDelete ` update strategy implements the legacy (prior to 1.7) behavior,
459
- and it is the default update strategy. When you select this update strategy,
460
- the StatefulSet controller will not automatically update Pods when a
461
- modification is made to the StatefulSet's ` .spec.template ` field.
462
-
463
- Patch the container image for the ` web ` StatefulSet.
464
-
465
- ``` shell
466
- kubectl patch statefulset web --type=' json' -p=' [{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"gcr.io/google_containers/nginx-slim:0.7"}]'
467
- " web" patched
468
- ```
469
-
470
- Delete the ` web-0 ` Pod.
471
-
472
- ``` shell
473
- kubectl delete pod web-0
474
- pod " web-0" deleted
475
- ```
476
-
477
- Watch the ` web-0 ` Pod, and wait for it to transition to Running and Ready.
478
-
479
- ``` shell
480
- kubectl get pod web-0 -w
481
- NAME READY STATUS RESTARTS AGE
482
- web-0 1/1 Running 0 54s
483
- web-0 1/1 Terminating 0 1m
484
- web-0 0/1 Terminating 0 1m
485
- web-0 0/1 Terminating 0 1m
486
- web-0 0/1 Terminating 0 1m
487
- web-0 0/1 Pending 0 0s
488
- web-0 0/1 Pending 0 0s
489
- web-0 0/1 ContainerCreating 0 0s
490
- web-0 1/1 Running 0 3s
491
- ```
492
-
493
- Get the ` web ` StatefulSet's Pods to view their container images.
494
-
495
- ``` shell{% raw %}
496
- kubectl get pod -l app=nginx -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].image}{"\n"}{end}'
497
- web-0 gcr.io/google_containers/nginx-slim:0.7
498
- web-1 gcr.io/google_containers/nginx-slim:0.8
499
- web-2 gcr.io/google_containers/nginx-slim:0.8
500
- {% endraw %}```
501
-
502
- `web-0` has had its image updated, but `web-1` and `web-2` still have the original
503
- image. Complete the update by deleting the remaining Pods.
504
-
505
- ```shell
506
- kubectl delete pod web-1 web-2
507
- pod "web-1" deleted
508
- pod "web-2" deleted
509
- ```
510
-
511
- Watch the StatefulSet's Pods, and wait for all of them to transition to Running and Ready.
512
-
513
- ```
514
- kubectl get pods -w -l app=nginx
515
- NAME READY STATUS RESTARTS AGE
516
- web-0 1/1 Running 0 8m
517
- web-1 1/1 Running 0 4h
518
- web-2 1/1 Running 0 23m
519
- NAME READY STATUS RESTARTS AGE
520
- web-1 1/1 Terminating 0 4h
521
- web-1 1/1 Terminating 0 4h
522
- web-1 0/1 Pending 0 0s
523
- web-1 0/1 Pending 0 0s
524
- web-1 0/1 ContainerCreating 0 0s
525
- web-2 1/1 Terminating 0 23m
526
- web-2 1/1 Terminating 0 23m
527
- web-1 1/1 Running 0 4s
528
- web-2 0/1 Pending 0 0s
529
- web-2 0/1 Pending 0 0s
530
- web-2 0/1 ContainerCreating 0 0s
531
- web-2 1/1 Running 0 36s
532
- ```
533
-
534
- Get the Pods to view their container images.
535
-
536
- ``` shell{% raw %}
537
- kubectl get pod -l app=nginx -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].image}{"\n"}{end}'
538
- web-0 gcr.io/google_containers/nginx-slim:0.7
539
- web-1 gcr.io/google_containers/nginx-slim:0.7
540
- web-2 gcr.io/google_containers/nginx-slim:0.7
541
- {% endraw %}```
542
-
543
- All the Pods in the StatefulSet are now running a new container image.
454
+ StatefulSet. There are two valid update strategies, ` RollingUpdate ` and
455
+ ` OnDelete ` .
544
456
545
457
### Rolling Update
546
458
@@ -797,6 +709,15 @@ gcr.io/google_containers/nginx-slim:0.7
797
709
By moving the `partition` to `0`, you allowed the StatefulSet controller to
798
710
continue the update process.
799
711
712
+ ### On Delete
713
+
714
+ The `OnDelete` update strategy implements the legacy (1.6 and prior) behavior,
715
+ When you select this update strategy, the StatefulSet controller will not
716
+ automatically update Pods when a modification is made to the StatefulSet' s
717
+ ` .spec.template` field. This strategy can be selected by setting the
718
+ ` .spec.template.updateStrategy.type` to ` OnDelete` .
719
+
720
+
800
721
# # Deleting StatefulSets
801
722
802
723
StatefulSet supports both Non-Cascading and Cascading deletion. In a
0 commit comments