A pod groups one or more containers into a unit that Kubernetes can run and scale. A Deployment wraps pods with replica management, health checks, and rollout behavior, while a Service routes requests to them. section 10.3
A practical Kubernetes setup treats the pod as the workload unit and adds surrounding controls:
- Use a Deployment to define the pod template, container image, exposed port, and desired replica count. section 10.3
- Use liveness and readiness probes to distinguish a running container from a pod ready to receive traffic. section 10.4
- Increase replicas when the service needs multiple pod instances for load or availability. section 10.4
- Place a Service in front of the Deployment to route calls across its pod instances. section 10.3
A health-checked hello-api pod
A hello-api Deployment can run a container image on port 8080, check /health for liveness and readiness, and set replicas to 3. Kubernetes can then direct traffic only to ready pods and replace unhealthy ones. section 10.4
Listing 10.2 deployment.yml
apiVersion: apps/v1
kind: Deployment #1
metadata:
name: hello-api #2
spec:
replicas: #3
selector:
matchLabels:
app: hello-api
template:
metadata:
labels:
app: hello-api
spec:
containers:
- name: hello-api
imagePullPolicy: Always
image: gcr.io/PROJECT_NAME/hello-api:latest
ports:
- containerPort: 8080 #4
name: hello-api-svc #5
Inspect the Deployment YAML showing the pod template, container image, port, labels, and initial replica configuration. section 10.3
Listing 10.4 deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-api
spec:
replicas: 1
selector:
matchLabels:
app: hello-api
template:
metadata:
labels:
app: hello-api
spec:
containers:
- name: hello-api
imagePullPolicy: Always
image: gcr.io/PROJECT_NAME/hello-api:latest
ports:
- containerPort: 8080
name: hello-api-svc
livenessProbe:
httpGet:
path: /health #1
port: 8080
initialDelaySeconds: 3
periodSeconds: 3
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 3
periodSeconds: 3
Inspect the health probe configuration that checks the pod's HTTP health endpoint before routing traffic. section 10.4
Listing 10.5 deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-api
spec:
replicas: 3 #1
selector:
matchLabels:
app: hello-api
template:
metadata:
labels:
app: hello-api
spec:
containers:
- name: hello-api
imagePullPolicy: Always
image: gcr.io/PROJECT_NAME/hello-api:latest
ports:
...
Inspect the one-line replica change that produces three running pod instances. section 10.4














