Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use Deployment in Kubernetes

Shulou Source: shulou.com Published: 2022-05-31 18:37:14 09月20日 Update

This article introduces the knowledge of "how to use Deployment in Kubernetes". In the operation of actual cases, many people will encounter such a dilemma, so 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!

Start

The configuration file includes a static page. First, we want to start serving its static content. Starting with Kubernetes repository's root, run:

This runs a proxy on port 8001. You can now visit: http://localhost:8001/static/, which is the demo web version (it now logs in and displays a blank page). Now we want to run an application and display it on a web page.

The code deploys a copy of the application with "update-demo:nautilus", which you can click here to view: http://localhost:8001/static/

The cards displayed on the page represent the name (ID), status, image and tag of a Kubernetes pod,pod.

The quantity becomes larger.

Now we want more copies of this app!

Update your application

What happens when you update the application?

This code opens your default editor, and then you can update the configuration on fly. Find .spec.template.spec.containers [0] .image, then modify nautilus to kitty, and you will see:

What you need to do now is to update the image of the application from "update-demo:nautilus" to "update-demo:kitty".

After a while, you will find that the update seems to be stuck. Oh, but what happened to the Cartesian form?

Debug rollout

If you look more closely, you will see that the images marked with "Kitty" are still pending. Once the run fails, Deployment automatically stops roll. Let's take a look at what happens on the new pod:

If you take a look at the events of this pod, you will notice that Kubernetes cannot pull the image because it cannot find "kitty":

Roll back

Okay, now we want to undo the changes and take the time to figure out which mirror tag we should use.

Everything is back to normal, yeah!

Update your application

After that, we finally found out that the correct image tag is "kitten", not "Kitty". Now put .spec.template.spec.containers [0]. Change the image label from "nautilus" to "kitten".

Now you can see 4 kittens on the demo website, which means that we have successfully updated the app! If you want to understand the mirror image behind this, take a look at this Deployment:

You can see from the events section that the configuration is managing another resource called Replica Set, each of which manages the number of copies of different pod templates.

This is the end of the content of "how to use Deployment in Kubernetes". 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!

Tags: Mirroring application update tag run content more web page configuration code copy application status knowledge program website static page management different Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi Microsoft Shulou Information Apple