Creating Pods is one of the most fundamental tasks in Kubernetes and a core skill required for the Certified Kubernetes Administrator (CKA) exam. In this blog, we will discuss creating single-container Pods and multi-container Pods on Kubernetes.
In the below example, we will see about creating pods and how to troubleshoot if any error occurs.
Create Single-Container Pod
First, we will see about creating a single-container pod, as the name suggests, we are going to deploy a single container on the pod.
Run the following command to deploy a single container on the pod.
kubectl run single-container --image nginx:latestThis command will deploy a single container of the latest nginx on the default namespace.
You can check if the pod is deployed and running successfully using the command
kubectl get podsOutput:
# kubectl get pods
NAME READY STATUS RESTARTS AGE
single-container 1/1 Running 0 6m45sPod is running status
Create Multi-Container Pod
A multi-container Pod runs multiple containers that share resources such as network and storage. This is commonly used for sidecar patterns (log collector, proxy, helper container).
Next, we will see about creating a multi-container pod, as the name suggests, we are going to deploy multiple containers on the pod.
For this we have to use a manifest file, we cannot create multiple containers using the command line.
Step 1: Create a base manifest
Run the following command to create a manifest file, which will have nginx image configurations in which we are going to add a log reader for nginx as a sidecar container.
kubectl run multi-container --image nginx --dry-run=client -o yaml > manifest.yamlStep 2: Edit the manifest to add a sidecar
Open the manifest file and add the log reader as another container as given below
apiVersion: v1
kind: Pod
metadata:
name: multi-container
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: logs
mountPath: /var/log/nginx
- name: log-reader
image: busybox
command: ["sh", "-c", "while true; do sleep 30; done"]
volumeMounts:
- name: logs
mountPath: /var/log/nginx
volumes:
- name: logs
emptyDir: {}Step 3: Apply the manifest
Once you have modified the manifest file, use the below command to deploy both containers.
kubectl apply -f manifest.yamlThis command will deploy the multiple container species on the manifest file on the default namespace as shown below
Step 4: Check the Pod is running
kubectl get podsIf everything is correct, the Pod should be in Running status.
Output:
# kubectl get pods
NAME READY STATUS RESTARTS AGE
multi-container 2/2 Running 0 40sThis pod now runs both the main Nginx container and a sidecar log-reader container.
TroubleShooting Pod
When a Pod is not running correctly, or repeatedly restarts, Kubernetes provides two key describe and logs
By using the describe command and logs command we can identify the issue and troubleshoot it easily.
As an example, I am going to use the describe command on the single-container pod and the logs command on the multi-container pod.
Run the following command to describe the single-container pod
kubectl describe po single-containerYou will get the following output:
# kubectl describe pod single-container
Name: single-container
Namespace: default
Priority: 0
Service Account: default
Node: node01/192.168.201.11
Start Time: Sun, 23 Nov 2025 17:56:50 +0000
Labels: run=single-container
Annotations: cni.projectcalico.org/containerID: 6510ceeda05598cce119d64e541afd73a51148e57a76f1efc1694377d6d63a09
cni.projectcalico.org/podIP: 10.244.196.129/32
cni.projectcalico.org/podIPs: 10.244.196.129/32
Status: Running
IP: 10.244.196.129
IPs:
IP: 10.244.196.129
Containers:
single-container:
Container ID: cri-o://2c1ef0c3c28916150fcf1ff8d92866207e59155ba19b9b96c8ffa45d70dcbac3
Image: nginx:latest
Image ID: docker.io/library/nginx@sha256:553f64aecdc31b5bf944521731cd70e35da4faed96b2b7548a3d8e2598c52a42
Port: <none>
Host Port: <none>
State: Running
Started: Sun, 23 Nov 2025 17:56:55 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-g6655 (ro)
Conditions:
Type Status
PodReadyToStartContainers True
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-g6655:
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 25s default-scheduler Successfully assigned default/single-container to node01
Normal Pulling 25s kubelet Pulling image "nginx:latest"
Normal Pulled 20s kubelet Successfully pulled image "nginx:latest" in 4.484s (4.484s including waiting). Image size: 155491845 bytes.
Normal Created 20s kubelet Created container: single-container
Normal Started 20s kubelet Started container single-containerSingle-container pod's describe
If the pod has any errors, you can find them in the Events section at the bottom. Check the Events section for:
- Image pull errors
- Probe failures
- CrashLoopBackOff
- OOMKilled events
- Volume mount issues
Check containers logs with kubectl logs
Now, let's use the logs command on the kubectl logs single-container multi-container pod, run the following command to get the logs
kubectl logs single-containerOutput:
root@controlplane:/home/vagrant# kubectl logs single-container
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2025/11/23 17:56:55 [notice] 1#1: using the "epoll" event method
2025/11/23 17:56:55 [notice] 1#1: nginx/1.29.3
2025/11/23 17:56:55 [notice] 1#1: built by gcc 14.2.0 (Debian 14.2.0-19)
2025/11/23 17:56:55 [notice] 1#1: OS: Linux 6.8.0-53-generic
2025/11/23 17:56:55 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2025/11/23 17:56:55 [notice] 1#1: start worker processes
2025/11/23 17:56:55 [notice] 1#1: start worker process 24
Single-container pod's logs
You can find the logs of the pod with timestamps, and logs provide valuable insight into application-level errors.
Logs for a specific container in a multi-container Pod:
kubectl logs multi-container -c log-readerEnhance Troubleshooting Section
Add these everyday things to help you troubleshoot more efficiently
# Check previous container logs (for crashlooping pods)
kubectl logs multi-container -c nginx --previous
# Follow logs in real-time
kubectl logs -f single-container
# Get last N lines
kubectl logs single-container --tail=50
# Check pod status in detail
kubectl get pod single-container -o yaml
# Interactive troubleshooting
kubectl exec -it multi-container -c nginx -- bashConclusion
In this guide, you explored how to deploy both single-container and multi-container Pods, use YAML manifests to define sidecar containers, and troubleshoot Pods using kubectl describe and kubectl logs. These capabilities are fundamental to Kubernetes administration and are highly relevant for the CKA exam.
