Kubernetes Pod Structure
Kubernetes Pod Structure defines how containers are grouped and managed within a cluster, forming the basic unit of deployment and scaling in Kubernetes.
Kubernetes Pod Structure is the internal composition of a Pod's spec, describing the collection of containers, volumes, and shared execution context that together define what a Pod actually is: not a single container, but a group of one or more containers deliberately co-located to share networking, storage, and certain aspects of their lifecycle, unified under one scheduling and identity boundary. Understanding this structure is foundational to everything else about Kubernetes workloads, since virtually every higher-level controller ultimately exists to manage one or more Pods built from this same underlying shape.
The Container Collection
containers as the Primary Workload
spec.containers is a list of one or more container definitions, each specifying an image, command, resource requirements, and its own configuration, representing the actual application processes the Pod exists to run; in the common single-container case, this list has exactly one entry, but Kubernetes places no inherent limit on how many containers a Pod's design can include.
initContainers for Sequenced Setup
spec.initContainers defines containers that run to completion, in order, before any container in the main containers list starts, used for setup work that must finish before the application containers begin — populating a shared volume, waiting for a dependency to become available, or performing a one-time migration step.
The Sidecar Pattern Within initContainers
A container within initContainers can be marked with a restartPolicy of Always, distinguishing it as a long-running sidecar that starts before the main containers and continues running alongside them for the Pod's lifetime, rather than exiting before the main containers begin — a structural mechanism for co-locating supporting processes like log shippers or proxies with clearly defined startup ordering relative to the main workload.
Shared Execution Context
Namespace Sharing at the Pod Level
Every container within a Pod's containers and long-running initContainers shares the same network namespace by default, giving them a common IP address and the ability to reach each other over localhost; IPC and, optionally, PID namespace sharing can also be configured, extending the scope of what containers within the Pod can observe or signal directly.
The securityContext Fields
spec.securityContext, set at the Pod level, establishes security defaults — such as the user and group IDs processes should run as, and seccomp or SELinux configuration — that apply across every container in the Pod unless a specific container overrides them with its own narrower securityContext, giving Pod structure a layered approach to security configuration from Pod-wide defaults down to per-container specifics.
Volumes as Pod-Scoped Storage
volumes Declared Once, Mounted Per Container
spec.volumes declares the storage sources available to the Pod as a whole — derived from a ConfigMap, a Secret, a PersistentVolumeClaim, or an ephemeral emptyDir — while each container independently chooses which of these declared volumes to mount and at what path through its own volumeMounts, meaning a single volume can be shared by multiple containers within the same Pod, each mounting it at a location of its own choosing.
Scheduling and Runtime Directives
nodeSelector, affinity, and tolerations
Fields such as spec.nodeSelector, spec.affinity, and spec.tolerations express constraints on where the Pod may be scheduled, evaluated once at scheduling time and, for most of these fields, not re-evaluated after the Pod has already been placed on a node.
restartPolicy and terminationGracePeriodSeconds
spec.restartPolicy (Always, OnFailure, or Never) governs how the kubelet responds to container exits within the Pod, while spec.terminationGracePeriodSeconds sets the default window containers are given to shut down gracefully before being forcibly killed, both operating at the Pod level even though their effects are ultimately carried out per container.
Status Reflecting the Whole Structure
Aggregating Container-Level State Into Pod-Level Status
A Pod's status reflects this same layered structure in reverse: status.containerStatuses and status.initContainerStatuses report per-container state individually, while Pod-level conditions such as Ready are computed as an aggregate judgment across all of a Pod's containers, meaning the Pod's overall reported health is always a function of, and never independent from, the state of the containers its structure actually contains.