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

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.

主站蜘蛛池模板: 交城县| 荔波县| 汾阳市| 娄底市| 武鸣县| 临泽县| 阜康市| 兴安县| 靖西县| 永安市| 海兴县| 南华县| 瑞昌市| 漠河县| 弥勒县| 齐河县| 阿巴嘎旗| 包头市| 晴隆县| 许昌县| 秦皇岛市| 宁远县| 浪卡子县| 文登市| 图木舒克市| 永德县| 长岛县| 罗定市| 大理市| 河曲县| 万源市| 安图县| 宁都县| 南部县| 中卫市| 微博| 通化市| 渭源县| 共和县| 台东市| 凉山|