text
stringlengths
1
1k
id
int64
0
8.58k
kubectl diff -f pod.json Diff file read from stdin cat service.yaml | kubectl diff -f - Diff configurations specified by file name or stdin between the current online configuration, and the configuration as it would be if applied. The output is always YAML. KUBECTL_EXTERNAL_DIFF environment variable can be used to select your own diff command. Users can use external commands with params too, example: KUBECTL_EXTERNAL_DIFF="colordiff -N -u" By default, the "diff" command available in your path will be run with the "-u" (unified diff) and "-N" (treat absent files as empty) options. Exit status: 0 No differences were found. 1 Differences were found. >1 Kubectl or diff failed with an error. Note: KUBECTL_EXTERNAL_DIFF, if used, is expected to follow that convention. Usage $ kubectl diff -f FILENAME Flags Name Shorthand Default Usage field- managerkubectl- client-side- applyName of the manager used to track field ownership. filename f []Filename, directory, or URL to files contains the co
7,900
nfiguration to diff force- conflictsfalseIf true, server-side apply will force the changes against conflicts. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. selector lSelector (label query) to filter on, supports '=', '==', and '! ='.(e.g. -l key1=value1,key2=value2) server-side false If true, apply runs in the server instead of the client. edit Edit the service named 'docker-registry
7,901
kubectl edit svc/docker-registry Use an alternative editor KUBE_EDITOR ="nano" kubectl edit svc/docker-registry Edit the job 'myjob' in JSON using the v1 API format kubectl edit job.v1.batch/myjob -o json Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation kubectl edit deployment/mydeployment -o yaml -- save-config Edit a resource from the default editor. The edit command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the editor defined by your KUBE_EDITOR, or EDITOR environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows. You can edit multiple objects, although changes are applied one at a time. The command accepts file names as well as command-line arguments, although the files you point to must be previously saved versions of resources. Editing is done with the API version used to fetch the resource. To edit using a specific API version, fully-qualify the resource, v
7,902
ersion, and group. The default format is YAML. To edit in JSON, specify "-o json". The flag --windows-line-endings can be used to force Windows line endings, otherwise the default for your operating system will be used. In the event an error occurs while updating, a temporary file will be created on disk that contains your unapplied changes. The most common error when updating a resource is another editor changing the resource on the server. When this occurs, you will have to apply your changes to the newer version of the resource, or update your temporary saved copy to include the latest resource version. Usage $ kubectl edit (RESOURCE/NAME | -f FILENAME) Flags Name Shorthand Default Usage allow- missing- template- keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. field-managerkubectl- editName of the manager used to track field ownership. filename f []Filename, directory, or URL to
7,903
files to use to edit the resourc
7,904
Name Shorthand Default Usage kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. output-patch false Output the patch if the resource is edited. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. save-config falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. show- managed- fieldsfalseIf true,
7,905
keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. validate true If true, use a schema to validate the input before sending it windows- line-endingsfalse Defaults to the line ending native to your platform. kustomize Build the current working directory kubectl kustomize Build some shared configuration directory kubectl kustomize / home /config /production Build from github kubectl kustomize https: //github.com /kubernetes-sigs/ kustomize.git /examples/ helloWorld? ref=v1. 0.6 Build a set of KRM resources using a 'kustomization.yaml' file. The DIR argument must be a path to a directory containing 'kustomization.yaml', or a git repository URL with a path suffix specifying same with respect to the repository root. If DIR is omitted, '.' is assumed
7,906
Usage $ kubectl kustomize DIR Flags Name Shorthand Default Usage as-current- userfalseuse the uid and gid of the command executor to run the function in the container enable-alpha- pluginsfalse enable kustomize plugins enable-helm falseEnable use of the Helm chart inflator generator. enable- managedby- labelfalseenable adding app.kubernetes.io/ managed-by env e []a list of environment variables to be used by functions helm- commandhelm helm command (path to executable) load- restrictorLoadRestrictionsRootOnlyif set to 'LoadRestrictionsNone', local kustomizations may load files from outside their root. This does, however, break the relocatability of the kustomization. mount []a list of storage options read from the filesystem network falseenable network access for functions that declare it network- namebridgethe docker network to run the container in output o If specified, write output to this path. reorder legacyReorder the resources just before output. Use 'legacy' to apply
7,907
a legacy reordering (Namespaces first, Webhooks last, etc). Use 'none' to suppress a final reordering. label Update pod 'foo' with the label 'unhealthy' and the value 'true' kubectl label pods foo unhealthy= true Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value kubectl label --overwrite pods foo status=unhealth
7,908
Update all pods in the namespace kubectl label pods --all status=unhealthy Update a pod identified by the type and name in "pod.json" kubectl label -f pod.json status=unhealthy Update pod 'foo' only if the resource is unchanged from version 1 kubectl label pods foo status =unhealthy --resource-version =1 Update pod 'foo' by removing a label named 'bar' if it exists # Does not require the --overwrite flag kubectl label pods foo bar- Update the labels on a resource. A label key and value must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters each. Optionally, the key can begin with a DNS subdomain prefix and a single '/', like example.com/my-app. If --overwrite is true, then existing labels can be overwritten, otherwise attempting to overwrite a label will result in an error. If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used. Usage $ ku
7,909
bectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [-- resource-version=version] Flags Name Shorthand Default Usage all falseSelect all resources, including uninitialized ones, in the namespace of the specified resource types all- namespacesA false If true, check the specified action in all namespaces. allow- missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. field-managerkubectl- labelName of the manager used to track field ownership. field-selectorSelector (field query) to filter on, supports '=', '==', and '!='. (e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per t
7,910
ype. • • •
7,911
Name Shorthand Default Usage filename f []Filename, directory, or URL to files identifying the resource to update the labels kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. list false If true, display the labels for a given resource. local false If true, label will NOT contact api-server but run locally. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. overwrite falseIf true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized withi
7,912
n the same directory. resource- versionIf non-empty, the labels update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource. selector lSelector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. patch Partially update a node using a strategic merge patch, specifying the patch as JSON kubectl patch node k8s-node-1 -p '{"spec" :{"unschedulable" :true}}' Partially update a node using a strategic merge patch, specifying the patch as YAML kubectl patch node k8s-node-1 -p $' spec:\n unschedulable: true' Partially update a node identified by the type an
7,913
d name specified in "node.json" using strategic merge patch kubectl patch -f node .json -p '{"spec" :{"unschedulable" :true}}
7,914
Update a container's image; spec.containers[*].name is required because it's a merge key kubectl patch pod valid-pod -p '{ "spec" :{"containers" :[{"name" :"kubernetes-serve-hostname" ,"ima ge":"new image" }]}}' Update a container's image using a JSON patch with positional arrays kubectl patch pod valid-pod -- type='json' -p='[{ "op": "replace" , "path" : "/spec/containers/0/ image" , "value" :"new image" }]' Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch. JSON and YAML formats are accepted. Usage $ kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE] Flags Name Shorthand Default Usage allow- missing- template- keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit serve
7,915
r-side request without persisting the resource. field-managerkubectl- patchName of the manager used to track field ownership. filename f []Filename, directory, or URL to files identifying the resource to update kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. local falseIf true, patch will operate on the content of the file, not the server-side resource. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. patch p The patch to be applied to the resource JSON file. patch-file A file containing a patch to be applied to the resource. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Usef
7,916
ul when you want to manage related manifests organized within the same directory
7,917
Name Shorthand Default Usage show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. type strategicThe type of patch being provided; one of [json merge strategic ] replace Replace a pod using the data in pod.json kubectl replace -f ./pod.json Replace a pod based on the JSON passed into stdin cat pod.json | kubectl replace -f - Update a single-container pod's image version (tag) to v4 kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\ 1:v4/' | kubectl replace -f - Force replace, delete and then re-create the resource kubectl replace --force -f ./pod.json Replace a resource by file name or stdin. JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtain
7,918
ed by $ kubectl get TYPE NAME -o yaml Usage $ kubectl replace -f FILENAME Flags Name Shorthand Default Usage allow- missing- template- keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. cascade backgroundMust be "background", "orphan", or "foreground". Selects the deletion cascading strategy for th
7,919
Name Shorthand Default Usage dependents (e.g. Pods created by a ReplicationController). Defaults to background. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. field- managerkubectl- replaceName of the manager used to track field ownership. filename f [] to use to replace the resource. force falseIf true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation. grace-period -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion). kustomize kProcess a kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|n
7,920
ame|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. rawRaw URI to PUT to the server. Uses the transport specified by the kubeconfig file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. save-config falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the obj
7,921
ect validate trueIf true, use a schema to validate the input before sending it wait falseIf true, wait for resources to be gone before returning. This waits for finalizers
7,922
rollout Rollback to the previous deployment kubectl rollout undo deployment/ abc Check the rollout status of a daemonset kubectl rollout status daemonset/foo Manage the rollout of a resource. Valid resource types include: deployments daemonsets statefulsets Usage $ kubectl rollout SUBCOMMAND history View the rollout history of a deployment kubectl rollout history deployment/ abc View the details of daemonset revision 3 kubectl rollout history daemonset/abc --revision=3 View previous rollout revisions and configurations. Usage $ kubectl rollout history (TYPE NAME | TYPE/NAME) [flags] Flags Name Shorthand Default Usage allow-missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. filename f []Filename, directory, or URL to files identifying the resource to get from a server. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R.
7,923
output o• •
7,924
Name Shorthand Default Usage Output format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. revision 0See the details, including podTemplate of the revision specified show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. pause Mark the nginx deployment as paused # Any current state of the deployment will continue its function; new updates # to the deployment will not have an effect as long as the deployment is paused kubectl rollout pause deployment/nginx Mark the provided resource as paused. Paused resources will
7,925
not be reconciled by a controller. Use "kubectl rollout resume" to resume a paused resource. Currently only deployments support being paused. Usage $ kubectl rollout pause RESOURCE Flags Name Shorthand Default Usage allow- missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. field-managerkubectl- rolloutName of the manager used to track field ownership. filename f []Filename, directory, or URL to files identifying the resource to get from a server. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file
7,926
Name Shorthand Default Usage recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. restart Restart a deployment kubectl rollout restart deployment/nginx Restart a daemon set kubectl rollout restart daemonset/abc Restart a resource. Resource rollout will be restarted. Usage $ kubectl rollout restart RESOURCE Flags Name Shorthand Default Usage allow- missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. field-managerkubectl- rolloutName of the manager used to track field
7,927
ownership. filename f []Filename, directory, or URL to files identifying the resource to get from a server. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. falseIf true, keep the managedFields when printing objects in JSON or YAML format
7,928
Name Shorthand Default Usage show- managed- fields templateTemplate string or path to 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 ]. resume Resume an already paused deployment kubectl rollout resume deployment/nginx Resume a paused resource. Paused resources will not be reconciled by a controller. By resuming a resource, we allow it to be reconciled again. Currently only deployments support being resumed. Usage $ kubectl rollout resume RESOURCE Flags Name Shorthand Default Usage allow- missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. field-managerkubectl- rolloutName of the manager used to track field ownership. filename f []Filename, directory, or URL to files identifying the resource to get from a server. kustomize kProcess the kustomization director
7,929
y. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]
7,930
status Watch the rollout status of a deployment kubectl rollout status deployment/nginx Show the status of the rollout. By default 'rollout status' will watch the status of the latest rollout until it's done. If you don't want to wait for the rollout to finish then you can use --watch=false. Note that if a new rollout starts in-between, then 'rollout status' will continue watching the latest revision. If you want to pin to a specific revision and abort if it is rolled over by another revision, use --revision=N where N is the revision you need to watch for. Usage $ kubectl rollout status (TYPE NAME | TYPE/NAME) [flags] Flags Name Shorthand Default Usage filename f []Filename, directory, or URL to files identifying the resource to get from a server. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within th
7,931
e same directory. revision 0Pin to a specific revision for showing its status. Defaults to 0 (last revision). timeout 0sThe length of time to wait before ending watch, zero means never. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h). watch w true Watch the status of the rollout until it's done. undo Roll back to the previous deployment kubectl rollout undo deployment/ abc Roll back to daemonset revision 3 kubectl rollout undo daemonset/ abc --to-revision= 3 Roll back to the previous deployment with dry-run kubectl rollout undo --dry- run=server deployment/abc Roll back to a previous rollout
7,932
Usage $ kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags] Flags Name Shorthand Default Usage allow- missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. filename f []Filename, directory, or URL to files identifying the resource to get from a server. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. show- managed-
7,933
fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. to-revision 0 The revision to rollback to. Default to 0 (last revision). scale Scale a replica set named 'foo' to 3 kubectl scale --replicas =3 rs/foo Scale a resource identified by type and name specified in "foo.yaml" to 3 kubectl scale --replicas =3 -f foo.yaml If the deployment named mysql's current size is 2, scale mysql to 3 kubectl scale --current-replicas =2 --replicas =3 deployment/mysql Scale multiple replication controllers kubectl scale --replicas= 5 rc/foo rc/ bar rc/ba
7,934
Scale stateful set named 'web' to 3 kubectl scale --replicas =3 statefulset/web Set a new size for a deployment, replica set, replication controller, or stateful set. Scale also allows users to specify one or more preconditions for the scale action. If --current-replicas or --resource-version is specified, it is validated before the scale is attempted, and it is guaranteed that the precondition holds true when the scale is sent to the server. Usage $ kubectl scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT (-f FILENAME | TYPE NAME) Flags Name Shorthand Default Usage all falseSelect all resources in the namespace of the specified resource types allow- missing- template- keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. current- replicas-1Precondition for current size. Requires that the current size of the resource match this value in order to scale. -1 (
7,935
default) for no condition. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. filename f []Filename, directory, or URL to files identifying the resource to set a new size kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. replicas 0 The new des
7,936
ired number of replicas. Required. resource- versionPrecondition for resource version. Requires that the current resource version match this value in order to scale. selector
7,937
Name Shorthand Default Usage Selector (label query) to filter on, supports '=', '==', and '!='. (e.g. -l key1=value1,key2=value2) show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 0sThe length of time to wait before giving up on a scale operation, zero means don't wait. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h). set Configure application resources. These commands help you make changes to existing application resources. Usage $ kubectl set SUBCOMMAND env Update deployment 'registry' with a new environment variable kubectl set env deployment/registry STORAGE_DIR =/local List the environment variables defined on a deployments 'sample-build' kubectl set env deployment/ sample -build --list List the e
7,938
nvironment variables defined on all pods kubectl set env pods --all --list Output modified deployment in YAML, and does not alter the object on the server kubectl set env deployment/sample-build STORAGE_DIR =/data -o yaml Update all containers in all replication controllers in the project to have ENV=prod kubectl set env rc --all ENV =prod Import environment from a secret kubectl set env --from =secret/mysecret deployment/myap
7,939
Import environment from a config map with a prefix kubectl set env --from =configmap/myconfigmap --prefix =MYSQL_ deployment/myapp Import specific keys from a config map kubectl set env --keys =my-example-key --from =configmap/myconfigmap deployment/myapp Remove the environment variable ENV from container 'c1' in all deployment configs kubectl set env deployments --all --containers= "c1" ENV- Remove the environment variable ENV from a deployment definition on disk and # update the deployment config on the server kubectl set env -f deploy.json ENV - Set some of the local shell environment into a deployment config on the server env | grep RAILS_ | kubectl set env -e - deployment/registry Update environment variables on a pod template. List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod templates (within replication controllers or deployment configurations). View or modify the envir
7,940
onment variable definitions on all containers in the specified pods or pod templates, or just those that match a wildcard. If "--env -" is passed, environment variables can be read from STDIN using the standard env syntax. Possible resources include (case insensitive): pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs) Usage $ kubectl set env RESOURCE/NAME KEY_1=VAL_1 ... KEY_N=VAL_N Flags Name Shorthand Default Usage all falseIf true, select all resources in the namespace of the specified resource types allow-missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. containers c *The names of containers in the selected pod templates to change - may use wildcards dry-run non
7,941
Name Shorthand Default Usage Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. env e []Specify a key-value pair for an environment variable to set into each container. field-managerkubectl- setName of the manager used to track field ownership. filename f []Filename, directory, or URL to files the resource to update the env fromThe name of a resource from which to inject environment variables keys []Comma-separated list of keys to import from specified resource kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. list falseIf true, display the environment and any changes in the standard format. this flag will removed when we have kubectl view env. local false If true, set env will NOT contact api-server but run locally. output oOutput format. One of: json|yaml|name|go-template|go- templat
7,942
e-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. overwrite trueIf true, allow environment to be overwritten, otherwise reject updates that overwrite existing environment. prefix Prefix to append to variable names recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. resolve falseIf true, show secret or configmap references when listing variables selector l Selector (label query) to filter on show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. image Set a deployment's nginx container image to 'nginx:1.9.1', and its busybox container image to 'busybox' kubectl set image deployment/nginx busybox =busybox nginx =n
7,943
ginx:1.9.1 Update all deployments' and rc's nginx container's image to 'nginx:1.9.1
7,944
kubectl set image deployments,rc nginx =nginx:1.9.1 --all Update image of all containers of daemonset abc to 'nginx:1.9.1' kubectl set image daemonset abc *=nginx: 1.9.1 Print result (in yaml format) of updating nginx container image from local file, without hitting the server kubectl set image -f path/ to/file.yaml nginx =nginx:1.9.1 --local -o yaml Update existing container image(s) of resources. Possible resources include (case insensitive): pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs) Usage $ kubectl set image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N Flags Name Shorthand Default Usage all falseSelect all resources, including uninitialized ones, in the namespace of the specified resource types allow- missing- template- keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and
7,945
jsonpath output formats. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. field- managerkubectl- setName of the manager used to track field ownership. filename f []Filename, directory, or URL to files identifying the resource to get from a server. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. local falseIf true, set image will NOT contact api-server but run locally. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists
7,946
Name Shorthand Default Usage recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. selector lSelector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. resources Set a deployments nginx container cpu limits to "200m" and memory to "512Mi" kubectl set resources deployment nginx -c=nginx --limits =cpu=200m,memory=512Mi Set the resource request and limits for all containers in nginx kubectl set resources deployment nginx --limits =cpu=200m,memory=512Mi --requests =cpu=100 m,memory=256Mi Remove the resource request
7,947
s for resources on containers in nginx kubectl set resources deployment nginx --limits =cpu=0,memory=0 --requests =cpu=0,memory=0 Print the result (in yaml format) of updating nginx container limits from a local, without hitting the server kubectl set resources -f path/ to/file.yaml --limits =cpu=200m,memory=512Mi --local -o yaml Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to its specified limits. For each compute resource, if a limit is specified and a request is omitted, the request will default to the limit. Possible resources include (case insensitive): Use "kubectl api-resources" for a complete list of supported resources.. Usage $ kubectl set resources (-f FILENAME | TYPE NAME) ([--limits=LIMITS & -- requests=REQUESTS
7,948
Flags Name Shorthand Default Usage all falseSelect all resources, including uninitialized ones, in the namespace of the specified resource types allow- missing- template- keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. containers c *The names of containers in the selected pod templates to change, all containers are selected by default - may use wildcards dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. field- managerkubectl- setName of the manager used to track field ownership. filename f []Filename, directory, or URL to files identifying the resource to get from a server. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. limitsThe resource requirement requests for this
7,949
container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges. local falseIf true, set resources will NOT contact api-server but run locally. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. requestsThe resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit range
7,950
s. selector lSelector (label query) to filter on, not including uninitialized ones,supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to template file to use when -o=go- template, -o=go-template-file. The template format i
7,951
Name Shorthand Default Usage golang templates [http://golang.org/pkg/text/template/ #pkg-overview ]. selector Set the labels and selector before creating a deployment/service pair kubectl create service clusterip my-svc --clusterip ="None" -o yaml --dry-run =client | kubectl set selector --local -f - 'environment=qa' -o yaml | kubectl create -f - kubectl create deployment my-dep -o yaml --dry-run =client | kubectl label --local -f - environm ent=qa -o yaml | kubectl create -f - Set the selector on a resource. Note that the new selector will overwrite the old selector if the resource had one prior to the invocation of 'set selector'. A selector must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters. If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used. Note: currently selectors can only be set on Service objects. Usage $ kubectl set sel
7,952
ector (-f FILENAME | TYPE NAME) EXPRESSIONS [--resource- version=version] Flags Name Shorthand Default Usage all falseSelect all resources in the namespace of the specified resource types allow- missing- template- keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. field- managerkubectl- setName of the manager used to track field ownership. filename f [] identifying the resource. local falseIf true, annotation will NOT contact api-server but run locally. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. record falseRecord current kubectl command in the resource annotation. If set to
7,953
false, do not record the command. If se
7,954
Name Shorthand Default Usage to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R trueProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. resource- versionIf non-empty, the selectors update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. serviceaccount Set deployment nginx-deployment's service account to serviceaccount1 kubectl set serviceaccount deployment nginx-deployment serviceaccount1 Print the result (in YAML format) of updated nginx deployment
7,955
with the service account from local file, without hitting the API server kubectl set sa -f nginx-deployment.yaml serviceaccount1 --local --dry-run =client -o yaml Update the service account of pod template resources. Possible resources (case insensitive) can be: replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset Usage $ kubectl set serviceaccount (-f FILENAME | TYPE NAME) SERVICE_ACCOUNT Flags Name Shorthand Default Usage all falseSelect all resources, including uninitialized ones, in the namespace of the specified resource types allow- missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource
7,956
Name Shorthand Default Usage field-managerkubectl- setName of the manager used to track field ownership. filename f []Filename, directory, or URL to files identifying the resource to get from a server. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. local falseIf true, set serviceaccount will NOT contact api-server but run locally. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. record falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. show- managed- fieldsfalseIf true, keep the managedFields when printi
7,957
ng objects in JSON or YAML format. templateTemplate string or path to 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 ]. subject Update a cluster role binding for serviceaccount1 kubectl set subject clusterrolebinding admin --serviceaccount =namespace:serviceaccount1 Update a role binding for user1, user2, and group1 kubectl set subject rolebinding admin --user =user1 --user =user2 --group =group1 Print the result (in YAML format) of updating rolebinding subjects from a local, without hitting the server kubectl create rolebinding admin --role =admin --user =admin -o yaml --dry-run =client | kubectl set subject --local -f - --user =foo -o yaml Update the user, group, or service account in a role binding or cluster role binding. Usage $ kubectl set subject (-f FILENAME | TYPE NAME) [--user=username] [--group=groupname] [-- serviceaccount=namespace:serviceaccountname] [--dry-run=
7,958
server|client|none
7,959
Flags Name Shorthand Default Usage all falseSelect all resources, including uninitialized ones, in the namespace of the specified resource types allow-missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. field-managerkubectl- setName of the manager used to track field ownership. filename f []Filename, directory, or URL to files the resource to update the subjects group [] Groups to bind to the role kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. local falseIf true, set subject will NOT contact api-server but run locally. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|te
7,960
mplatefile|jsonpath|jsonpath- as-json|jsonpath-file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. selector lSelector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) serviceaccount [] Service accounts to bind to the role show-managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. wait Wait for the pod "busybox1" to contain the status condition of type "Ready" kubectl wait --for=condition=Ready pod/busybox1 The default value of status condition is true; you can set it to false kubectl wait --for=condition=Ready= false pod/busybox
7,961
Wait for the pod "busybox1" to be deleted, with a timeout of 60s, after having issued the "delete" command kubectl delete pod/busybox1 kubectl wait --for=delete pod/busybox1 --timeout =60s Experimental: Wait for a specific condition on one or many resources. The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resource. Alternatively, the command can wait for the given set of resources to be deleted by providing the "delete" keyword as the value to the --for flag. A successful message will be printed to stdout indicating when the specified condition has been met. You can use -o option to change to output destination. Usage $ kubectl wait ([-f FILENAME] | resource.group/resource.name | resource.group [(-l label | -- all)]) [--for=delete|--for condition=available] Flags Name Shorthand Default Usage all falseSelect all resources in the namespace of the specified resource types all-namespaces A falseIf present, list the re
7,962
quested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. allow-missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. field-selectorSelector (field query) to filter on, supports '=', '==', and '!='. (e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. filename f [] identifying the resource. forThe condition to wait on: [delete|condition=condition- name ]. The default status value of condition-name is true, you can set false with condition=condition-name=false local falseIf true, annotation will NOT contact api-server but run locally. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. recursive R trueProcess the directory used in -f, --filename recursively.
7,963
Useful when you want to manage related manifests organized within the same directory. selector lSelector (label query) to filter on, supports '=', '==', and '!='. (e.g. -l key1=value1,key2=value2) fals
7,964
Name Shorthand Default Usage show- managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 30sThe length of time to wait before giving up. Zero means check once and don't wait, negative means wait for a week. WORKING WITH APPS This section contains commands for inspecting and debugging your applications. logs will print the logs from the specified pod + container. exec can be used to get an interactive shell on a pod + container. describe will print debug information about the given resource. attach Get output from running pod mypod; use the 'kubectl.kubernetes.io/default- container' annotation # for selecting the container to be attached or the first container in the pod will be chosen kubectl attach mypod Get output from ruby-container from pod
7,965
mypod kubectl attach mypod -c ruby-container Switch to raw terminal mode; sends stdin to 'bash' in ruby-container from pod mypod # and sends stdout/stderr from 'bash' back to the client kubectl attach mypod -c ruby-container -i -t Get output from the first pod of a replica set named nginx kubectl attach rs/nginx Attach to a process that is already running inside an existing container. Usage $ kubectl attach (POD | TYPE/NAME) -c CONTAINER• •
7,966
Flags Name Shorthand Default Usage container cContainer name. If omitted, use the kubectl.kubernetes.io/ default-container annotation for selecting the container to be attached or the first container in the pod will be chosen pod- running- timeout1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running quiet q false Only print output from the remote session stdin i false Pass stdin to the container tty t false Stdin is a TTY auth Inspect authorization Usage $ kubectl auth can-i Check to see if I can create pods in any namespace kubectl auth can-i create pods --all-namespaces Check to see if I can list deployments in my current namespace kubectl auth can-i list deployments.apps Check to see if I can do everything in my current namespace ("*" means all) kubectl auth can- i '*' '*' Check to see if I can get the job named "bar" in namespace "foo" kubectl auth can-i list jobs.batch/bar -n foo Check to see if I can read pod logs kubectl au
7,967
th can-i get pods --subresource =log Check to see if I can access the URL /logs/ kubectl auth can-i get /logs/ List all allowed actions in namespace "foo
7,968
kubectl auth can-i --list -- namespace =foo Check whether an action is allowed. VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL that starts with "/". NAME is the name of a particular Kubernetes resource. Usage $ kubectl auth can-i VERB [TYPE | TYPE/NAME | NONRESOURCEURL] Flags Name Shorthand Default Usage all-namespaces A false If true, check the specified action in all namespaces. list false If true, prints all allowed actions. no-headers false If true, prints allowed actions without headers quiet q false If true, suppress output and just return the exit code. subresource SubResource such as pod/log or deployment/scale reconcile Reconcile RBAC resources from a file kubectl auth reconcile -f my-rbac-rules.yaml Reconciles rules for RBAC role, role binding, cluster role, and cluster role binding objects. Missing objects are created, and the containin
7,969
g namespace is created for namespaced objects, if required. Existing roles are updated to include the permissions in the input objects, and remove extra permissions if --remove-extra-permissions is specified. Existing bindings are updated to include the subjects in the input objects, and remove extra subjects if --remove-extra-subjects is specified. This is preferred to 'apply' for RBAC resources so that semantically-aware merging of rules and subjects is done. Usage $ kubectl auth reconcile -f FILENAME Flags Name Shorthand Default Usage allow-missing- template-keystru
7,970
Name Shorthand Default Usage If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. dry-run noneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. filename f []Filename, directory, or URL to files identifying the resource to reconcile. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. remove-extra- permissionsfalse If true, removes extra permissions added to roles remove-extra- subjectsfalse If true, rem
7,971
oves extra subjects added to rolebindings show- managed-fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. cp !!!Important Note!!! # Requires that the 'tar' binary is present in your container # image. If 'tar' is not present, 'kubectl cp' will fail. # # For advanced use cases, such as symlinks, wildcard expansion or # file mode preservation, consider using 'kubectl exec'. # Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace tar cf - /tmp/ foo | kubectl exec -i -n <some-namespace> <some-pod> -- tar xf - -C /tmp/ bar Copy /tmp/foo from a remote pod to /tmp/bar locally kubectl exec -n <some-namespace> <some-pod> -- tar cf - /tmp/ foo | tar xf - -C /tmp/ bar Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default
7,972
namespace kubectl cp /tmp/foo_dir <some-pod> :/tmp/bar_dir Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container kubectl cp /tmp/ foo <some-pod> :/tmp/ bar -c <specific-container
7,973
Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace kubectl cp /tmp/ foo <some-namespace> /<some-pod> :/tmp/ bar Copy /tmp/foo from a remote pod to /tmp/bar locally kubectl cp <some-namespace> /<some-pod> :/tmp/ foo /tmp/ bar Copy files and directories to and from containers. Usage $ kubectl cp <file-spec-src> <file-spec-dest> Flags Name Shorthand Default Usage container cContainer name. If omitted, use the kubectl.kubernetes.io/ default-container annotation for selecting the container to be attached or the first container in the pod will be chosen no- preservefalseThe copied file/directory's ownership and permissions will not be preserved in the container describe Describe a node kubectl describe nodes kubernetes- node -emt8 .c.myproject.internal Describe a pod kubectl describe pods/nginx Describe a pod identified by type and name in "pod.json" kubectl describe -f pod.json Describe all pods kubectl describe pods Describe pods by label name=myLabel kubectl describe
7,974
po -l name =myLabel Describe all pods managed by the 'frontend' replication controller (rc-created pods # get the name of the rc as a prefix in the pod the name) kubectl describe pods frontend Show details of a specific resource or group of resources
7,975
Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects of that type, provide a name prefix, or label selector. For example: $ kubectl describe TYPE NAME_PREFIX will first check for an exact match on TYPE and NAME_PREFIX. If no such resource exists, it will output details for every resource that has a name prefixed with NAME_PREFIX. Use "kubectl api-resources" for a complete list of supported resources. Usage $ kubectl describe (-f FILENAME | TYPE [NAME_PREFIX | -l label] | TYPE/NAME) Flags Name Shorthand Default Usage all- namespacesA falseIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. chunk-size 500Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may change in the future. filename f []Filename, directory, or URL to files containing the
7,976
resource to describe kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. selector lSelector (label query) to filter on, supports '=', '==', and '!='. (e.g. -l key1=value1,key2=value2) show-events true If true, display events related to the described object. exec Get output from running the 'date' command from pod mypod, using the first container by default kubectl exec mypod -- date Get output from running the 'date' command in ruby-container from pod mypod kubectl exec mypod -c ruby- container -- date Switch to raw terminal mode; sends stdin to 'bash' in ruby-container from pod mypod # and sends stdout/stderr from 'bash' back to the client kubectl exec mypod -c ruby- container -i -t -- bash -i
7,977
List contents of /usr from the first container of pod mypod and sort by modification time # If the command you want to execute in the pod has any flags in common (e.g. -i), # you must use two dashes (--) to separate your command's flags/arguments # Also note, do not surround your command and its flags/arguments with quotes # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr") kubectl exec mypod -i - t -- ls - t /usr Get output from running 'date' command from the first pod of the deployment mydeployment, using the first container by default kubectl exec deploy/mydeployment -- date Get output from running 'date' command from the first pod of the service myservice, using the first container by default kubectl exec svc/myservice -- date Execute a command in a container. Usage $ kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...] Flags Name Shorthand Default Usage container cContainer name. If omitted, use the kubectl.kubernetes.i
7,978
o/ default-container annotation for selecting the container to be attached or the first container in the pod will be chosen filename f [] to use to exec into the resource pod- running- timeout1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running quiet q false Only print output from the remote session stdin i false Pass stdin to the container tty t false Stdin is a TTY logs Return snapshot logs from pod nginx with only one container kubectl logs nginx Return snapshot logs from pod nginx with multi containers kubectl logs nginx -- all-containers= true Return snapshot logs from all containers in pods defined by label app=nginx kubectl logs -l app=nginx --all-containers =tru
7,979
Return snapshot of previous terminated ruby container logs from pod web-1 kubectl logs -p -c ruby web -1 Begin streaming the logs of the ruby container in pod web-1 kubectl logs -f -c ruby web -1 Begin streaming the logs from all containers in pods defined by label app=nginx kubectl logs -f -l app=nginx --all-containers =true Display only the most recent 20 lines of output in pod nginx kubectl logs --tail =20 nginx Show all logs from pod nginx written in the last hour kubectl logs --since =1h nginx Show logs from a kubelet with an expired serving certificate kubectl logs --insecure-skip-tls-verify-backend nginx Return snapshot logs from first container of a job named hello kubectl logs job/hello Return snapshot logs from container nginx-1 of a deployment named nginx kubectl logs deployment/nginx -c nginx -1 Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional. Usage $ kubectl logs [-f] [-p] (POD | TYPE/NAME) [-
7,980
c CONTAINER] Flags Name Shorthand Default Usage all-containers false Get all containers' logs in the pod(s). container c Print the logs of this container follow f false Specify if the logs should be streamed. ignore-errors falseIf watching / following pod logs, allow for any errors that occur to be non-fatal insecure-skip- tls-verify- backendfalseSkip verifying the identity of the kubelet that logs are requested from. In theory, an attacker could provide invalid log content back. You might want to use this if your kubelet serving certificates have expired. limit-bytes 0 Maximum bytes of logs to return. Defaults to no limit.
7,981
Name Shorthand Default Usage max-log- requestsSpecify maximum number of concurrent logs to follow when using by a selector. Defaults to 5. pod-running- timeout20sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running prefix falsePrefix each log line with the log source (pod name and container name) previous p falseIf true, print the logs for the previous instance of the container in a pod if it exists. selector l Selector (label query) to filter on. since 0sOnly return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since-time / since may be used. since-timeOnly return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used. tail -1Lines of recent log file to display. Defaults to -1 with no selector, showing all log lines otherwise 10, if a selector is provided. timestamps false Include timestamps on each line in the log output port-forward List
7,982
en on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod kubectl port-forward pod/mypod 5000 6000 Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment kubectl port-forward deployment/mydeployment 5000 6000 Listen on port 8443 locally, forwarding to the targetPort of the service's port named "https" in a pod selected by the service kubectl port-forward service/myservice 8443:https Listen on port 8888 locally, forwarding to 5000 in the pod kubectl port-forward pod/mypod 8888:5000 Listen on port 8888 on all addresses, forwarding to 5000 in the pod kubectl port-forward --address 0.0.0.0 pod/mypod 8888:5000 Listen on port 8888 on localhost and selected IP, forwarding to 5000 in the pod kubectl port-forward --address localhost, 10.19 .21.23 pod/mypod 8888:5000 Listen on a random port locally, forwarding to 5000 in the po
7,983
kubectl port-forward pod/mypod : 5000 Forward one or more local ports to a pod. Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted. If there are multiple pods matching the criteria, a pod will be selected automatically. The forwarding session ends when the selected pod terminates, and a rerun of the command is needed to resume forwarding. Usage $ kubectl port-forward TYPE/NAME [options] [LOCAL_PORT:]REMOTE_PORT [... [LOCAL_PORT_N:]REMOTE_PORT_N] Flags Name Shorthand Default Usage address [localhost]Addresses to listen on (comma separated). Only accepts IP addresses or localhost as a value. When localhost is supplied, kubectl will try to bind on both 127.0.0.1 and ::1 and will fail if neither of these addresses are available to bind. pod- running- timeout1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running proxy To proxy all of the Kubernetes API and nothing else kubectl
7,984
proxy --api-prefix =/ To proxy only part of the Kubernetes API and also some static files # You can get pods info with 'curl localhost:8001/api/v1/pods' kubectl proxy --www =/my/files --www-prefix =/static/ --api-prefix =/api/ To proxy the entire Kubernetes API at a different root # You can get pods info with 'curl localhost:8001/custom/api/v1/pods' kubectl proxy --api-prefix =/custom/ Run a proxy to the Kubernetes API server on port 8011, serving static content from ./local/www/ kubectl proxy --port =8011 --www =./local/www/ Run a proxy to the Kubernetes API server on an arbitrary local port # The chosen port for the server will be output to stdou
7,985
kubectl proxy --port =0 Run a proxy to the Kubernetes API server, changing the API prefix to k8s-api # This makes e.g. the pods API available at localhost:8001/k8s-api/v1/pods/ kubectl proxy --api-prefix =/k8s-api Creates a proxy server or application-level gateway between localhost and the Kubernetes API server. It also allows serving static content over specified HTTP path. All incoming data enters through one port and gets forwarded to the remote Kubernetes API server port, except for the path matching the static content path. Usage $ kubectl proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix] Flags Name Shorthand Default Usage accept- hosts^localhost$,^127.0.0.1$,^[:: 1]$Regular expression for hosts that the proxy should accept. accept- paths^.*Regular expression for paths that the proxy should accept. address 127.0.0.1 The IP address on which to serve on. api-prefix / Prefix to serve the proxied API under. disable- filterfalseIf true, disable r
7,986
equest filtering in the proxy. This is dangerous, and can leave you vulnerable to XSRF attacks, when used with an accessible port. keepalive 0skeepalive specifies the keep-alive period for an active network connection. Set to 0 to disable keepalive. port p 8001The port on which to run the proxy. Set to 0 to pick a random port. reject- methods^$Regular expression for HTTP methods that the proxy should reject (example --reject- methods='POST,PUT,PATCH'). reject- paths^/api/. /pods/./exec,^/api/. / pods/./attachRegular expression for paths that the proxy should reject. Paths specified here will be rejected even accepted by --accept-paths. unix- socketu Unix socket on which to run the proxy. www wAlso serve static files from the given directory under the specified prefix. www- prefixP /static/Prefix to serve static files under, if static file directory is specified
7,987
top Display Resource (CPU/Memory) usage. The top command allows you to see the resource consumption for nodes or pods. This command requires Metrics Server to be correctly configured and working on the server. Usage $ kubectl top node Show metrics for all nodes kubectl top node Show metrics for a given node kubectl top node NODE_NAME Display resource (CPU/memory) usage of nodes. The top-node command allows you to see the resource consumption of nodes. Usage $ kubectl top node [NAME | -l label] Flags Name Shorthand Default Usage no-headers false If present, print output without headers selector lSelector (label query) to filter on, supports '=', '==', and '!='. (e.g. -l key1=value1,key2=value2) sort-byIf non-empty, sort nodes list using specified field. The field can be either 'cpu' or 'memory'. use-protocol- bufferstrue Enables using protocol-buffers to access Metrics API. pod Show metrics for all pods in the default namespace kubectl top pod Show metrics for all pods in the given
7,988
namespac
7,989
kubectl top pod -- namespace =NAMESPACE Show metrics for a given pod and its containers kubectl top pod POD_NAME --containers Show metrics for the pods defined by label name=myLabel kubectl top pod -l name =myLabel Display resource (CPU/memory) usage of pods. The 'top pod' command allows you to see the resource consumption of pods. Due to the metrics pipeline delay, they may be unavailable for a few minutes since pod creation. Usage $ kubectl top pod [NAME | -l label] Flags Name Shorthand Default Usage all- namespacesA falseIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. containers false If present, print usage of containers within a pod. field-selectorSelector (field query) to filter on, supports '=', '==', and '!='. (e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. no-headers false If present, print output without headers.
7,990
selector lSelector (label query) to filter on, supports '=', '==', and '!='. (e.g. -l key1=value1,key2=value2) sort-byIf non-empty, sort pods list using specified field. The field can be either 'cpu' or 'memory'. use-protocol- bufferstrue Enables using protocol-buffers to access Metrics API. CLUSTER MANAGEMENT api-versions Print the supported API versions kubectl api-versions Print the supported API versions on the server, in the form of "group/version"
7,991
Usage $ kubectl api-versions certificate Modify certificate resources. Usage $ kubectl certificate SUBCOMMAND approve Approve CSR 'csr-sqgzp' kubectl certificate approve csr-sqgzp Approve a certificate signing request. kubectl certificate approve allows a cluster admin to approve a certificate signing request (CSR). This action tells a certificate signing controller to issue a certificate to the requestor with the attributes requested in the CSR. SECURITY NOTICE: Depending on the requested attributes, the issued certificate can potentially grant a requester access to cluster resources or to authenticate as a requested identity. Before approving a CSR, ensure you understand what the signed certificate can do. Usage $ kubectl certificate approve (-f FILENAME | NAME) Flags Name Shorthand Default Usage allow-missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. filename f []
7,992
Filename, directory, or URL to files identifying the resource to update force false Update the CSR even if it is already approved. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. recursive R fals
7,993
Name Shorthand Default Usage Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to 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 ]. deny Deny CSR 'csr-sqgzp' kubectl certificate deny csr-sqgzp Deny a certificate signing request. kubectl certificate deny allows a cluster admin to deny a certificate signing request (CSR). This action tells a certificate signing controller to not to issue a certificate to the requestor. Usage $ kubectl certificate deny (-f FILENAME | NAME) Flags Name Shorthand Default Usage allow-missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang
7,994
and jsonpath output formats. filename f []Filename, directory, or URL to files identifying the resource to update force false Update the CSR even if it is already denied. kustomize kProcess the kustomization directory. This flag can't be used together with -f or -R. output oOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. recursive R falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. show- managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to template file to use when - o=go-template, -o=go-template-file. The template format i
7,995
Name Shorthand Default Usage golang templates [http://golang.org/pkg/text/template/ #pkg-overview ]. cluster-info Print the address of the control plane and cluster services kubectl cluster- info Display addresses of the control plane and services with label kubernetes.io/cluster- service=true. To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. Usage $ kubectl cluster-info dump Dump current cluster state to stdout kubectl cluster- info dump Dump current cluster state to /path/to/cluster-state kubectl cluster- info dump --output-directory =/path/to/cluster-state Dump all namespaces to stdout kubectl cluster -info dump --all-namespaces Dump a set of namespaces to /path/to/cluster-state kubectl cluster -info dump --namespaces default ,kube- system --output-directory=/path/to/ cluste r-state Dump cluster information out suitable for debugging and diagnosing cluster problems. By default, dumps everything to stdout. You can optionally specify a directory wit
7,996
h --output- directory. If you specify a directory, Kubernetes will build a set of files in that directory. By default, only dumps things in the current namespace and 'kube-system' namespace, but you can switch to a different namespace with the --namespaces flag, or specify --all-namespaces to dump all namespaces. The command also dumps the logs of all of the pods in the cluster; these logs are dumped into different directories based on namespace and pod name. Usage $ kubectl cluster-info dum
7,997
Flags Name Shorthand Default Usage all-namespaces A falseIf true, dump all namespaces. If true, --namespaces is ignored. allow-missing- template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. namespaces [] A comma separated list of namespaces to dump. output o jsonOutput format. One of: json|yaml|name|go-template|go- template-file|template|templatefile|jsonpath|jsonpath-as- json|jsonpath-file. output- directoryWhere to output the files. If empty or '-' uses stdout, otherwise creates a directory hierarchy in that directory pod-running- timeout20sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running show-managed- fieldsfalseIf true, keep the managedFields when printing objects in JSON or YAML format. templateTemplate string or path to template file to use when - o=go-template, -o=go-template-file. The template format is golang templ
7,998
ates [http://golang.org/pkg/text/template/ #pkg-overview ]. cordon Mark node "foo" as unschedulable kubectl cordon foo Mark node as unschedulable. Usage $ kubectl cordon NODE Flags Name Shorthand Default Usage dry- runnoneMust be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. selector l Selector (label query) to filter o
7,999