Kubernetes: Basic Deployments

1) Basic Deployment Example

nano myDeployment.yaml apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
kubectl create -f myDeployment.yamldeployment.apps/busybox-deployment created
kubectl rollout status deployment.v1.apps/busybox-deploymentWaiting for deployment "busybox-deployment" rollout to finish: 7 of 10 updated replicas are available...
Waiting for deployment "busybox-deployment" rollout to finish: 8 of 10 updated replicas are available...
Waiting for deployment "busybox-deployment" rollout to finish: 9 of 10 updated replicas are available...
deployment "busybox-deployment" successfully rolled out
kubectl get deployNAME                 DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
busybox-deployment 10 10 10 10 23s
kubectl describe deployment.extensions/busybox-deploymentName:                   busybox-deployment
Namespace: default
CreationTimestamp: Sat, 19 Jan 2019 07:51:48 +0200
Labels: app=busybox
Annotations: deployment.kubernetes.io/revision: 1
Selector: app=busybox
Replicas: 10 desired | 10 updated | 10 total | 10 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=busybox
Containers:
busybox:
Image: busybox
Port: <none>
Host Port: <none>
Command:
sh
-c
echo Container 1 is Running ; sleep 3600
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: busybox-deployment-668d59f6b7 (10/10 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 68s deployment-controller Scaled up replica set busybox-deployment-668d59f6b7 to 10
kubectl get pods --show-labelsNAME                                  READY   STATUS    RESTARTS   AGE    LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
PS C:\k8>
kubectl rollout history deployment.v1.apps/busybox-deploymentdeployment.apps/busybox-deploymentREVISION  CHANGE-CAUSE
1 <none>
kubectl delete -f myDeployment.yaml --force --grace-period=0deployment.apps "busybox-deployment" force deleted
kubectl get pods --show-labelsNAME                                  READY   STATUS        RESTARTS   AGE     LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
kubectl get pods --show-labelsNAME                                  READY   STATUS        RESTARTS   AGE     LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
kubectl get pods --show-labelsNAME                                  READY   STATUS        RESTARTS   AGE     LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
kubectl get pods --show-labelsNAME                                  READY   STATUS        RESTARTS   AGE     LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
kubectl get pods --show-labelsNAME                                  READY   STATUS        RESTARTS   AGE     LABELS
busybox-deployment-668d59f6b7-762nm 0/1 Terminating 0 6m49s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m49s app=busybox,pod-template-hash=668d59f6b7
kubectl get pods --show-labelsNo resources found.

2) terminationGracePeriodSeconds: 0

apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
terminationGracePeriodSeconds: 0
kubectl create -f myDeployment.yamldeployment.apps/busybox-deployment created
kubectl get pods --show-labelsNAME                                 READY   STATUS              RESTARTS   AGE   LABELS
busybox-deployment-5d6889b44-7xrxh 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-8d56t 1/1 Running 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-b7xbs 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-bng4z 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-cs5tx 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-fhrnf 1/1 Running 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-jz985 1/1 Running 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-mtmm2 0/1 Pending 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-nv54h 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-v9rzg 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
kubectl get pods --show-labelsNAME                                 READY   STATUS    RESTARTS   AGE   LABELS
busybox-deployment-5d6889b44-7xrxh 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-8d56t 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-b7xbs 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-bng4z 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-cs5tx 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-fhrnf 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-jz985 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-mtmm2 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-nv54h 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-v9rzg 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
kubectl delete -f myDeployment.yaml --force --grace-period=0deployment.apps "busybox-deployment" force deleted
kubectl get pods --show-labels
No resources found.

3) Updating the Image in a Pod

