Search⌘ K

A Quick Way to Run Pods

Understand how to quickly create Pods in Kubernetes using kubectl commands and why using declarative YAML specifications is preferred for repeatability and maintainability. Explore how to confirm Pod status and troubleshoot when running containers like MongoDB within a cluster.

Creating a Pod with Mongo

Just as we can execute docker run to create containers, kubectl allows us to create Pods with a single command. For example, if we’d like to create a Pod with a Mongo database, the command is as follows:

Shell
kubectl run db --image mongo

You’ll notice that the output says that “pod/db created”. We have created our first Pod. We can confirm that by listing all the Pods in the cluster.

Shell
kubectl get pods

The output should be something like this:

Shell
NAME READY STATUS RESTARTS AGE
db 0/1 ContainerCreating 0 1m

In the output, we can see the following:

  • The name of the Pod
  • Its readiness
...