How to start a pod in command line without deployment in kubernetes?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
If you want to start a single pod directly from the command line, you do not need a Deployment at all. The two usual options are kubectl run for a quick one-off pod or kubectl apply with a minimal Pod manifest when you want explicit configuration.
Quickest Option: kubectl run
For ad hoc testing, kubectl run is the fastest path.
The --restart=Never part matters. Without it, older kubectl workflows could create higher-level controllers depending on command semantics. For a one-off pod, you want an actual Pod object rather than a Deployment.
You can inspect the result with:
This is useful for quick image checks, debugging, or interactive experiments.
Run an Interactive Pod
If you want a shell inside a container, combine -it with a command.
This starts a short-lived pod and attaches your terminal to it. It is a common pattern for debugging cluster DNS, service connectivity, or filesystem behavior.
Use a Pod Manifest for Repeatability
For anything beyond a quick experiment, a manifest is clearer and easier to reproduce.
Create it with:
This approach is better when you need environment variables, volumes, probes, or a record of the exact pod specification.
Understand the Tradeoff Against a Deployment
A Pod is a single runtime instance. If it crashes, Kubernetes does not automatically recreate it unless another controller owns it. That is the main difference from a Deployment.
Use a bare Pod when:
- you are debugging
- you need a temporary container
- you are testing an image or command manually
- you intentionally want no self-healing controller
Use a Deployment when:
- the workload should be restarted automatically
- you want rolling updates
- you need multiple replicas
- the workload is part of a real application deployment
Useful Follow-Up Commands
A few commands are especially common after creating a one-off pod:
These let you inspect output, open a shell, and clean up the object once you are done.
If the pod never reaches Running, check the events from kubectl describe pod before guessing. Image pull errors, invalid commands, and resource constraints are common causes.
Common Pitfalls
- Expecting a standalone Pod to restart automatically after failure misunderstands the Kubernetes object model. A bare Pod has no Deployment controller behind it.
- Using
kubectl runwithout understanding what object it creates can cause confusion. For one-off pods, be explicit and verify the resulting resource. - Treating a debug pod as a production deployment skips health management, scaling, and update controls. Use a Deployment for real services.
- Forgetting to clean up temporary pods leaves clutter in the namespace. Delete one-off pods when the test is finished.
- Debugging a failed pod without checking
kubectl describe podwastes time. Event output usually explains image, scheduling, or command problems directly.
Summary
- You can start a single pod from the command line with
kubectl run. - A Pod manifest is better when you want reproducibility and richer configuration.
- Standalone Pods are good for testing and debugging, not for managed application rollout.
- Deployments add restart behavior, scaling, and rollout control.
- After creating a one-off pod, use logs, exec, and describe to inspect it, then clean it up.
Related reading
- How to stop all containers when one container stops with docker-compose?
- How to stop all external traffic and allow only inter pod network call within namespace using network policy?
- How to stop Docker and Kubernetes using Docker desktop?
- How to stop Replicaset from restarting?
- how to stop/pause a pod in kubernetes
- how to stop/pause a pod in kubernetes
- How to strip the path prefix in Kubernetes Traefik ingress?
- How to switch kubectl clusters between gcloud and minikube

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.