Create Pod - Imperative Way

Imperative Commands

This is “easier to use” commands that are easily remembered. They also require only one step to make a change to a cluster. Imperative commands are recommended for use in development projects, but they do also have downsides. These commands do not provide a great option for keeping records or integrating commands into change review processes, as the user is operating directly on live clusters.

  • Lets Check the running Pods
$ kubectl get pods
  • Create a nginx Pod
$ kubectl run webserver --image=nginx --restart=Never
  • To check the pod is running
$ kubectl get pods -o wide
  • How to login to a pod?
$ kubectl exec -it webserver -- /bin/bash
  • How to see the details about the running pod ?
$ kubectl describe pod webserver
  • How to delete a pod?
$ kubectl delete pod webserver