Junior
What should be inside a Pod in Kubernetes?
sobes.tech AI
Answer from AI
In a Pod in Kubernetes, there should be:
- One or more related containers that work as a single unit and share resources.
- Shared data storage (Volumes) for containers within the Pod.
- A common network stack for all containers (according to the IP specification).
- A Pod specification (PodSpec object) describing how containers should operate, including:
- Container images.
- Required resources (CPU, memory).
- Ports that are open.
- Environment variables.
- Health probes (liveness and readiness probes).
- Restart policies.
Typical usage:
- One main application container.
- One or more "sidecar" containers performing auxiliary tasks (logging, monitoring, adapters).
Example of a Pod specification (partial):
# Example of a partial Pod specification
apiVersion: v1
kind: Pod
metadata:
name: my-app-pod
spec:
containers:
- name: main-app
image: my-docker-repo/my-app:latest
ports:
- containerPort: 80
resources:
limits:
cpu: "500m"
memory: "512Mi"
- name: log-collector
image: my-docker-repo/log-collector:latest
volumeMounts:
- name: app-logs
mountPath: /var/log/app
volumes:
- name: app-logs
emptyDir: {}
Main principles:
- A Pod is the smallest deployable unit in Kubernetes.
- Containers within a Pod share the kernel namespace (PID, UTS, IPC).
- Scaling occurs at the Pod level.
- A Pod is intended for hosting tightly coupled processes.