Creating Pods with Generators


We use the run subcommand to run a Pod, Job, or a Deployment in the cluster. We will discuss Jobs and Deployments later.

oc run --help | grep "restart policy"

Run a simple nginx web server pod.

oc run nginx --image nginx --restart=Never

Get the list of pods.

oc get pods

View additional information about the pod.

oc get pods -o wide

View a detailed description of the running pod.

oc describe pod nginx


View the IP address of the running pod.

oc exec nginx -- hostname -i

Let’s execute an echo command within the pod.

oc exec nginx -- /bin/echo "Hello from Redhat"

Execute an interactive shell session inside the container.

oc exec -it nginx -- /bin/sh

Run some commands inside the container and exit.

cat /etc/os-release

Notice the label that automatically gets set on a pod that is created with kubectl run

oc get pods --show-labels

Clean Up

Use the delete subcommand to delete the resources that were created.

oc delete --help

Delete the resources that we created.

oc delete pod nginx