-
Create Deployment
kubectl apply -f deployment.yaml
-
Check
kubectl get deployment
kubectl get replicaset
kubectl get replicaset nginx-xxxx -o yaml
- You can see the replicaset is created by
Deployment
inownerReferences
field. - You can also see
pod-template-hash
, which is added byDeployment
.
kubectl get pod
- You can see the replicaset is created by
-
Change replicas
-
Update
replicas: 2
indeployment.yaml
-
Apply it
kubectl apply deployment.yaml
rollout isn't triggered as
replica
is not in the pod template.
-
-
Change image by command
kubectl set image deployment/nginx nginx=nginx:1.15
check:
kubectl get rs
You can see two replicasets; one is old one, the other is new one.
-
Change image by updating yaml file.
-
Change
nginx:1.14
->nginx:1.15
in deployment.yaml -
Apply it
kubectl apply -f deployment.yaml
-
You can check the replicasets
kubectl get replicaset
-> 3 replicasets
-
-
Rollback
-
Check rollout history.
kubectl rollout history deployment.v1.apps/nginx
-
Roll back to the revision 2
kubectl rollout undo deployment.v1.apps/nginx --to-revision=2
-
Check replicaset
kubectl get rs
-> replicaset with
nginx:1.15
has running pods.
-
-
Delete the resources
kubectl delete -f deployment.yaml
04-deployment
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||