nano myDeployment.yaml apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
terminationGracePeriodSeconds: 10
kubectl create -f myDeployment.yamldeployment.apps/busybox-deployment created
kubectl get deployNAME                 DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
busybox-deployment 10 10 10 10 1m
kubectl set image deployment.v1.apps/busybox-deployment busybox=busybox:1.29.3 --record
kubectl get pods --show-labelsNAME                                  READY   STATUS              RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-2vhm9 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-4sqlh 1/1 Running 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-5jhwz 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-7lzdg 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cxx7s 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ftxht 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h8kxp 1/1 Running 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hqd4s 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jwfvc 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-srfxd 1/1 Running 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-5cxs9 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6v4z6 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7qmxt 0/1 Pending 0 1s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-cc7th 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d6wt5 0/1 Pending 0 1s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dgzq4 0/1 ContainerCreating 0 4s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-fjk7t 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-jhrrj 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pdwgm 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-thd5m 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labelsNAME                                  READY   STATUS              RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-2vhm9 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-4sqlh 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-5jhwz 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-7lzdg 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cxx7s 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ftxht 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h8kxp 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hqd4s 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jwfvc 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-srfxd 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-5cxs9 1/1 Running 0 6s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6v4z6 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7qmxt 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-cc7th 1/1 Running 0 6s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d6wt5 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dgzq4 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-fjk7t 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-jhrrj 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pdwgm 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-thd5m 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labelsNAME                                  READY   STATUS        RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-2vhm9 0/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-4sqlh 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-5jhwz 0/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-7lzdg 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cxx7s 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ftxht 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h8kxp 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hqd4s 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jwfvc 0/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-srfxd 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-5cxs9 1/1 Running 0 10s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6v4z6 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7qmxt 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-cc7th 1/1 Running 0 10s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d6wt5 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dgzq4 1/1 Running 0 12s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-fjk7t 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-jhrrj 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pdwgm 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-thd5m 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
kubectl delete -f myDeployment.yamldeployment.apps "busybox-deployment" force deleted

4) maxUnavailable and maxSurge

nano myDeployment.yaml apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 5
maxUnavailable: 5
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
terminationGracePeriodSeconds: 10
kubectl create -f myDeployment.yamldeployment.apps/busybox-deployment created
kubectl get pods --show-labelsNAME                                  READY   STATUS              RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-f992m 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-gt6wc 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ht94m 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jbz8j 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jjtqx 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-k8bcf 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-mwfnm 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-nqbml 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rz5bj 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-v2fcf 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-425zn 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-4hnmx 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7lmp7 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-b426t 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dbgvb 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-hl2m2 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-kr7dt 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsvq8 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-vsmqp 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-wtfnc 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labelsNAME                                  READY   STATUS              RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-f992m 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-gt6wc 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ht94m 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jbz8j 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jjtqx 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-k8bcf 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-mwfnm 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-nqbml 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rz5bj 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-v2fcf 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-425zn 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-4hnmx 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7lmp7 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-b426t 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dbgvb 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-hl2m2 0/1 ContainerCreating 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-kr7dt 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsvq8 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-vsmqp 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-wtfnc 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labelsNAME                                  READY   STATUS        RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-f992m 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-gt6wc 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ht94m 0/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jbz8j 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-k8bcf 0/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-mwfnm 0/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rz5bj 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-v2fcf 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-425zn 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-4hnmx 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7lmp7 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-b426t 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dbgvb 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-hl2m2 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-kr7dt 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsvq8 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-vsmqp 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-wtfnc 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
PS C:\k8>
kubectl delete -f myDeployment.yaml --force --grace-period=0deployment.apps "busybox-deployment" force deleted

5) maxSurge: 5 maxUnavailable: 5

nano myDeployment.yaml apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 5
maxUnavailable: 1
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
terminationGracePeriodSeconds: 10
kubectl create -f myDeployment.yamldeployment.apps/busybox-deployment created
kubectl get pods --show-labelsNAME                                  READY   STATUS    RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-54gkx 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-96w9b 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cbpw4 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h97jv 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hm8r8 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hp2jn 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-l5swd 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-nvcsz 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-q6ssv 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-qhtd7 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
PS C:\k8>
kubectl set image deployment.v1.apps/busybox-deployment busybox=busybox:1.29.3 --recorddeployment.apps/busybox-deployment image updated
kubectl get pods --show-labelsNAME                                  READY   STATUS              RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-54gkx 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-96w9b 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cbpw4 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h97jv 1/1 Terminating 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hm8r8 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hp2jn 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-l5swd 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-nvcsz 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-q6ssv 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-qhtd7 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-6hbmn 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-9qmp8 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-b5b9h 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-bsbt2 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-cv8vz 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qrbmc 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
kubectl delete -f myDeployment.yaml --force --grace-period=0deployment.apps "busybox-deployment" force deleted

