RBCloud & DevOpsTHE PRACTICAL LEARNING LIBRARY
By Ravindra BagaleResources

CHAPTER 52 / 60

Kubernetes architecture, Pods and Deployments

Understand desired state before writing a large collection of YAML.

Concept + practical labBy Ravindra Bagale · ~5 min read · lab time additional

Why and what

The control plane stores desired state and schedules work. Worker nodes run Pods through a container runtime and kubelet. A Pod is the smallest scheduling unit and can contain tightly related containers. A Deployment manages ReplicaSets and rolling replacement for suitable stateless workloads. Deleting a managed Pod usually causes a replacement; the controller is doing its job.

Lab prerequisites

Use a local kind/minikube cluster or an authorized test cluster with kubectl configured. Verify the context before every mutation. A Kubernetes context can point at production just as easily as a lab.

bash
kubectl config current-context
kubectl get nodes
kubectl create namespace academy

Deployment manifest

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: academy-web
  namespace: academy
spec:
  replicas: 2
  selector:
    matchLabels: {app: academy-web}
  template:
    metadata:
      labels: {app: academy-web}
    spec:
      containers:
        - name: web
          image: nginx:stable-alpine
          ports:
            - containerPort: 80
          resources:
            requests: {cpu: 100m, memory: 64Mi}
            limits: {cpu: 500m, memory: 128Mi}
          readinessProbe:
            httpGet: {path: /, port: 80}
            initialDelaySeconds: 3
            periodSeconds: 5
bash
kubectl apply -f deployment.yaml
kubectl -n academy rollout status deployment/academy-web
kubectl -n academy get pods -o wide
kubectl -n academy describe deployment academy-web

Requests guide scheduling; limits constrain usage. Memory-limit exceedance can cause OOM termination. A containerPort declaration documents the port but does not by itself expose the application externally.

Debugging

Pending may mean capacity, affinity or storage constraints. ImagePullBackOff suggests registry/image/network issues. CrashLoopBackOff means the container repeatedly exits; inspect logs including --previous. A Running Pod can still be unready.

Assignment

Delete one lab Pod and observe replacement. Scale the Deployment to three replicas, then restore two. Explain why manually editing a managed Pod is not a durable deployment strategy.

Official reference

Kubernetes Deployments

Ravindra’s Tip

Pod delete किया और वापस आ गया तो Kubernetes खराब नहीं है। Deployment desired replicas maintain कर रहा है।

Interview and revision check

Why can a Running Pod still receive no service traffic?

It may be unready or its labels may not match the Service selector. Running is not equivalent to ready for traffic.

Ravindra Bagale · Cloud & DevOps Academy · Handbook and project downloads