Please enable JavaScript.
Coggle requires JavaScript to display documents.
4.4.2 Pods (Enterprise Kubernetes) - Coggle Diagram
4.4.2 Pods (Enterprise Kubernetes)
Definition
Pod
Smallest deployable object in Kubernetes
Basic execution unit of Kubernetes
Represents one or more Linux containers running together
Containers inside one Pod share
Network
Same Internet Protocol (IP) Address
Same localhost (127.0.0.1)
Same network namespace
Storage
Shared Volumes
Lifecycle
Started together
Stopped together
Scheduled together
Pod is temporary
If deleted
Kubernetes creates another Pod if controlled by Deployment
Pod should never be considered permanent
What is Kubernetes?
Kubernetes
Open-source Container Orchestration Platform
Developed by Google
Maintained by Cloud Native Computing Foundation
Automates
Container deployment
Scaling
Self-healing
Load balancing
Updates
Rollbacks
Storage management
Network management
Why Pods Exist
Containers cannot run directly inside Kubernetes
Kubernetes always manages containers through Pods
Pod provides
Shared networking
Shared storage
Common lifecycle
Scheduling unit
Enterprise Use Cases
Web Application
One container
NGINX Web Server
Application Server
One container
Java Application
Sidecar Pattern
Main application container
Logging container
Monitoring container
Proxy container
Database
Usually one database container per Pod
Pod Architecture
Pod
Metadata
Name
Namespace
Labels
Annotations
Unique Identifier
Specification
Container definition
Images
Volumes
Ports
Environment variables
Security settings
Resource requests
Resource limits
Status
Pending
Running
Succeeded
Failed
Unknown
Kubernetes Components Related to Pods
Control Plane
API Server
Receives kubectl requests
Scheduler
Chooses worker node
Controller Manager
Maintains desired state
ETCD
Stores cluster information
Worker Node
Kubelet
Pod manager
Container Runtime
Containerd
CRI-O
Kube Proxy
Network routing
Pod Lifecycle
User creates Pod
API Server stores object
Scheduler selects node
Kubelet receives assignment
Container runtime downloads image
Container starts
Pod becomes Running
Health checks begin
Pod terminates when deleted or failed
Pod Phases
Pending
Waiting for scheduling
Pulling image
Running
Containers executing
Succeeded
Completed successfully
Failed
Container exited with failure
Unknown
Node communication problem
Pod Status Commands
View Pods
kubectl get pods
Wide Output
kubectl get pods -o wide
Detailed Description
kubectl describe pod pod-name
YAML Output
kubectl get pod pod-name -o yaml
JSON Output
kubectl get pod pod-name -o json
Pod YAML File
apiVersion
API version
kind
Resource type
metadata
Name
Labels
Namespace
spec
Containers
Volumes
Restart Policy
DNS Policy
status
Current state
Example Pod Manifest
apiVersion
v1
kind
Pod
metadata
name
nginx-pod
spec
containers
name
nginx
image
nginx:latest
ports
containerPort
80
Create Pod
kubectl apply -f pod.yaml
Delete Pod
kubectl delete pod nginx-pod
Delete Using YAML
kubectl delete -f pod.yaml
Pod Information
kubectl describe pod nginx-pod
Pod Logs
Single Container
kubectl logs nginx-pod
Multiple Containers
kubectl logs pod-name container-name
Execute Commands Inside Pod
Open Shell
kubectl exec -it nginx-pod -- bash
If Bash unavailable
kubectl exec -it nginx-pod -- sh
Copy Files
Local to Pod
kubectl cp file.txt pod-name:/tmp
Pod to Local
kubectl cp pod-name:/tmp/file.txt .
Port Forward
Local Computer
kubectl port-forward pod/nginx-pod 8080:80
Shared Networking
One Pod
One IP Address
All containers
Same localhost
Containers communicate
localhost
Without network traffic leaving Pod
Shared Storage
Volumes
EmptyDir
Temporary
ConfigMap
Configuration
Secret
Sensitive data
Persistent Volume Claim
Permanent storage
Restart Policy
Always
Default
OnFailure
Restart only after failure
Never
Never restart
Pod Resource Management
CPU Request
Guaranteed CPU
CPU Limit
Maximum CPU
Memory Request
Guaranteed RAM
Memory Limit
Maximum RAM
Resource Commands
kubectl top pod
kubectl describe pod
Labels
Purpose
Organize Pods
Example
app=nginx
environment=production
team=devops
Commands
Show Labels
kubectl get pods --show-labels
Label Pod
kubectl label pod nginx-pod environment=production
Selectors
Match Labels
Used By
Services
Deployments
ReplicaSets
Annotations
Metadata
Documentation
Monitoring information
Namespaces
Logical isolation
Default
Kube-System
Development
Production
Commands
kubectl get namespaces
kubectl get pods -n production
Multi-Container Pods
Main Container
Business application
Sidecar Container
Logging
Monitoring
Proxy
Init Container
Runs before application
Init Containers
Purpose
Initialize environment
Complete before application starts
Health Checks
Liveness Probe
Restart unhealthy container
Readiness Probe
Remove Pod from Service until ready
Startup Probe
Slow startup applications
Scheduling
Scheduler chooses node
Based on
CPU
Memory
Taints
Tolerations
Node Selector
Affinity
Anti Affinity
Node Selector
Force Pod onto selected node
Node Affinity
Preferred scheduling rules
Pod Affinity
Place Pods together
Pod Anti Affinity
Separate Pods
Taints
Block Pod scheduling
Tolerations
Allow scheduling onto tainted nodes
Quality of Service Classes
Guaranteed
Burstable
BestEffort
Pod Security
Security Context
User Identifier
Group Identifier
Linux Capabilities
Read-only Root Filesystem
Run as Non-Root
Drop Linux Capabilities
Linux Namespaces Used
Process Namespace
Network Namespace
Mount Namespace
User Namespace
Interprocess Communication Namespace
UTS Namespace
Linux Control Groups
CPU Limits
Memory Limits
Process Limits
File System Paths
Pod Manifest
/etc/kubernetes/manifests
Static Pods
Kubelet Configuration
/var/lib/kubelet/
Container Logs
/var/log/pods/
/var/log/containers/
Container Runtime Data
/var/lib/containerd/
Static Pods
Managed directly by Kubelet
Not controlled by API Server
Common for Control Plane components
Commands
kubectl get pods
kubectl get pods -A
kubectl describe pod pod-name
kubectl logs pod-name
kubectl exec -it pod-name -- bash
kubectl delete pod pod-name
kubectl apply -f pod.yaml
kubectl get pod pod-name -o yaml
kubectl get pod pod-name -o json
kubectl explain pod
kubectl api-resources
kubectl api-versions
Troubleshooting
Pod Pending
Node lacks resources
Image unavailable
Scheduling failure
ImagePullBackOff
Wrong image
Registry authentication failure
CrashLoopBackOff
Application crash
Configuration error
OOMKilled
Out Of Memory
Evicted
Node resource pressure
Enterprise Best Practices
Never create standalone Pods in production
Use Deployments
Define CPU Requests
Define CPU Limits
Define Memory Requests
Define Memory Limits
Use Readiness Probes
Use Liveness Probes
Use Namespaces
Use Labels
Use Resource Quotas
Use Network Policies
Store secrets in Kubernetes Secrets
Store configuration in ConfigMaps
Run applications as non-root
Keep Pods immutable
Monitor using Prometheus
Collect logs using Fluent Bit or Filebeat
Secure using Role-Based Access Control
Scan container images before deployment
Use rolling updates instead of deleting Pods manually
Important Interview Questions
What is a Pod?
Why does Kubernetes use Pods instead of directly managing containers?
Can one Pod have multiple containers?
How do containers communicate inside one Pod?
Difference between Pod and Deployment?
Difference between Init Container and Sidecar Container?
Difference between Liveness Probe and Readiness Probe?
What happens when a Pod is deleted?
What is CrashLoopBackOff?
What is ImagePullBackOff?
What is a Static Pod?
Where are Static Pod manifests stored?
Where are Pod logs stored?
How do you enter a running Pod?
How do you troubleshoot a failed Pod?
How does Kubernetes schedule Pods?
What Linux kernel features make Pods possible?