Your cart is currently empty!
Kubernetes: Deployments Workload
Resource type alias deploy = deployment = deployments
Create deployments workload with command line:
Shell
x
3
1
kubectl create deploy <deployment_name> --image=<image1_name>,<image2_name>
2
kubectl create deployment <deployment_name> --image=<image1_name>,<image2_name>
3
kubectl create deployments <deployment_name> --image=<image1_name>,<image2_name>
Create deployments workload using YAML file:
YAML
1
22
22
1
apiVersion apps/v1
2
kind Deployment
3
metadata
4
# Unique key of the Deployment instance
5
name deployment-example
6
spec
7
# 3 Pods should exist at all times.
8
replicas3
9
selector
10
matchLabels
11
app nginx
12
template
13
metadata
14
labels
15
# Apply this label to pods and default
16
# the Deployment label selector to this value
17
app nginx
18
spec
19
containers
20
name nginx
21
# Run this image
22
image nginx1.14
Edit deployments workload:
Shell
1
3
1
kubectl edit deploy/<deployment_name>
2
kubectl edit deployment/<deployment_name>
3
kubectl edit deployments/<deployment_name>
Delete deployments workload:
Shell
1
3
1
kubectl delete deploy/<deployment_name>
2
kubectl delete deployment/<deployment_name>
3
kubectl delete deployments/<deployment_name>
Scale deployments workload:
Shell
1
1
1
kubectl scale --replicas=<target_replica_number> deployments/<deployment_name>
Update container image:
Shell
1
3
1
kubectl set image deployments/<deployment_name> \
2
<container_name>=<new_image_name>:<new_image_tag> \
3
--record
Check update status
Shell
1
1
1
kubectl rollout status deployments/<deployment_name>
Check update history
Shell
1
1
1
kubectl rollout history deployments/<deployment_name>
Check update history based on revision
Shell
1
1
1
kubectl rollout history deployments/<deployment_name> --revision=<revision_id>
Undo the updates
Shell
1
1
1
kubectl rollout undo deployments/<deployment_name>
References:
Leave a Reply