Forrest logo
back to the kubectl tool

kubectl-run:tldr:2b385

kubectl-run: Run an nginx pod, setting the TEST_VAR environment variable.
$ kubectl run --generator=run-pod/v1 nginx --image=nginx --env="TEST_VAR=testing"
try on your machine

This command is used to create and run a Kubernetes pod.

Here's a breakdown of the command:

  • kubectl: It is the command-line interface (CLI) tool used to interact with a Kubernetes cluster.
  • run: It is a subcommand used to create and run a resource in Kubernetes.
  • --generator=run-pod/v1: It specifies the generator to use for creating the resource. In this case, it uses the run-pod/v1 generator, which is the default generator for the run command. This generator creates a simple pod.
  • nginx: It is the name of the pod that will be created.
  • --image=nginx: It specifies the container image to use for the pod. In this case, the pod will run an nginx container.
  • --env="TEST_VAR=testing": It sets an environment variable named TEST_VAR in the pod. The value of this variable is set to testing.

Overall, this command creates a new pod named nginx running the nginx container image, and sets an environment variable TEST_VAR with the value testing.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the kubectl tool