kubectl-run
Run pods in Kubernetes. tldr-pages
On several platforms
Several platforms
Run pods in Kubernetes. Specifies pod generator to avoid deprecation error in some K8S versions.
Run an nginx pod and expose port 80
kubectl run nginx-dev --image nginx --port 80Identify--imageThe image for the container to run. kubectl reference--portThe port that this container exposes. kubectl referenceRun an nginx pod, setting the $TEST_VAR environment variable
kubectl run nginx-dev --image nginx --env "TEST_VAR=testing"Identify--imageThe image for the container to run. kubectl reference--envEnvironment variables to set in the container. kubectl referenceSimulate creating an nginx container, showing the API calls that would be made
kubectl run nginx-dev --image nginx --dry-run=noneIdentify--imageThe image for the container to run. kubectl reference--dry-runMust be "none", "server", or "client". kubectl referenceRun an Ubuntu pod interactively, never restart it, and remove it when it exits
kubectl run temp-ubuntu --image ubuntu:22.04 --restart Never --rm -- /bin/bashIdentify--imageThe image for the container to run. kubectl reference--restartThe restart policy for this Pod. kubectl reference--rmIf true, delete the pod after it exits. kubectl referenceRun an Ubuntu pod, overriding the default command with echo, and specifying custom arguments
kubectl run temp-ubuntu --image ubuntu:22.04 --command -- echo argument1 argument2 ...Identify--imageThe image for the container to run. kubectl reference--commandIf true and extra arguments are present, use them as the 'command' field in the container, rather than the 'args' field which is the default. kubectl reference