Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Kubernetes update APP

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to update APP with Kubernetes". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Perform a rolling update to update the application

Users want the application to be available at any time, while developers want to deploy new versions of the application multiple times a day. In Kubernetes, this is done by scrolling updates. Rolling updates allow deployed updates to occur within zero downtime by incrementally updating the Pods instance with the new instance. The new Pods will be arranged on the node with available resources.

By default, the maximum number of pod not available during the update and the maximum number of new pod that can be created is 1. Both options can be configured as numbers or percentages (of pod). In Kubernetes, updates are versioned, and any deployment update can be reverted to the previous (stable) version.

Overview of scrolling updates

Similar to application scaling, if the deployment is public, the service will load balance the traffic to the available pod only during the update. The available Pod is an instance available to the user of the application.

Scrolling updates allow the following:

Promote an application from one environment to another (updated by container image)

Roll back to the previous version

Continuous integration and continuous delivery of applications with no downtime

Command to view resource information: kubectl get deployments; kubectl get pods;kubectl describe pods

Use the set image command to update the image of the application to the version 2:kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2, which informs the deployment that the application uses a different image and initiates the rolling update. Use kubectl get pods again to check the status of the Pods.

Validate updates

First, let's check to see if the application is running. We can use the kubectl describe services/kubernetes-bootcamp command to find out the exposed IP and port.

Create an environment variable named NODE_PORT with the value of the specified node port: export NODE_PORT=$ (kubectl get services/kubernetes-bootcamp-o go-template=' {{(index .spec.ports 0) .nodePort}') echo NODE_PORT=$NODE_PORT

Next, we will access the exposed IP and port through curl: curl $(minikube ip): $NODE_PORT, execute multiple requests, each request will encounter a different Pod, and we see that all Pod are running the latest version (v2).

You can also confirm the update by running the rollout status command: kubectl rollout status deployments/kubernetes-bootcamp

To see the current mirrored version of the application, execute: kubectl describe pods

Roll back an update

Let's perform another update and deploy the image labeled v10 to execute: kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=gcr.io/google-samples/kubernetes-bootcamp:v10

Use kubectl get deployments to view the status of the deployment. You may find that there is a problem that the number of available Pods is not as good as we expected. Use kubectl get pods to view pods status. The kubectl describe pods command provides more information. It can be found from the information that there is no image marked v10 in the repository.

Let's go back to the previous working version, and we will use the rollout undo command: the kubectl rollout undo deployments/kubernetes-bootcamp.rollout command will restore the deployment to its previously known state (v2 version image). Updates are versioned, and you can revert to any previously known deployment state. Execute kubectl get podskubectl describe pods again

This is the end of the content of "how Kubernetes updates APP". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report