やったこと
Deployment を使ってみます。
確認環境
$ k version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:18:23Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3", GitCommit:"1e11e4a2108024935ecfcb2912226cedeafd99df", GitTreeState:"clean", BuildDate:"2020-10-14T12:41:49Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}
調査
sample3.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment-first
spec:
replicas: 2
selector:
matchLabels:
app: sample3
template:
metadata:
labels:
app: sample3
spec:
containers:
- name: nginx-container
image: nginx:1.16
マニフェストの適用
$ k apply -f sample3.yaml
deployment.apps/my-deployment-first created
$ k get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
my-deployment-first 2/2 2 2 78s
$ k get rs
NAME DESIRED CURRENT READY AGE
my-deployment-first-55df95dccf 2 2 2 3m37s
$ k get pods
NAME READY STATUS RESTARTS AGE
my-deployment-first-55df95dccf-8d9ld 1/1 Running 0 92s
my-deployment-first-55df95dccf-pcmr8 1/1 Running 0 90s
sample3.yaml を編集します。
image: nginx:1.17
$ k apply -f sample3.yaml
deployment.apps/my-deployment-first configured
$ k get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
my-deployment-first 2/2 0 2 20m
$ k get rs
NAME DESIRED CURRENT READY AGE
my-deployment-first-55df95dccf 2 2 2 5m19s
my-deployment-first-5b8875c9cb 1 1 0 20m
$ k get pods
NAME READY STATUS RESTARTS AGE
my-deployment-first-55df95dccf-8d9ld 1/1 Running 0 2m48s
my-deployment-first-55df95dccf-pcmr8 1/1 Running 0 2m46s
my-deployment-first-5b8875c9cb-qp66z 0/1 ContainerCreating 0 0s
更新戦略の確認 ( .spec.strategy
)
- Recreate
- RollingUpdate (デフォルト)
$ k get deployment -o jsonpath="{.items[*].spec.strategy}"
map[rollingUpdate:map[maxSurge:25% maxUnavailable:25%] type:RollingUpdate]