6) maxSurge: 10 maxUnavailable: 10

nano myDeployment.yaml apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 10
maxUnavailable: 10
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
terminationGracePeriodSeconds: 10
kubectl create -f myDeployment.yamldeployment.apps/busybox-deployment created
kubectl get pods --show-labelsNAME                                  READY   STATUS              RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-4x7dr 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-97284 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-bfrvv 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-fplhq 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ms8dh 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-prm86 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rzknx 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-sptzx 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-vf4kd 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-wcwg4 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-2dzfc 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-2sdqj 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6xr8w 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7s62s 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d9zmg 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-nqn9k 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pn2td 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsq6d 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-rkmtk 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-shvxp 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labelsNAME                                  READY   STATUS              RESTARTS   AGE   LABELS
busybox-deployment-6b48b9cb8f-4x7dr 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-97284 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-bfrvv 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-fplhq 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ms8dh 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-prm86 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rzknx 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-sptzx 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-vf4kd 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-wcwg4 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-2dzfc 0/1 Pending 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-2sdqj 0/1 Pending 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6xr8w 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7s62s 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d9zmg 0/1 Pending 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-nqn9k 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pn2td 0/1 Pending 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsq6d 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-rkmtk 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-shvxp 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
kubectl delete -f myDeployment.yamldeployment.apps "busybox-deployment" force deleted

Conclusion

maxSurge: 1
maxUnavailable: 1
kubectl delete -f myDeployment.yaml --force --grace-period=0deployment.apps "busybox-deployment" force deletedBy Alwyn Botha, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud's incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.We use Deployments to define how many replicas of a Pod we want to be running. Kubernetes then continuously drives the state of running Pods to match our desired number of replicas.If one of those Pods get deleted by accident, Kubernetes will automatically create a new one to replace it.Deployments have other features as well:

1) Basic Deployment Example

nano myDeployment.yaml 

apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']
kubectl create -f myDeployment.yaml

deployment.apps/busybox-deployment created
kubectl rollout status deployment.v1.apps/busybox-deployment

Waiting for deployment "busybox-deployment" rollout to finish: 7 of 10 updated replicas are available...
Waiting for deployment "busybox-deployment" rollout to finish: 8 of 10 updated replicas are available...
Waiting for deployment "busybox-deployment" rollout to finish: 9 of 10 updated replicas are available...
deployment "busybox-deployment" successfully rolled out
kubectl get deploy

NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
busybox-deployment 10 10 10 10 23s
kubectl describe deployment.extensions/busybox-deployment

Name: busybox-deployment
Namespace: default
CreationTimestamp: Sat, 19 Jan 2019 07:51:48 +0200
Labels: app=busybox
Annotations: deployment.kubernetes.io/revision: 1
Selector: app=busybox
Replicas: 10 desired | 10 updated | 10 total | 10 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=busybox
Containers:
busybox:
Image: busybox
Port: <none>
Host Port: <none>
Command:
sh
-c
echo Container 1 is Running ; sleep 3600
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: busybox-deployment-668d59f6b7 (10/10 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 68s deployment-controller Scaled up replica set busybox-deployment-668d59f6b7 to 10
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Running 0 3m6s app=busybox,pod-template-hash=668d59f6b7
PS C:\k8>
kubectl rollout history deployment.v1.apps/busybox-deployment

deployment.apps/busybox-deployment

REVISION CHANGE-CAUSE
1 <none>
kubectl delete -f myDeployment.yaml --force --grace-period=0

deployment.apps "busybox-deployment" force deleted
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Terminating 0 6m13s app=busybox,pod-template-hash=668d59f6b7
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Terminating 0 6m17s app=busybox,pod-template-hash=668d59f6b7
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Terminating 0 6m26s app=busybox,pod-template-hash=668d59f6b7
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-668d59f6b7-762nm 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-9sglb 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-f5728 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-gzwbr 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-j8b9g 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-nszns 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-sm86q 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-w99jh 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-xgbfq 1/1 Terminating 0 6m41s app=busybox,pod-template-hash=668d59f6b7
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-668d59f6b7-762nm 0/1 Terminating 0 6m49s app=busybox,pod-template-hash=668d59f6b7
busybox-deployment-668d59f6b7-rm7lb 1/1 Terminating 0 6m49s app=busybox,pod-template-hash=668d59f6b7

kubectl get pods --show-labels

No resources found.

2) terminationGracePeriodSeconds: 0

apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']

terminationGracePeriodSeconds: 0
kubectl create -f myDeployment.yaml

deployment.apps/busybox-deployment created
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-5d6889b44-7xrxh 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-8d56t 1/1 Running 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-b7xbs 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-bng4z 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-cs5tx 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-fhrnf 1/1 Running 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-jz985 1/1 Running 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-mtmm2 0/1 Pending 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-nv54h 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-v9rzg 0/1 ContainerCreating 0 3s app=busybox,pod-template-hash=5d6889b44
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-5d6889b44-7xrxh 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-8d56t 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-b7xbs 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-bng4z 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-cs5tx 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-fhrnf 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-jz985 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-mtmm2 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-nv54h 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
busybox-deployment-5d6889b44-v9rzg 1/1 Running 0 9s app=busybox,pod-template-hash=5d6889b44
kubectl delete -f myDeployment.yaml --force --grace-period=0

deployment.apps "busybox-deployment" force deleted
kubectl get pods --show-labels
No resources found.

3) Updating the Image in a Pod

nano myDeployment.yaml 

apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']

terminationGracePeriodSeconds: 10
kubectl create -f myDeployment.yaml

deployment.apps/busybox-deployment created
kubectl get deploy

NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
busybox-deployment 10 10 10 10 1m
kubectl set image deployment.v1.apps/busybox-deployment busybox=busybox:1.29.3 --record
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-2vhm9 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-4sqlh 1/1 Running 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-5jhwz 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-7lzdg 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cxx7s 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ftxht 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h8kxp 1/1 Running 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hqd4s 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jwfvc 1/1 Terminating 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-srfxd 1/1 Running 0 22s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-5cxs9 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6v4z6 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7qmxt 0/1 Pending 0 1s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-cc7th 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d6wt5 0/1 Pending 0 1s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dgzq4 0/1 ContainerCreating 0 4s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-fjk7t 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-jhrrj 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pdwgm 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-thd5m 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-2vhm9 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-4sqlh 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-5jhwz 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-7lzdg 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cxx7s 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ftxht 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h8kxp 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hqd4s 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jwfvc 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-srfxd 1/1 Terminating 0 26s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-5cxs9 1/1 Running 0 6s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6v4z6 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7qmxt 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-cc7th 1/1 Running 0 6s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d6wt5 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dgzq4 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-fjk7t 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-jhrrj 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pdwgm 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-thd5m 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-2vhm9 0/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-4sqlh 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-5jhwz 0/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-7lzdg 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cxx7s 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ftxht 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h8kxp 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hqd4s 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jwfvc 0/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-srfxd 1/1 Terminating 0 30s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-5cxs9 1/1 Running 0 10s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6v4z6 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7qmxt 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-cc7th 1/1 Running 0 10s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d6wt5 1/1 Running 0 9s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dgzq4 1/1 Running 0 12s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-fjk7t 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-jhrrj 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pdwgm 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-thd5m 1/1 Running 0 13s app=busybox,pod-template-hash=8866dfbb4
kubectl delete -f myDeployment.yaml

deployment.apps "busybox-deployment" force deleted

4) maxUnavailable and maxSurge

nano myDeployment.yaml 

apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 5
maxUnavailable: 5
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']

terminationGracePeriodSeconds: 10
kubectl create -f myDeployment.yaml

deployment.apps/busybox-deployment created
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-f992m 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-gt6wc 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ht94m 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jbz8j 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jjtqx 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-k8bcf 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-mwfnm 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-nqbml 1/1 Terminating 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rz5bj 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-v2fcf 1/1 Running 0 27s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-425zn 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-4hnmx 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7lmp7 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-b426t 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dbgvb 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-hl2m2 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-kr7dt 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsvq8 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-vsmqp 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-wtfnc 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-f992m 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-gt6wc 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ht94m 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jbz8j 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jjtqx 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-k8bcf 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-mwfnm 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-nqbml 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rz5bj 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-v2fcf 1/1 Terminating 0 33s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-425zn 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-4hnmx 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7lmp7 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-b426t 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dbgvb 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-hl2m2 0/1 ContainerCreating 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-kr7dt 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsvq8 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-vsmqp 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-wtfnc 1/1 Running 0 8s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-f992m 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-gt6wc 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ht94m 0/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-jbz8j 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-k8bcf 0/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-mwfnm 0/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rz5bj 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-v2fcf 1/1 Terminating 0 39s app=busybox,pod-template-hash=6b48b9cb8f

