Updated on 2024-05-23 GMT+08:00

Pods

What Is a Pod?

A pod is the smallest and simplest unit in the Kubernetes object model that you create or deploy. A pod encapsulates one or more containers, storage resources, a unique network IP address, and options that govern how the container(s) should run.

Pods can be used in either of the following ways:

  • One container runs in one pod. This is the most common usage of pods in Kubernetes. You can view the pod as a single encapsulated container, but Kubernetes directly manages pods instead of containers.
  • Multiple containers that need to be coupled and share resources run in a pod. In this scenario, an application contains a main container and several sidecar containers, as shown in Figure 1. For example, the main container is a web server that provides file services from a fixed directory, and the sidecar container periodically downloads files to the directory.
    Figure 1 Pod

In Kubernetes, pods are rarely created directly. Instead, controllers such as Deployments and jobs, are used to manage pods. Controllers can create and manage multiple pods, and provide replica management, rolling upgrade, and self-healing capabilities. A controller generally uses a pod template to create corresponding pods.

Viewing Pods

You can create pods by calling the API or running the kubectl command. However, these pods cannot be managed on the console because they are not used to deploy a workload or execute a job. To solve this problem, CCI provides pod management, which allows you to filter pods by source.

Figure 2 Selecting a pod source

You can view details about all pods, including basic information, container composition, monitoring data, and events. You can use the web-terminal to access pods. In addition, you can view pod logs and delete pods.

Figure 3 Pod details

Creating a Pod Using kubectl

For details, see Pod in the Developer Guide.