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 the golang and jsonpath output 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 typed kubectl attach .... default is false, unless -i/--stdin is set, in which case the default flips to true. and with --restart=Never the 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 to background.
  • --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 to 1 for immediate shutdown. it can only be set to 0 when --force is 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 -f or -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, or strategic.
  • --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 valid apiVersion field or it's simply not happening.
  • --pod-running-timeout=1m0s β€” the length of time (like 5s, 2m, or 3h, 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 to false, don't record the command. if set to true, 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, --filename recursively. 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 perform kubectl apply on this object in the future. future-proofing, bestie πŸ’œ
  • --show-managed-fields=false β€” if true, keep the managedFields when 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 exporting KUBECTL_KUBERC=false feature gate or turning off the feature KUBERC=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=raw prints 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