Pods
TOC
Understanding Pods
Refer to the official Kubernetes website documentation: Pod
A Pod is the smallest deployable unit of computing that you can create and manage in Kubernetes. A Pod (as in a pod of whales or a pea pod) is a group of one or more containers (such as containers), with shared storage and network resources, and a specification for how to run the containers. Pods are the fundamental building blocks on which all higher-level controllers (like Deployments, StatefulSets, DaemonSets) are built.
YAML file example
Managing a Pod by using CLI
While Pods are often managed by higher-level controllers, direct kubectl operations on Pods are useful for troubleshooting, inspection, and ad-hoc tasks.
Viewing a Pod
-
To list all Pods in the current namespace:
-
To list all Pods across all namespaces:
-
To get detailed information about a specific Pod:
Viewing a Pod Logs
-
To stream logs from a container within a Pod (useful for debugging):
-
If a Pod has multiple containers, you must specify the container name:
-
To follow the logs (stream new logs as they appear):
Executing Commands in a Pod
To execute a command inside a specific container within a Pod (useful for debugging, like accessing a shell):
Port Forwarding to a Pod
To forward a local port to a port on a Pod, allowing direct access to a service running inside the Pod from your local machine (useful for testing or direct access without exposing the service externally):
After running this command, you can access the Nginx web server running in my-nginx-pod by visiting localhost:8080 in your web browser.
Deleting a Pod
-
To delete a specific Pod:
-
To delete multiple Pods by their names:
-
To delete Pods based on a label selector (e.g., delete all Pods with the label app=nginx):
Managing a Pod by using web console
Viewing a Pod
The platform interface provides various information about the pods for quick reference.
Procedure
-
Container Platform, navigate to Workloads > Pods in the left sidebar.
-
Locate the Pod you wish to view.
-
Click the deployment name to see the Details, YAML, Configuration, Logs, Events, Monitoring, etc.
Pod Parameters
Below are some parameter explanations:
Deleting a Pod
Deleting pods may affect the operation of computing components; please proceed with caution.
Use Cases
-
Restore the pods to its desired state promptly: If a pods remains in a state that affects business operations, such as
PendingorCrashLoopBackOff, manually deleting the pods after addressing the error message can help it quickly return to its desired state, such asRunning. At this time, the deleted pods will be rebuilt on the current node or rescheduled. -
Resource cleanup for operations management: Some podss reach a designated stage where they no longer change, and these groups often accumulate in large numbers, complicating the management of other podss. The podss to be cleaned up may include those in the
Evictedstatus due to insufficient node resources or those in theCompletedstatus triggered by recurring scheduled tasks. In this case, the deleted podss will no longer exist.Note: For scheduled tasks, if you need to check the logs of each task execution, it is not recommended to delete the corresponding
Completedstatus podss.
Procedure
-
Go to Container Platform.
-
In the left navigation bar, click Workloads > Pods.
-
(Delete individually) Click the ⋮ on the right side of the pods to be deleted > Delete, and confirm.
-
(Delete in bulk) Select the podss to be deleted, click Delete above the list, and confirm.