KUBERNETES(1)(kubernetes)
π kubectl run π
okay so bestie, welcome to the KUBERNETES(1)(kubernetes) manual page, the one and only. This page got compiled by Eric Paris back in Jan 2015 and honestly? we're still thriving off it. sit down, hydrate, let's run some pods together π«Ά
β¨ NAME β¨
kubectl run β Run a particular image on the cluster π
β¨ SYNOPSIS β¨
kubectl run [OPTIONS]
β¨ DESCRIPTION β¨
Create and run a particular image in a pod. that's it, that's the whole vibe. you say image, it says pod, the cluster gets a whole new resident. main character energy fr fr πΈ
β¨ OPTIONS β¨
--allow-missing-template-keys=trueβ if true, just ignore any errors that pop up in templates when a field or map key is missing from the template. ngl this only applies to thegolangandjsonpathoutput formats, so don't get cute elsewhere π--annotations=[]β annotations to slap onto the pod. little notes for the pod, iykyk β¨--attach=falseβ if true, wait for the Pod to actually start running, and then attach to it as if you'd literally typedkubectl attach .... default is false, unless-i/--stdinis set, in which case the default flips to true. and with--restart=Neverthe exit code of the container process is what you get back. iconic behavior tbh--cascade="background"β must be one of"background","orphan", or"foreground". it picks the deletion cascading strategy for the dependents (think Pods created by a ReplicationController). defaults tobackground.--command=falseβ if true and there are extra arguments hanging around, those args become the'command'field in the container instead of the'args'field, which is what you get by default. choose wisely bestie--detach-keys="ctrl-p,ctrl-q"β override the key sequence you use to detach from a container π§--dry-run="none"β must be"none","server", or"client". if you pick the client strategy, it only prints the object that would be sent, without actually sending it. if you pick server strategy, it submits a server-side request without persisting the resource. manifesting without committing, we love to see it β¨--env=[]β environment variables to set in the container π--expose=falseβ if true, create a ClusterIP service associated with the pod. requires--port, no exceptions π--field-manager="kubectl-run"β the name of the manager used to track field ownership.--filename=[]β the source text for this one literally just says "to use to replace the resource." that's all it gives us. no cap. π--force=falseβ if true, immediately remove resources from the API and bypass graceful deletion. > heads up bestie: immediate deletion of some resources may result in inconsistency or data loss, and it requires confirmation. this is not a drill π--grace-period=-1β the period of time, in seconds, given to the resource to terminate gracefully. ignored if negative. set it to1for immediate shutdown. it can only be set to0when--forceis true (force deletion).--image=""β the image for the container to run. this is the whole point, the moment, the reason we're here π--image-pull-policy=""β the image pull policy for the container. if you leave it empty, the client won't specify this value at all and the server will default it for you.-k,--kustomize=""β process a kustomization directory. this flag can't be used together with-for-R. pick a lane, babe.-l,--labels=""β comma separated labels to apply to the pod. will override previous values, so the last one wins, periodt π--leave-stdin-open=falseβ if the pod is started in interactive mode or with stdin, leave stdin open after the first attach completes. by default, stdin gets closed once the first attach completes.-o,--output=""β output format. one of: (json,yaml,kyaml,name,go-template,go-template-file,template,templatefile,jsonpath,jsonpath-as-json,jsonpath-file). so many choices, all of them valid, go off β¨--override-type="merge"β the method used to override the generated object:json,merge, orstrategic.--overrides=""β an inline JSON override for the generated object. if this is non-empty, it gets used to override the generated object. requires that the object supply a validapiVersionfield or it's simply not happening.--pod-running-timeout=1m0sβ the length of time (like5s,2m, or3h, and it has to be higher than zero) to wait until at least one pod is running β³--port=""β the port that this container exposes.--privileged=falseβ if true, run the container in privileged mode. powerful. use with intention π-q,--quiet=falseβ if true, suppress prompt messages. shhh era π€«--record=falseβ record the current kubectl command in the resource annotation. if set tofalse, don't record the command. if set totrue, record it. if it's not set at all, it defaults to updating the existing annotation value only if one already exists.-R,--recursive=falseβ process the directory used in-f,--filenamerecursively. super useful when you want to manage related manifests organized within the same directory π--restart="Always"β the restart policy for this Pod. legal values are[Always, OnFailure, Never]. no other values, that's the whole list.--rm=falseβ if true, delete the pod after it exits. only valid when attaching to the container, e.g. with'--attach'or with'-i/--stdin'. clean up after yourself, we stan π§Ή--save-config=falseβ if true, the configuration of the current object gets saved in its annotation. otherwise the annotation stays unchanged. this flag is useful when you want to performkubectl applyon this object in the future. future-proofing, bestie π--show-managed-fields=falseβ if true, keep themanagedFieldswhen printing objects in JSON or YAML format.-i,--stdin=falseβ keep stdin open on the container in the pod, even if nothing is attached. commitment π--template=""β template string, or path to a template file, to use when-o=go-template,-o=go-template-file. the template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].--timeout=0sβ the length of time to wait before giving up on a delete. zero means determine a timeout from the size of the object.-t,--tty=falseβ allocate a TTY for the container in the pod. we're getting a real terminal, it's giving interactive β¨--wait=falseβ if true, wait for resources to be gone before returning. this waits for finalizers, so be patient, it's doing the work π«Ά
β¨ OPTIONS INHERITED FROM PARENT COMMANDS β¨
these come from the parent command, so they're not just run's thing β they're the family's thing π«Ά
--as=""β username to impersonate for the operation. user could be a regular user or a service account in a namespace.--as-group=[]β group to impersonate for the operation. this flag can be repeated to specify multiple groups.--as-uid=""β UID to impersonate for the operation.--as-user-extra=[]β user extras to impersonate for the operation. this flag can be repeated to specify multiple values for the same key.--cache-dir="/home/username/.kube/cache"β default cache directory.--certificate-authority=""β path to a cert file for the certificate authority.--client-certificate=""β path to a client certificate file for TLS.--client-key=""β path to a client key file for TLS.--cluster=""β the name of the kubeconfig cluster to use.--context=""β the name of the kubeconfig context to use.--disable-compression=falseβ if true, opt-out of response compression for all requests to the server.--insecure-skip-tls-verify=falseβ if true, the server's certificate will not be checked for validity. > this will make your HTTPS connections insecure, bestie. dramatic but true π₯--kubeconfig=""β path to the kubeconfig file to use for CLI requests.--kuberc=""β path to the kuberc file to use for preferences. this can be disabled by exportingKUBECTL_KUBERC=falsefeature gate or turning off the featureKUBERC=off.--match-server-version=falseβ require server version to match client version.-n,--namespace=""β if present, the namespace scope for this CLI request.--password=""β password for basic authentication to the API server.--profile="none"β name of profile to capture. one of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace).--profile-output="profile.pprof"β name of the file to write the profile to.--proxy-url=""β proxy URL to use for requests to the API server.--request-timeout="0"β the length of time to wait before giving up on a single server request. non-zero values should contain a corresponding time unit (e.g.1s,2m,3h). a value of zero means don't timeout requests.-s,--server=""β the address and port of the Kubernetes API server.--tls-server-name=""β server name to use for server certificate validation. if it is not provided, the hostname used to contact the server is used.--token=""β bearer token for authentication to the API server.--user=""β the name of the kubeconfig user to use.--username=""β username for basic authentication to the API server.--version=falseβ--version,--version=rawprints version information and quits;--version=vX.Y.Z...sets the reported version.--warnings-as-errors=falseβ treat warnings received from the server as errors and exit with a non-zero exit code. no chill mode, strictly business π€
β¨ EXAMPLE β¨
okay these are the recipes, bestie. copy them exactly, don't freestyle the flags π
# Start a nginx pod
kubectl run nginx --image=nginx
# Start a hazelcast pod and let the container expose port 5701
kubectl run hazelcast --image=hazelcast/hazelcast --port=5701
# Start a hazelcast pod and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container
kubectl run hazelcast --image=hazelcast/hazelcast --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default"
# Start a hazelcast pod and set labels "app=hazelcast" and "env=prod" in the container
kubectl run hazelcast --image=hazelcast/hazelcast --labels="app=hazelcast,env=prod"
# Dry run; print the corresponding API objects without creating them
kubectl run nginx --image=nginx --dry-run=client
# Start a nginx pod, but overload the spec with a partial set of values parsed from JSON
kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }'
# Start a busybox pod and keep it in the foreground, don't restart it if it exits
kubectl run -i -t busybox --image=busybox --restart=Never
# Start the nginx pod using the default command, but use custom arguments (arg1 .. argN) for that command
kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>
# Start the nginx pod using a different command and custom arguments
kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
β¨ SEE ALSO β¨
kubectl(1),β the parent, the blueprint, the moment π«Ά
β¨ HISTORY β¨
January 2015, Originally compiled by Eric Paris (eparis at redhat dot com) based on the kubernetes source material, but hopefully they have been automatically generated since! and honestly? hope they stayed generated, because hand-writing all those flags would be a whole saga π
and that's the page, bestie π
this was the Manuals / User flavor of KUBERNETES(1)(kubernetes), dated Jan 2015. go forth, run your pods, and remember: the vibe changes, the flags don't π β¨
π¦ where this page comes from
- arch rolling: kubectl 1.37.2-1 Β· Apache-2.0
- fedora 43: kubernetes1.37-client 1.37.0-3.fc43
- fedora 43: kubernetes1.37-client 1.37.1-1.fc43 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause-HP AND CC-BY-4.0 AND ISC AND MIT AND MPL-2.0
- fedora 44: kubernetes1.37-client 1.37.0-3.fc44
- fedora 44: kubernetes1.37-client 1.37.1-1.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause-HP AND CC-BY-4.0 AND ISC AND MIT AND MPL-2.0
- nixpkgs unstable: kubectl 1.37.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms