If Kubernetes is an aquarium

Author: Anne LoVerso

Translation: Bach (Caiyun)

Proofreading: Wenzi under the stars (Caiyun)

Kubernetes has many things, various terms, like onions, wrapped layer by layer.

image.png

Many Kubernetes introduction diagrams are like this, explaining all the terms covered.

image.png

Technically speaking, it is accurate, but it is not very helpful for some people. This article compares it to fish and aquariums, which may help some people to record these analyses in their minds.

image.png

This is an application.

It is a complete functional unit in itself, but it cannot survive alone because it requires a properly configured environment. This particular "fish" program requires water to survive.

image.png

We can throw it into the ocean with all other applications, but it must compete for resources and deal with everything else in the ocean, because it does not have its own exclusive space and resources.

image.png

This is why we are containerized.

Using tools like Docker, we can provide containers for applications, separate them, and give them their own space.

image.png

This is a Pod, which is the basic building block of Kubernetes. This is a box where we put containerized applications. We give it a label so that Kubernetes knows what it is and how to use it.

Now the fish program has been safely deployed in the Pod and can now be managed through the Kubernetes Aquarium.

image.png

Sometimes, applications need resources, such as memory and CPU. Here, our fish tank container needs 60W power to use the water filter.

image.png

There are different rooms in the aquarium for fish tanks.

There are no more resources available in the first room here, and the only two power outlets are already in use.

image.png

There are sockets available in the second room, but the sockets in this room only provide 40W power, and our fish tank needs 60W.

These rooms are the nodes in the Kubernetes cluster, that is, the staff who run the Pod.

image.png

Kubernetes is the curator of the aquarium.

He knows which rooms he has and what resources he has, and can use this information to decide where to put the new fish tank. In the absence of any other restrictions, he defaults to placing the fish tanks evenly in all rooms.

image.png

We usually don't handle a single fish in a single tank. The curator often put the fish tanks together as a collection of exhibits.

Here, the deep-sea collection exhibits consist of some anglerfish tanks, jellyfish tanks and squid tanks. When grouping them into a collection of exhibits, we have to determine how many containers need to be created.

image.png

When designing the exhibits, we provided instructions about each item in the exhibit.

Here is a detailed description of the number of each fish tank we want, and how to create a new fish tank when it needs to be repaired. We listed the amount of water to be filled, the required water temperature, and the amount of food required.

image.png

After providing these instructions to the curator of the Kubernetes aquarium, he can delegate the maintenance of each application's fish tank to the "aquarium intern".

The job of the interns is to ensure that there are always the correct number of fish tanks in the aquarium. In Kubernetes, this intern created with Deployment is called a Replica Set.

image.png

Visitors to the aquarium don't care if they are looking at Jellyfish A or Jellyfish B, they just want to see Jellyfish. The intern will replace the jellyfish A with a brand new jellyfish B through instructions when the jellyfish A is tired and needs a rest.

In Kubernetes, a replica set ensures that when a Pod hangs, a new Pod will be replaced to keep the correct number of Pods available.

image.png

There is another important consideration when designing exhibits. So far, we have been showing such a Pod, a box for containerized applications.

image.png

In fact, we can describe Pod more accurately. From the outside, it is just a Pod with certain tags. As for the internals, although we can learn more internal information through the Kubernetes aquarium curator, it is not helpful for the display. Our users (aquarium visitors) must be able to see the application and interact with it.

image.png

We need a way to allow aquarium visitors to observe the Pod. We need to open the window so that they can observe the fish in it.

image.png

In the Kubernetes aquarium, the answer is Service. Service has several different functions, but the main function is to expose ports in the container for external access.

Through the Service in the Pod, visitors to the aquarium can observe the fish inside.

image.png

Service also plays a role in allowing Pod and container to access each other. If we want the fish in the two tanks to exchange water and food back and forth, we can set up a Service to realize this interaction.

image.png

Network Policy is another way we can apply.

Here, it is a one-way valve that can make the water in the fish tank flow outward, but not inward.

image.png

Config Map is a set of variables or values ​​needed by Pod to operate. Fish need food to live, so we install equipment on the container.

We will also see transparent and opaque Config Maps, which represent general information and confidential information, respectively. There are many other things in Kubernetes. These are the basic building blocks that make up the aquarium and describe the work of the curator.

Original link: https://mp.weixin.qq.com/s/4YsRHyN-JFGbwb2JEih0Fw

Guess you like

Origin blog.51cto.com/14133165/2590786