busybox-deployment-8866dfbb4-425zn 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-4hnmx 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7lmp7 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-b426t 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-dbgvb 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-hl2m2 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-kr7dt 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsvq8 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-vsmqp 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-wtfnc 1/1 Running 0 14s app=busybox,pod-template-hash=8866dfbb4
PS C:\k8>
kubectl delete -f myDeployment.yaml --force --grace-period=0

deployment.apps "busybox-deployment" force deleted

5) maxSurge: 5 maxUnavailable: 5

nano myDeployment.yaml 

apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 5
maxUnavailable: 1
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']

terminationGracePeriodSeconds: 10
kubectl create -f myDeployment.yaml

deployment.apps/busybox-deployment created
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-54gkx 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-96w9b 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cbpw4 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h97jv 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hm8r8 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hp2jn 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-l5swd 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-nvcsz 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-q6ssv 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-qhtd7 1/1 Running 0 7s app=busybox,pod-template-hash=6b48b9cb8f
PS C:\k8>
kubectl set image deployment.v1.apps/busybox-deployment busybox=busybox:1.29.3 --record

deployment.apps/busybox-deployment image updated
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-54gkx 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-96w9b 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-cbpw4 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-h97jv 1/1 Terminating 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hm8r8 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-hp2jn 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-l5swd 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-nvcsz 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-q6ssv 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-qhtd7 1/1 Running 0 35s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-6hbmn 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-9qmp8 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-b5b9h 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-bsbt2 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-cv8vz 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qrbmc 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
kubectl delete -f myDeployment.yaml --force --grace-period=0

deployment.apps "busybox-deployment" force deleted

6) maxSurge: 10 maxUnavailable: 10

nano myDeployment.yaml 

apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-deployment
labels:
app: busybox
spec:
replicas: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 10
maxUnavailable: 10
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent

command: ['sh', '-c', 'echo Container 1 is Running ; sleep 3600']

terminationGracePeriodSeconds: 10
kubectl create -f myDeployment.yaml

deployment.apps/busybox-deployment created
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-4x7dr 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-97284 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-bfrvv 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-fplhq 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ms8dh 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-prm86 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rzknx 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-sptzx 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-vf4kd 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-wcwg4 1/1 Terminating 0 21s app=busybox,pod-template-hash=6b48b9cb8f

busybox-deployment-8866dfbb4-2dzfc 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-2sdqj 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6xr8w 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7s62s 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d9zmg 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-nqn9k 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pn2td 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsq6d 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-rkmtk 0/1 Pending 0 2s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-shvxp 0/1 ContainerCreating 0 2s app=busybox,pod-template-hash=8866dfbb4
kubectl get pods --show-labels

NAME READY STATUS RESTARTS AGE LABELS
busybox-deployment-6b48b9cb8f-4x7dr 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-97284 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-bfrvv 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-fplhq 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-ms8dh 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-prm86 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-rzknx 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-sptzx 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-vf4kd 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-6b48b9cb8f-wcwg4 1/1 Terminating 0 24s app=busybox,pod-template-hash=6b48b9cb8f
busybox-deployment-8866dfbb4-2dzfc 0/1 Pending 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-2sdqj 0/1 Pending 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-6xr8w 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-7s62s 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-d9zmg 0/1 Pending 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-nqn9k 1/1 Running 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-pn2td 0/1 Pending 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-qsq6d 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-rkmtk 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
busybox-deployment-8866dfbb4-shvxp 0/1 ContainerCreating 0 5s app=busybox,pod-template-hash=8866dfbb4
kubectl delete -f myDeployment.yaml

deployment.apps "busybox-deployment" force deleted

Conclusion

maxSurge: 1
maxUnavailable: 1
kubectl delete -f myDeployment.yaml --force --grace-period=0

deployment.apps "busybox-deployment" force deleted

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store