官术网_书友最值得收藏!

Pods

Kubernetes uses Pods as its basic, atomic unit for Deployment and scaling, and represents processes running in the cluster – an analogy from Microsoft Hyper-V would be a single virtual machine that you deploy as an atomic unit in your Hyper-V cluster. A Kubernetes Pod consists of one or more containers that share kernel namespaces, IPC, network stack (you address them by the same cluster IP and they can communicate via localhost), and storage. To understand Pods, it is good to know the origin of the name: in the English language, a pod is a group of whales, and Docker uses a whale for its logo – think of a whale as a Docker container!

In their simplest form, you can create single-container Pods this is what we did in the introduction to this section when demonstrating nginx Pod creation. For some scenarios, you may need multiple-container Pods, where the main container is accompanied by additional containers that serve multiple purposes. Let's take a look at a few of these:

  • Sidecar containers, which can perform various helper operations, such as log collection, data synchronization for the main container, and so on.
  • Adapter containers, which can normalize output or monitor the data of the main container so that it can be used by other services.
  • Ambassador containers, which proxy the communication of the main container with the outside world.
  • Init containers, which are specialized containers that run before application containers in the Pod. For example, they may set up the environment, which isn't performed in the main container image. 
Technically, even single-container Pods contain an extra infra container, which is often a pause image. It acts as a parent container for all containers in the pod and enables kernel namespaces sharing. If you are interested in more details regarding infra containers, please refer to this article: https://www.ianlewis.org/en/almighty-pause-container.

The concept of a Pod can be seen in the following diagram:

There are a couple of considerations that you should keep in mind when using Pods:

  • Pod's containers always run on one node and once a Pod is created, it is always bound to one node.
  • You scale your application by adding more Pods, not by adding more containers inside the same Pod.
  • A Pod is considered ready and able to serve requests when all its containers are ready. The status of a container is determined by Probes, for example, liveness and readiness Probes, which can be defined in the Spec.
  • Pods are ephemeral. They are created, they die, and new ones are recreated in their place (if needed).
  • When a Pod is recreated, it receives a new cluster IP. This means that your application design should never rely on static IP assignments and assume that the Pod may even be recreated on a different node.
You will rarely create bare Pods independently, as we did in the introduction to the section. In most cases, they are managed through Deployments.

Pods have a finite life cycle and if the containers inside crash or exit, they may not be automatically recreated, depending on the restart policy. To maintain a desired number of Pods with a certain Spec and metadata in the cluster, you need ReplicaSet objects.

主站蜘蛛池模板: 香格里拉县| 延庆县| 安徽省| 福建省| 客服| 湘阴县| 孟连| 安新县| 上饶县| 会泽县| 呼伦贝尔市| 武山县| 封丘县| 刚察县| 苍山县| 甘德县| 平陆县| 安图县| 九江县| 平远县| 仁布县| 和政县| 江西省| 新田县| 丹棱县| 开平市| 岳阳市| 东莞市| 奉化市| 清徐县| 大理市| 长泰县| 新竹市| 宜昌市| 句容市| 宁夏| 乌海市| 通山县| 江阴市| 林芝县| 安丘市|