A Kubernetes pod consists of several key components:
-
Containers: The primary components of a pod, which run the application. A pod can contain one or more containers that share the same network namespace and storage.
-
Shared Storage Volumes: Pods can define storage volumes that can be shared among the containers. This allows data to persist beyond the lifecycle of individual containers.
-
Network Namespace: All containers in a pod share the same IP address and port space, allowing them to communicate with each other using
localhost. -
Pod Specification (Spec): This is a YAML or JSON configuration that defines the desired state of the pod, including the containers, their images, resource limits, environment variables, and other settings.
-
Labels and Annotations: Labels are key-value pairs used to organize and select pods, while annotations provide metadata that can be used by tools and libraries.
-
Init Containers: These are specialized containers that run before the main containers in the pod. They can be used for setup tasks, such as initializing databases or waiting for services to be ready.
-
Lifecycle Hooks: These are scripts or commands that can be executed at specific points in a container's lifecycle, such as before it starts or before it stops.
These components work together to define the behavior and characteristics of a pod in a Kubernetes cluster.
