Forrest logo
back to the kubectl tool

kubectl-run:tldr:884bd

kubectl-run: Run an nginx pod and expose port 80.
$ kubectl run --generator=run-pod/v1 nginx --image=nginx --port 80
try on your machine

This command is used with the Kubernetes command-line tool, kubectl, to run a new pod in a Kubernetes cluster.

Here is the breakdown of the command:

  • kubectl run: This is the main command used to create and manage Kubernetes resources.
  • --generator=run-pod/v1: This flag specifies the generation method for the resource being created. In this case, it is using the "run-pod/v1" generator.
  • nginx: This is the name given to the newly created pod. You can choose any name you like for your pod.
  • --image=nginx: This flag specifies the container image to be used in the pod. In this case, it is using the official nginx image.
  • --port 80: This flag specifies that the container in the pod should listen on port 80. It exposes port 80 of the container to the outside world.

In summary, this command creates a new pod named "nginx" using the nginx container image and exposes port 80 of the container.

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