Kubernetes Study Notes 3

Source: Internet
Author: User

Kubernetes Auto Release and rollback

Deployment was introduced to better solve the problem of pod orchestration.
    • Create a Deployment object to generate the corresponding replica set and complete the creation of the pod copy
    • Check the status of the deployment to see if the deployment action is complete (the number of pod replicas is up to the expected value)
    • Update deployment to create a new pod (such as a mirror upgrade)
    • If the current deployment is unstable, roll back to an earlier version of deployment
Create deployment
$ kubectl create -f docs/user-guide/nginx-deployment.yaml --recorddeployment "nginx-deployment” created
View deplyment that are being created or are being updated
$ kubectl get deploymentsNAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGEnginx-deployment   3         0         0            0           1s
$ kubectl get deploymentsNAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGEnginx-deployment   3         3         3            3           18s
View replica set and pod
$ kubectl get rsNAME                          DESIRED   CURRENT   AGEnginx-deployment-2035384211   3         3         
View the attribution of each pod that is generated
$ kubectl get pods --show-labelsNAME                                READY     STATUS    RESTARTS   AGE       LABELSnginx-deployment-2035384211-7ci7o   1/1       Running   0          18s       app=nginx,pod-template-hash=2035384211nginx-deployment-2035384211-kzszj   1/1       Running   0          18s       app=nginx,pod-template-hash=2035384211nginx-deployment-2035384211-qqcnn   1/1       Running   0          18s       app=nginx,pod-template-hash=2035384211
View the status of deployment
$ kubectl rollout status deployment/nginx-deploymentdeployment "nginx-deployment" successfully rolled out
Update deploymentwhen the pod template in deployment changed.label has updatedif the container image changes, then the deployment will be triggered, and if deployment is extended, it will not trigger deploymentCan be changed directly by writing commands
kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1deployment "nginx-deployment" image updated
You can also make edits to make changes
$ kubectl edit deployment/nginx-deploymentdeployment "nginx-deployment" edited
To view the status of a publication
$ kubectl rollout status deployment/nginx-deploymentWaiting for rollout to finish: 2 out of 3 new replicas have been updated...deployment "nginx-deployment" successfully rolled out
If the publication succeeds
$ kubectl get deploymentsNAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGEnginx-deployment   3         3         3            3           36s
$ kubectl get rsNAME                          DESIRED   CURRENT   AGEnginx-deployment-1564180365   3         3         6snginx-deployment-2035384211   0         0         36s
$ kubectl get podsNAME                                READY     STATUS    RESTARTS   AGEnginx-deployment-1564180365-khku8   1/1       Running   0          14snginx-deployment-1564180365-nacti   1/1       Running   0          14snginx-deployment-1564180365-z9gth   1/1       Running   0          14s
Update pod, we just need to update deployment inside TemplementWhen we update the deployment, K8S will delete the old pod when the appropriate pod is created, and the old pod will continue to generate new pods when it is removed enough .Deployment rollback View Deployment Details
$ kubectl describe deployment
View deployment's release history
$ kubectl rollout history deployment/nginx-deployment
can be rolled back to any previous version
$ kubectl rollout undo deployment/nginx-deploymentdeployment "nginx-deployment" rolled back
$ kubectl rollout undo deployment/nginx-deployment --to-revision=2deployment "nginx-deployment" rolled back
Extended deployment

ou can scale a Deployment by using the following command:

$ kubectl scale deployment nginx-deployment --replicas 10deployment "nginx-deployment" scaled
$ kubectl autoscale deployment nginx-deployment --min=10 --max=15 --cpu-percent=80deployment "nginx-deployment" autoscaled
Pause or reply to a deployment
$ kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1; kubectl rollout pause deployment/nginx-deploymentdeployment "nginx-deployment" image updateddeployment "nginx-deployment" paused
Deployment status deployment for processing state: 1.deployment creating rs2.deployment expanding or removing RS deploymen why did it fail
    • Insufficient quota
    • Readiness Probe Failures
    • Image Pull Errors
    • Insufficient permissions
    • Limit Ranges
    • Application Runtime misconfiguration

Kubernetes Study Notes 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.