Pods#
Pods are k8s abstractions that can be interpreted as a single application. In the container runtime, pods can be considered as a group of containers/volumes. This section discusses typical operations associated with pods.
Config#
You can use a configuration file to define a pod’s properties.
There are few important details associated with pods configuration:
The file can be in YAML or JSON format.
The command
kubectl create -f <file>runs the pod specified in the given configuration file.
The following cell creates the pod configuration file.
rm -rf /tmp/pods_config && mkdir /tmp/pods_config
cat << EOF > /tmp/pods_config/pods_config.yml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx-pod
image: nginx:1.22.1
ports:
- containerPort: 80
EOF
With kubectl create -f <file name> you can create the pod.
kubectl create -f /tmp/pods_config/pods_config.yml
kubectl get pods
pod/nginx-pod created
NAME READY STATUS RESTARTS AGE
nginx-pod 0/1 ContainerCreating 0 0s
kubectl delete pod nginx-pod
pod "nginx-pod" deleted from default namespace
Generated config#
Use the --dry-run parameter to instruct the kubectl run pod to generate the config instead of actually running the pod. It typically used with the -o <yaml/json> parameter to specify the format.
The following cell shows the configuration for the nginx pod.
kubectl run pod --dry-run=client -o yaml --image=nginx:1.22.1 nginx-pod
apiVersion: v1
kind: Pod
metadata:
labels:
run: pod
name: pod
spec:
containers:
- args:
- nginx-pod
image: nginx:1.22.1
name: pod
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
Describe#
Use the nginx describe pod <pod_name> command to check the status of a pod.
The following cell creates the pod and shows the describe for it.
kubectl run nginx-pod --image=nginx:1.22.1
kubectl describe pod nginx-po
kubectl delete pod nginx-pod
Name: nginx-pod
Namespace: default
Priority: 0
Service Account: default
Node: minikube/192.168.49.2
Start Time: Mon, 13 Oct 2025 11:49:48 +0200
Labels: run=nginx-pod
Annotations: <none>
Status: Running
IP: 10.244.0.23
IPs:
IP: 10.244.0.23
Containers:
nginx-pod:
Container ID: docker://7a880563fab311448f207cb9909b63a34478f887fe7fca78a7aef99a5144451d
Image: nginx:1.22.1
Image ID: docker-pullable://nginx@sha256:fc5f5fb7574755c306aaf88456ebfbe0b006420a184d52b923d2f0197108f6b7
Port: <none>
Host Port: <none>
State: Running
Started: Mon, 13 Oct 2025 11:49:49 +0200
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-vt79d (ro)
Conditions:
Type Status
PodReadyToStartContainers True
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-vt79d:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
Optional: false
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 4s default-scheduler Successfully assigned default/nginx-pod to minikube
Normal Pulled 3s kubelet Container image "nginx:1.22.1" already present on machine
Normal Created 3s kubelet Created container: nginx-pod
Normal Started 3s kubelet Started container nginx-pod