DevOps Classroom notes 06/Oct/2026

Pod:

  • pod is smallest deployment unit in k8s

ALL container in pods

  • we have same network ip address
  • having shared volume
  • Are started and stoped as a unit.

Types of container

  1. containers:
  • this is used for application container
  • all container will run parellel
  • Mandatory atlest one container
  1. init-container:
  • pre-conditional run before container start
  • this will be run in sequence
  • Optional
  • this container will run and complete state.
alpine ==> bash ==> curl download dependancy ==> create folder and add files 
  1. ephemeralContainers:
  • temporary container for debug
  • Optional
kubectl debug -it <pod> --image=<image> --target=<container>

API Referance link

apiVersion: v1
kind: Pod
metadata:
  name: sample-pod
  labels:
    app: sample
    environment: production
spec:
  containers:
    - name: sample-container
      image: nginx:latest
      ports:
        - containerPort: 80
  initContainers:
    - name: init-sample
      image: busybox:latest
      command: ["sh", "-c", "echo Initializing... && sleep 5"]

killercoda for k8s playground

Pod lifecycle:

Offical doc for pod lifecycle

  1. pending: accept the cluster to create pod, also will pull images for container and init container
  2. Running: bound to node and at least one container will started running
  3. succeeded: all init container or container run and exist with status code o
  4. Failed: if any container is failled and terminated
  5. Unknow: pod state can’t be determined.(resource issue, node problems , network issues)

Container states:

  1. waiting: (not yet running container but its in pulling images and runing init container)
  2. Running: Executing normally (application is runing)
  3. terminated: Finshed or failed

note deploy below yaml and test the container state by describe pod

apiVersion: v1
kind: Pod
metadata:
  name: sample-pod
  labels:
    app: sample
    environment: production
spec:
  containers:
    - name: sample-container
      image: nginx:latest
      ports:
        - containerPort: 80
    - name: init-sample
      image: busybox:latest
      command: ["sh", "-c", "echo Initializing... && sleep 10"]

kubectl get pod <pod-name> -n <namespace> -o jsonpath='{range .status.containerStatuses[*]}{.name}{"\t"}{.state}{"\n"}{end}'

kubectl logs <pod_name> -c <container_name>

Restart policy

  1. Always: (deafault -> k8s try to restart if pod or container failed)
  2. Never: (never restart)
  3. OnFailure: Restart pod when if its failled when status code is not equal to 0

Task:

  1. create sample yaml for pod image tomcat:latest port: 8080
  2. add init container
initContainers:
    - name: init-sample-data
      image: busybox:latest
      command: ["sh", "-c", "echo Initializing demo... && sleep 5"]
  1. check logs and describe pod to validate state

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%