⚡ ~/naveed Interview Prep
⚡ Portfolio Home ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
← Back to All Kubernetes Interview Questions Scenario 199 of 203 in Kubernetes
Senior DevOps / SRE Kubernetes Pod Lifecycle & Debugging Production Scenario
🎯 Target Role / Context: Senior Platform Engineer / SRE Interview Question

Q: A pod fails to start with 'CreateContainerError'. There are no container logs available via 'kubectl logs'. What causes this error before application code can execute, and how do you differentiate container runtime sandbox creation errors from volume mount deadlocks and security policy denials?

Deep diagnostic analysis of why Kubernetes pods get stuck in Waiting state with Reason: CreateContainerError, dissecting volume attachment deadlocks (EBS Multi-Attach), subPath mount failures, Linux cgroup/PID limits, and AppArmor/SELinux profile rejections.

#Kubernetes #CreateContainerError #Pod Lifecycle #Volume Mounts #AppArmor #SELinux #Containerd #CRI
🎙️ Candidate Opening & Architectural Context
"CreateContainerError occurs during the container lifecycle transition between the Kubelet and the Container Runtime Interface (CRI). The container image has already been successfully pulled to the node, but when containerd or CRI-O attempts to construct the container execution context—attaching volumes, configuring Linux namespaces, establishing cgroups, or enforcing AppArmor/SELinux profiles—the underlying system call fails. Because the container process never launched, 'kubectl logs' outputs nothing."
Advertisement
⚡ Recommended Practice Lab

Want to master this scenario in a live sandbox? KodeKloud's CKA & CKAD Hands-On Certification Track covers this exact problem with hands-on terminal drills.

🛠️ Production Runbook & Step-by-Step Resolution

1️⃣

Extract the Exact CRI RPC Error Message

Inspect the pod status and event timeline to capture the exact failure string returned by the container runtime:

  • Describe the Pod: Run kubectl describe pod <pod-name> and scroll to the Containers -> State block. Check Reason: CreateContainerError and read the Message field.
  • Extract Events: Run kubectl get events --field-selector involvedObject.name=<pod-name> --sort-by=.metadata.creationTimestamp.
  • Classify Failure Category: The error message will pinpoint whether the failure is in MountVolume.SetUp failed, failed to generate spec, permission denied, or OCI runtime create failed.
Pro Tip: Never spend time checking application log files or application code when a pod is in CreateContainerError; the error is strictly infrastructural.
2️⃣

Volume Mounts & SubPath Deadlocks (EBS / NFS / CSI)

The most frequent cause of CreateContainerError in cloud environments is a storage volume that cannot be mounted into the container namespace:

  • Multi-Attach Error: Check if a PersistentVolume (e.g. AWS EBS ReadWriteOnce) is still locked to another worker node: kubectl get volumeattachments.
  • Invalid subPath in VolumeMount: If using volumeMounts.subPath, verify that the subPath actually exists in the persistent volume or that Kubelet has permission to create it.
  • Missing ConfigMap/Secret File Mount: If a volume mounts a ConfigMap or Secret that was deleted after pod scheduling, container creation fails during the bind mount.
Pro Tip: On AWS EBS, if a node crashes abruptly, the cloud controller may take 6+ minutes to release the VolumeAttachment, causing new pods to hang in CreateContainerError.
Advertisement
3️⃣

AppArmor, SELinux & Seccomp Profile Violations

Linux security modules will block container runtime initialization if an annotated profile is missing from the node:

  • Audit AppArmor Annotations: Look for container.apparmor.security.beta.kubernetes.io/<container>: localhost/custom-profile. If custom-profile is not loaded in the node's /etc/apparmor.d/, containerd aborts container creation.
  • Check Node Kernel Audit Logs: On the worker node, run dmesg -T | grep -i 'apparmor\|selinux\|audit' to locate rejected capability bindings.
  • Verify Seccomp Profile Path: Verify if securityContext.seccompProfile.localhostProfile points to a valid file inside /var/lib/kubelet/seccomp/.
Pro Tip: In Kubernetes 1.30+, seccomp defaults are enabled by default; invalid custom profiles will immediately halt container creation.
4️⃣

Host Kernel Inotify, File Descriptor & PID Exhaustion

If the worker node has exhausted OS resources, containerd cannot allocate new kernel namespace descriptors:

  • Check Inotify Watchers: Microservices with file watchers can exhaust fs.inotify.max_user_watches. Check usage via: cat /proc/sys/fs/inotify/max_user_watches.
  • Check Node Kernel Task Limits: Run cat /proc/sys/kernel/pid_max and compare with current running threads: ps -eLf | wc -l.
  • Inspect Containerd Service Logs: Run journalctl -u containerd -n 50 --no-pager for too many open files or failed to allocate cgroup.
Pro Tip: When inotify watches are exhausted, containerd fails with <code>failed to create containerd task: too many open files</code>.
5️⃣

Resolution Runbook & VolumeAttachment Cleanup

Execute targeted remediations based on the identified failure vector:

  • Force Release Stuck EBS Volume: If volume attachment is stuck, delete the blocking volumeattachment object or detach the volume via AWS CLI: aws ec2 detach-volume --volume-id <vol-id> --force.
  • Fix subPath Missing Directory: Add an initContainer to create the necessary directory structure on the PV before the main container attempts to mount it.
  • Adjust Host Inotify Limits: Permanently increase inotify watches in /etc/sysctl.d/99-kubernetes.conf: fs.inotify.max_user_watches = 524288.
Pro Tip: Always prefer updating initContainers to create directory paths rather than granting wide root privileges to application containers.
6️⃣

Verification & Hands-On Lab Reproduction

Verify the container reaches Running state and practice hands-on debugging in the lab:

  • Verify Pod Status: Confirm STATUS: Running with kubectl get pod <pod-name>.
  • Check Container Runtime Health: Run crictl ps --name <pod-name> on the node.
  • Lab Runbook: Practice reproducing and fixing CreateContainerError in DevOps Lab: CreateContainerError Hands-On Runbook ↗.
Pro Tip: CreateContainerError is an infrastructural setup blocker. Once the underlying mount or security profile is satisfied, Kubelet recovers the container without requiring image re-pulls.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"CreateContainerError means the image was pulled, but the container runtime failed to construct the sandbox environment. Check 'kubectl describe pod' for the exact CRI error. The vast majority of incidents stem from stuck VolumeAttachments (EBS multi-attach), missing volume subPaths, or node-level inotify/AppArmor security restrictions."
⚡ 60-Second Elevator Pitch Talking Points
  • Recognized that CreateContainerError occurs before PID 1 execution, meaning 'kubectl logs' is useless and the issue is infrastructural.
  • Inspected 'kubectl describe pod' and events to capture the exact CRI RPC error string from containerd.
  • Triaged storage volume attachments for EBS ReadWriteOnce multi-attach locks and subPath directory absence.
  • Audited worker node kernel logs for AppArmor or SELinux security profile rejections and inotify limit exhaustion.
  • Remediated the root cause (cleared stale VolumeAttachment / loaded missing AppArmor profile / adjusted sysctl limits).
  • Verified the pod transitioned cleanly into Running status with healthy readiness probes.
Advertisement
📥 FREE DOWNLOAD · 101-PAGE COMPANION HANDBOOK
Studying for Kubernetes & SRE Technical Rounds?
Download the complete 100-question PDF field guide covering all 11 core modules with offline diagnostic runbooks.
📥 Download PDF (Free) Read Online Guide →
Want more Kubernetes scenarios?
Explore our complete collection of scenario-based Kubernetes interview runbooks.
Browse All Kubernetes Questions →