[A-00239] Kubernetes 1000本ノック (4)
前回記事はこちら
今回はローリングアップデートのStrategy設定について学習します。
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-dep
namespace: default
spec:
replicas: 2
# RollingUpdate
strategy:
# Recreate or RollingUpdate
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 25%
selector:
matchLabels:
app: hello-dep
template:
metadata:
labels:
app: hello-dep
spec:
containers:
- name: hello-dep
# 1.0 --> 2.0
image: gcr.io/google-samples/hello-app:1.0
imagePullPolicy: Always
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 5
successThreshold: 1
上記をapplyしてhello-app:1.0をhello-app:2.0に書き換えて2回applyします。
下記のようにローリングアップデートが走ることがわかります。
user@usernoMacBook-Pro rolling_update % kubectl apply -f deployment.yml
deployment.apps/hello-dep created
user@usernoMacBook-Pro rolling_update % kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-dep-5c7b8b57b9-nq5vw 0/1 Running 0 7s
hello-dep-5c7b8b57b9-xb52q 0/1 Running 0 7s
kubeshark-front-5fd548d6b-hpps4 1/1 Running 0 3h4m
kubeshark-hub-574fd7bc79-m2hgl 1/1 Running 0 3h4m
kubeshark-worker-daemon-set-q4zn7 1/2 CrashLoopBackOff 25 (74s ago) 3h4m
mynginx-74859d9744-k5rtx 1/1 Running 0 11d
user@usernoMacBook-Pro rolling_update % kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-dep-5c7b8b57b9-nq5vw 1/1 Running 0 15s
hello-dep-5c7b8b57b9-xb52q 1/1 Running 0 15s
kubeshark-front-5fd548d6b-hpps4 1/1 Running 0 3h4m
kubeshark-hub-574fd7bc79-m2hgl 1/1 Running 0 3h4m
kubeshark-worker-daemon-set-q4zn7 1/2 CrashLoopBackOff 25 (82s ago) 3h4m
mynginx-74859d9744-k5rtx 1/1 Running 0 11d
user@usernoMacBook-Pro rolling_update % kubectl apply -f deployment.yml
deployment.apps/hello-dep configured
user@usernoMacBook-Pro rolling_update % kubectl get pod -w
NAME READY STATUS RESTARTS AGE
hello-dep-5c7b8b57b9-nq5vw 1/1 Running 0 44s
hello-dep-5c7b8b57b9-xb52q 1/1 Running 0 44s
hello-dep-c597c4df6-qp9pf 0/1 Running 0 8s
kubeshark-front-5fd548d6b-hpps4 1/1 Running 0 3h5m
kubeshark-hub-574fd7bc79-m2hgl 1/1 Running 0 3h5m
kubeshark-worker-daemon-set-q4zn7 1/2 CrashLoopBackOff 25 (111s ago) 3h5m
mynginx-74859d9744-k5rtx 1/1 Running 0 11d
hello-dep-c597c4df6-qp9pf 1/1 Running 0 10s
hello-dep-5c7b8b57b9-nq5vw 1/1 Terminating 0 46s
hello-dep-c597c4df6-6r2b4 0/1 Pending 0 0s
hello-dep-c597c4df6-6r2b4 0/1 Pending 0 0s
hello-dep-c597c4df6-6r2b4 0/1 ContainerCreating 0 0s
hello-dep-5c7b8b57b9-nq5vw 0/1 Terminating 0 46s
hello-dep-5c7b8b57b9-nq5vw 0/1 Terminating 0 47s
hello-dep-5c7b8b57b9-nq5vw 0/1 Terminating 0 47s
hello-dep-c597c4df6-6r2b4 0/1 Running 0 2s
hello-dep-c597c4df6-6r2b4 1/1 Running 0 10s
hello-dep-5c7b8b57b9-xb52q 1/1 Terminating 0 56s
hello-dep-5c7b8b57b9-xb52q 0/1 Terminating 0 57s
hello-dep-5c7b8b57b9-xb52q 0/1 Terminating 0 57s
hello-dep-5c7b8b57b9-xb52q 0/1 Terminating 0 57s
hello-dep-5c7b8b57b9-xb52q 0/1 Terminating 0 57s
^C%
user@usernoMacBook-Pro rolling_update % kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-dep-c597c4df6-6r2b4 1/1 Running 0 34s
hello-dep-c597c4df6-qp9pf 1/1 Running 0 44s
kubeshark-front-5fd548d6b-hpps4 1/1 Running 0 3h5m
kubeshark-hub-574fd7bc79-m2hgl 1/1 Running 0 3h5m
kubeshark-worker-daemon-set-q4zn7 1/2 CrashLoopBackOff 25 (2m27s ago) 3h5m
mynginx-74859d9744-k5rtx 1/1 Running 0 11d
・Appendix
参考文献はこちら
コメントを残す