Pod (Kubernetes)¶
A Pod is the smallest deployable computing unit that can be created and managed in Kubernetes^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. It represents a single instance of a running process in the cluster and serves as the fundamental building block for application deployment^[400-devops-06-kubernetes-k8s-paas-readme.md].
Overview¶
In the Kubernetes ecosystem, a Pod acts as a wrapper for one or more containers. While a Pod typically contains a single container (such as a Docker container), it is architected to support multiple containers that need to share resources and local storage[400-devops-06-kubernetes-k8s-paas-readme.md][400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. These containers within the same Pod are scheduled together on the same Node and share a unique network IP, allowing them to communicate easily with one another^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md].
Core Concepts¶
Architecture and Specifications¶
The configuration and desired state of a Pod are defined in a YAML manifest file^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. This specification consists of four main sections:
- apiVersion: Specifies the version of the Kubernetes API the object belongs to (e.g.,
v1). - metadata: Contains data that helps uniquely identify the Pod, such as
nameandlabels^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. Labels are key-value pairs used by selectors to organize and query objects^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. - spec: Defines the desired behavior of the Pod^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. This section lists the containers to be run, including properties such as the container
imageand exposedports(viacontainerPort)1. - status: Describes the current state of the Pod, automatically generated and updated by the Kubernetes system^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md].
Lifecycle and Management¶
A Pod transitions through various states during its existence^[400-devops-06-kubernetes-k8s-paas-readme.md]. Common lifecycle phases include: * Pending: The Pod has been accepted by the cluster, but one or more containers are not yet running. * Running: At least one container is still running or is in the process of starting/restarting. * Succeeded: All containers in the Pod have terminated successfully. * Failed: All containers have terminated, and at least one terminated in failure.
Because Pods are ephemeral (they can be created and destroyed at any time), they are typically managed by higher-level controllers such as [[Deployment]] to handle scalability and self-healing^[400-devops-06-kubernetes-k8s-paas-readme.md].
Networking¶
By default, Pods are isolated but have a distinct IP address. To access a running application inside a Pod from a local machine, developers often use kubectl port-forward. This command maps a local port to a port on the Pod, allowing traffic to flow via localhost^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md].
Related Concepts¶
- Kubernetes
- Container
- [[Node (Kubernetes)|Node]]
- [[Deployment]]
- [[Service (Kubernetes)|Service]]
Sources¶
-
In the
spec,containerPortspecifies which ports the container listens on for traffic^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. ↩