CodeBlanks Logo Icon CodeBlanks

Pod status

Learn Pod status and phases.

Pod status

A pod's life cycle has phases:

  • Pending: accepted, not placed on a node yet or the image is being pulled.
  • Running: at least one container is running.
  • Succeeded: all containers finished successfully.
  • Failed: at least one container finished with an error.

The READY 1/1 column shows whether containers passed their readiness checks, and RESTARTS how many times they restarted.

NAME   READY   STATUS             RESTARTS      AGE
web    1/1     Running            0             5m
api    0/1     CrashLoopBackOff   4 (30s ago)   3m

Health checks

Kubernetes watches container health with probes:

  • livenessProbe: if it fails, the container is restarted (a hung application).
  • readinessProbe: while failing, the pod gets no traffic (not ready yet).
  • startupProbe: delays the other probes for slow-starting applications.
      readinessProbe:
        httpGet:
          path: /saglik
          port: 8080
        periodSeconds: 5
      livenessProbe:
        httpGet:
          path: /saglik
          port: 8080
        initialDelaySeconds: 10

Practice A container with probes

Write a pod YAML: name api; container named api, image api:1.0; readinessProbe checks the /saglik path on port 8080 with httpGet; livenessProbe uses the same path and port.

Starter code

terminal
# buraya yaz

Sample solution

terminal
apiVersion: v1
kind: Pod
metadata:
  name: api
spec:
  containers:
    - name: api
      image: api:1.0
      readinessProbe:
        httpGet:
          path: /saglik
          port: 8080
      livenessProbe:
        httpGet:
          path: /saglik
          port: 8080

Expected output

pod/api created

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 If STATUS is Running but READY is 0/1, what does it mean?

  • The pod was deleted
  • The image can't be pulled
  • Everything is fine
  • The container runs but fails its readiness check; it gets no traffic Correct answer

Explanation: A Service sends traffic only to ready pods.

2 Write the probe that restarts the container when it fails.

Question
      ____:
        httpGet:
          path: /saglik
          port: 8080
Answer
      livenessProbe:
        httpGet:
          path: /saglik
          port: 8080

Explanation: readinessProbe doesn't restart; it only cuts the traffic.

3 Match.

Term Meaning
Pending Waiting to be placed
Succeeded Finished successfully
livenessProbe Restart when hung
readinessProbe No traffic if not ready

All lessons in Intermediate