CodeBlanks Logo Icon CodeBlanks

What is a Pod?

Learn that a Pod is the smallest Kubernetes unit.

What is a pod?

A pod is the smallest unit Kubernetes runs: a group of one or more containers running together on the same node. The containers in a pod share the same IP address and ports (they reach each other via localhost) and can mount volumes in common.

kubectl run deneme --image=nginx:1.27
kubectl get pod deneme -o wide
# NAME     READY   STATUS    IP           NODE
# deneme   1/1     Running   10.244.0.12  minikube

Pods are ephemeral

Pods aren't permanent: if the node crashes, or the pod is deleted or updated, a new pod is created with a new IP. That is why pods are usually created not directly but through controllers that manage them, like a Deployment; a Service gives pods a stable address.

kubectl run deneme --image=nginx:1.27   # a single pod for experiments
kubectl delete pod deneme               # nobody recreates it

Practice An experiment pod

Write three commands: run a pod named deneme with the nginx:1.27 image; show the pod in wide format; then delete it.

Starter code

terminal
# buraya yaz

Sample solution

terminal
kubectl run deneme --image=nginx:1.27
kubectl get pod deneme -o wide
kubectl delete pod deneme

Expected output

pod/deneme created
NAME     READY   STATUS    RESTARTS   AGE   IP            NODE
deneme   1/1     Running   0          6s    10.244.0.12   minikube
pod "deneme" deleted

Questions and answers

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

1 How do two containers in the same pod reach each other?

  • With the host's IP
  • They can't
  • Via localhost and the port number Correct answer
  • By pod name through DNS

Explanation: Since the network namespace is shared, both can't listen on the same port.

2 Run a single pod.

Question
kubectl ____ deneme --image=nginx:1.27
Answer
kubectl run deneme --image=nginx:1.27

Explanation: kubectl run creates a single pod.

3 Match.

Term Meaning
pod Smallest unit
shared IP Access via localhost
Deployment Manages pods
Service Stable address

All lessons in Intermediate