A pod is Kubernetes’ basic unit of computation. Nodes host pods, and pods host containers. A pod can contain multiple containers, but a straightforward microservice deployment uses one container per pod. That simplification is useful here; a pod and a container are not the same thing. section 6.4.2
For a running microservice, put the pod under a Deployment rather than creating it alone. The Deployment monitors the workload and replaces its pod if the microservice crashes or stops responding. A Service supplies a DNS record so the microservice can be reached. One pod is enough for the initial setup; multiple replicas are a later route to redundancy and load balancing. section 6.4.3
Listing 6.2 Deploying our microservice to Kubernetes on Azure
apiVersion: apps/v1
kind: Deployment
metadata:
name: video-streaming
spec:
replicas: 1
selector:
matchLabels:
app: video-streaming
template:
metadata:
labels:
app: video-streaming
spec:
containers:
- name: video-streaming
image: bmdk1.azurecr.io/video-streaming:1 #1
imagePullPolicy: IfNotPresent #2
env:
- name: PORT
value: "4000"
---
apiVersion: v1
kind: Service
metadata:
name: video-streaming
spec:
selector:
app: video-streaming
type: LoadBalancer #3
ports:
- protocol: TCP
port: 80
targetPort: 4000
The deployment manifest puts the container image and PORT setting inside the pod template, sets one replica, and uses matching app labels to connect the Deployment and Service. This version pulls its image from a container registry and exposes the Service through an Azure load balancer. section 6.11.4 section 6.8.3
Check a local deployment
With Docker Desktop Kubernetes enabled and kubectl connected to its context, run `kubectl apply -f scripts/deploy.yaml`. Then run `kubectl get pods`, `kubectl get deployments`, and `kubectl get services`. The single-replica example produces one running pod alongside its Deployment and Service. Its pod name begins with the microservice name and has a Kubernetes-generated suffix. When finished, run `kubectl delete -f scripts/deploy.yaml` and repeat the checks to confirm cleanup. section 6.8.4 section 6.8.5 section 6.8.7














