2025-03-14 21:59:59 -06:00
|
|
|
# kubectl run
|
|
|
|
|
|
|
|
|
|
> Run pods in Kubernetes. Specifies pod generator to avoid deprecation error in some K8S versions.
|
2025-12-16 10:20:31 -07:00
|
|
|
> More information: <https://kubernetes.io/docs/reference/kubectl/generated/kubectl_run>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Run an nginx pod and expose port 80:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl run {{nginx-dev}} --image nginx --port 80`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Run an nginx pod, setting the TEST_VAR environment variable:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl run {{nginx-dev}} --image nginx --env "{{TEST_VAR}}={{testing}}"`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Show API calls that would be made to create an nginx container:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl run {{nginx-dev}} --image nginx --dry-run={{none|server|client}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Run an Ubuntu pod interactively, never restart it, and remove it when it exits:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl run {{temp-ubuntu}} --image ubuntu:22.04 --restart Never --rm -- /bin/bash`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Run an Ubuntu pod, overriding the default command with echo, and specifying custom arguments:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl run {{temp-ubuntu}} --image ubuntu:22.04 --command -- echo {{argument1 argument2 ...}}`
|