kubernetes
command line
pod creation
kubernetes tutorial
kubectl usage

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.

Practice system design

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.

bash
kubectl run demo-pod \
  --image=nginx:1.27 \
  --restart=Never

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:

bash
kubectl get pods
kubectl describe pod demo-pod

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.

bash
1kubectl run toolbox \
2  --image=busybox:1.36 \
3  --restart=Never \
4  -it -- sh

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.

yaml
1apiVersion: v1
2kind: Pod
3metadata:
4  name: demo-pod
5spec:
6  containers:
7    - name: web
8      image: nginx:1.27
9      ports:
10        - containerPort: 80

Create it with:

bash
kubectl apply -f pod.yaml

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:

bash
kubectl logs demo-pod
kubectl exec -it demo-pod -- sh
kubectl delete pod demo-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 run without 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 pod wastes 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
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track 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.

Practice system design

All Rights Reserved.