Kubernetes Commands

  • Uploaded by: Ovigz Hero
  • 0
  • 0
  • January 2021
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Kubernetes Commands as PDF for free.

More details

  • Words: 12,895
  • Pages: 36
Loading documents preview...
kubectl controls the Kubernetes cluster manager. Find more information at https://github.com/kubernetes/kubernetes. Basic Commands (Beginner): create Create a resource by filename or stdin expose Take a replication controller, service, deployment or pod and e xpose it as a new Kubernetes Service run Run a particular image on the cluster set Set specific features on objects Basic Commands (Intermediate): get Display one or many resources explain Documentation of resources edit Edit a resource on the server delete Delete resources by filenames, stdin, resources and names, or b y resources and label selector Deploy Commands: rollout rolling-update scale ller, or Job autoscale

Manage a deployment rollout Perform a rolling update of the given ReplicationController Set a new size for a Deployment, ReplicaSet, Replication Contro Auto-scale a Deployment, ReplicaSet, or ReplicationController

Cluster Management Commands: certificate Modify certificate resources. cluster-info Display cluster info top Display Resource (CPU/Memory/Storage) usage cordon Mark node as unschedulable uncordon Mark node as schedulable drain Drain node in preparation for maintenance taint Update the taints on one or more nodes Troubleshooting describe logs attach exec port-forward proxy cp

and Debugging Commands: Show details of a specific resource or group of resources Print the logs for a container in a pod Attach to a running container Execute a command in a container Forward one or more local ports to a pod Run a proxy to the Kubernetes API server Copy files and directories to and from containers.

Advanced Commands: apply Apply a configuration to a resource by filename or stdin patch Update field(s) of a resource using strategic merge patch replace Replace a resource by filename or stdin convert Convert config files between different API versions Settings Commands: label Update the labels on a resource annotate Update the annotations on a resource completion Output shell completion code for the given shell (bash or zsh) Other Commands: api-versions "group/version" config help version

Print the supported API versions on the server, in the form of Modify kubeconfig files Help about any command Print the client and server version information

Use "kubectl --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands). ========================================================= The following options can be passed to any command: --alsologtostderr=false: log to standard error as well as files --api-version='': DEPRECATED: The API version to use when talking to the s erver --as='': Username to impersonate for the operation --certificate-authority='': Path to a cert. file for the certificate autho rity --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 --insecure-skip-tls-verify=false: If true, the server's certificate will n ot be checked for validity. This will make your HTTPS connections insecure --kubeconfig='': Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace --log-dir='': If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client versi on -n, --namespace='': If present, the namespace scope for this CLI request --password='': Password for basic authentication to the API server --request-timeout='0': The length of time to wait before giving up on a si ngle server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero mean s don't timeout requests. -s, --server='': The address and port of the Kubernetes API server --stderrthreshold=2: logs at or above this threshold go to stderr --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 -v, --v=0: log level for V logs --vmodule=: comma-separated list of pattern=N settings for file-filtered l ogging ========================================================= ============ Create a resource by filename or stdin. JSON and YAML formats are accepted. Examples: # Create a pod using the data in pod.json. kubectl create -f ./pod.json # Create a pod based on the JSON passed into stdin. cat pod.json | kubectl create -f # Edit the data in docker-registry.yaml in JSON using the v1 API format then c reate the resource using the edited data. kubectl create -f docker-registry.yaml --edit --output-version=v1 -o json Available Commands: configmap Create a configmap from a local file, directory or literal valu

e deployment namespace quota secret service serviceaccount

Create Create Create Create Create Create

a a a a a a

deployment with the specified name. namespace with the specified name quota with the specified name. secret using specified subcommand service using specified subcommand. service account with the specified name

Options: --dry-run=false: If true, only print the object that would be sent, withou t sending it. --edit=false: Edit the API resource before creating -f, --filename=[]: Filename, directory, or URL to files to use to create the r esource --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --record=false: Record 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 alrea dy exists. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --save-config=false: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply o n this object in the future. --schema-cache-dir='~/.kube/schema': If non-empty, load/store cached API s chemas in this directory, default is '$HOME/.kube/schema' -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. --validate=true: If true, use a schema to validate the input before sendin g it --windows-line-endings=false: Only relevant if --edit=true. Use Windows li ne-endings (default Unix line-endings) Usage: kubectl create -f FILENAME [options] Use "kubectl --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands).

============ Expose a resource as a new Kubernetes service. Looks up a deployment, service, replica set, replication controller or pod by na me and uses the selector for that resource as the selector for a new service on the specified port. A deployment or replica set will be exposed as a service onl y if its selector is convertible to a selector that service supports, i.e. when the selector contains only the matchLabels component. Note that if no port is sp ecified via --port and the exposed resource has multiple ports, all will be re-u sed by the new service. Also if no labels are specified, the new service will re -use the labels from the resource it exposes. Possible resources include (case insensitive): pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replic aset (rs) Examples: # Create a service for a replicated nginx, which serves on port 80 and connect s to the containers on port 8000. kubectl expose rc nginx --port=80 --target-port=8000 # Create a service for a replication controller identified by type and name sp ecified in "nginx-controller.yaml", which serves on port 80 and connects to the containers on port 8000. kubectl expose -f nginx-controller.yaml --port=80 --target-port=8000 # Create a service for a pod valid-pod, which serves on port 444 with the name "frontend" kubectl expose pod valid-pod --port=444 --name=frontend # Create a second service based on the above service, exposing the container p ort 8443 as port 443 with the name "nginx-https" kubectl expose service nginx --port=443 --target-port=8443 --name=nginx-https # Create a service for a replicated streaming application on port 4100 balanci ng UDP traffic and named 'video-stream'. kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream # Create a service for a replicated nginx using replica set, which serves on p ort 80 and connects to the containers on port 8000. kubectl expose rs nginx --port=80 --target-port=8000 # Create a service for an nginx deployment, which serves on port 80 and connec ts to the containers on port 8000. kubectl expose deployment nginx --port=80 --target-port=8000 Options: --cluster-ip='': ClusterIP to be assigned to the service. Leave empty to a uto-allocate, or set to 'None' to create a headless service. --container-port='': Synonym for --target-port --create-external-load-balancer=false: If true, create an external load ba lancer for this service (trumped by --type). Implementation is cloud provider de pendent. Default is 'false'. --dry-run=false: If true, only print the object that would be sent, withou t sending it. --external-ip='': Additional external IP address (not managed by Kubernete s) to accept for the service. If this IP is routed to a node, the service can be accessed by this IP in addition to its generated service IP.

-f, --filename=[]: Filename, directory, or URL to files identifying the resour ce to expose a service --generator='service/v2': The name of the API generator to use. There are 2 generators: 'service/v1' and 'service/v2'. The only difference between them is that service port in v1 is named 'default', while it is left unnamed in v2. Def ault is 'service/v2'. -l, --labels='': Labels to apply to the service created by this call. --load-balancer-ip='': IP to assign to the Load Balancer. If empty, an eph emeral IP will be created and used (cloud-provider specific). --name='': The name for the newly created object. --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --overrides='': An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the obj ect supply a valid apiVersion field. --port='': The port that the service should serve on. Copied from the reso urce being exposed, if unspecified --protocol='': The network protocol for the service to be created. Default is 'TCP'. --record=false: Record 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 alrea dy exists. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --save-config=false: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply o n this object in the future. --selector='': A label selector to use for this service. Only equality-bas ed selector requirements are supported. If empty (the default) infer the selecto r from the replication controller or replica set. --session-affinity='': If non-empty, set the session affinity for the serv ice to this; legal values: 'None', 'ClientIP' -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --target-port='': Name or number for the port on the container that the se rvice should direct traffic to. Optional. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. --type='': Type for this service: ClusterIP, NodePort, or LoadBalancer. De fault is 'ClusterIP'. Usage: kubectl expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP] [-

-target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service ] [--type=type] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Create and run a particular image, possibly replicated. Creates a deployment or job to manage the created container(s). Aliases: run, run-container Examples: # Start a single instance of nginx. kubectl run nginx --image=nginx # Start a single instance of hazelcast and let the container expose port 5701 . kubectl run hazelcast --image=hazelcast --port=5701 # Start a single instance of hazelcast and set environment variables "DNS_DOMA IN=cluster" and "POD_NAMESPACE=default" in the container. kubectl run hazelcast --image=hazelcast --env="DNS_DOMAIN=cluster" --env="POD_ NAMESPACE=default" # Start a replicated instance of nginx. kubectl run nginx --image=nginx --replicas=5 # Dry run. Print the corresponding API objects without creating them. kubectl run nginx --image=nginx --dry-run # Start a single instance of nginx, but overload the spec of the deployment wi th a partial set of values parsed from JSON. kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { . .. } }' # Start a pod of busybox 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 container using the default command, but use custom argument s (arg1 .. argN) for that command. kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN> # Start the nginx container using a different command and custom arguments. kubectl run nginx --image=nginx --command -- <arg1> ... <argN> # Start the perl container to compute Ï to 2000 places and print it out. kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'pri nt bpi(2000)' # Start the cron job to compute Ï to 2000 places and print it out every 5 minutes . kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- pe rl -Mbignum=bpi -wle 'print bpi(2000)' Options: --attach=false: If true, wait for the Pod to start running, and then attac

h to the Pod as if 'kubectl attach ...' were called. Default false, unless '-i/ --stdin' is set, in which case the default is true. With '--restart=Never' the e xit code of the container process is returned. --command=false: If true and extra arguments are present, use them as the 'command' field in the container, rather than the 'args' field which is the defa ult. --dry-run=false: If true, only print the object that would be sent, withou t sending it. --env=[]: Environment variables to set in the container --expose=false: If true, a public, external service is created for the con tainer(s) which are run --generator='': The name of the API generator to use, see http://kubernete s.io/docs/user-guide/kubectl-conventions/#generators for a list. --hostport=-1: The host port mapping for the container port. To demonstrat e a single-machine container. --image='': The image for the container to run. --image-pull-policy='': The image pull policy for the container. If left e mpty, this value will not be specified by the client and defaulted by the server --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] -l, --labels='': Labels to apply to the pod(s). --leave-stdin-open=false: If the pod is started in interactive mode or wit h stdin, leave stdin open after the first attach completes. By default, stdin wi ll be closed after the first attach completes. --limits='': The resource requirement limits for this container. For exam ple, 'cpu=200m,memory=512Mi'. Note that server side components may assign limit s depending on the server configuration, such as limit ranges. --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --overrides='': An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the obj ect supply a valid apiVersion field. --port='': The port that this container exposes. If --expose is true, thi s is also the port used by the service that is created. --quiet=false: If true, suppress prompt messages. --record=false: Record 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 alrea dy exists. -r, --replicas=1: Number of replicas to create for this container. Default is 1. --requests='': The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign r equests depending on the server configuration, such as limit ranges. --restart='Always': The restart policy for this Pod. Legal values [Always , OnFailure, Never]. If set to 'Always' a deployment is created, if set to 'OnF ailure' a job is created, if set to 'Never', a regular pod is created. For the l atter two --replicas must be 1. Default 'Always', for ScheduledJobs `Never`. --rm=false: If true, delete resources created in this command for attached containers. --save-config=false: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply o

n this object in the future. --schedule='': A schedule in the Cron format the job should be run with. --service-generator='service/v2': The name of the generator to use for cre ating a service. Only used if --expose is true --service-overrides='': An inline JSON override for the generated service object. If this is non-empty, it is used to override the generated object. Requi res that the object supply a valid apiVersion field. Only used if --expose is t rue. -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. -i, --stdin=false: Keep stdin open on the container(s) in the pod, even if not hing is attached. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. -t, --tty=false: Allocated a TTY for each container in the pod. Usage: kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=r eplicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [ar gs...] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Configure application resources These commands help you make changes to existing application resources. Available Commands: image Update image of a pod template resources update resource requests/limits on objects with pod templates Usage: kubectl set SUBCOMMAND [options] Use "kubectl --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Display one or many resources. Valid resource types include: * * * * * * * *

clusters (valid only for federation apiservers) componentstatuses (aka 'cs') configmaps (aka 'cm') daemonsets (aka 'ds') deployments (aka 'deploy') endpoints (aka 'ep') events (aka 'ev') horizontalpodautoscalers (aka 'hpa')

* * * * * * * * * * * * * * * * * * * *

ingresses (aka 'ing') jobs limitranges (aka 'limits') namespaces (aka 'ns') networkpolicies nodes (aka 'no') persistentvolumeclaims (aka 'pvc') persistentvolumes (aka 'pv') pods (aka 'po') podsecuritypolicies (aka 'psp') podtemplates replicasets (aka 'rs') replicationcontrollers (aka 'rc') resourcequotas (aka 'quota') secrets serviceaccounts (aka 'sa') services (aka 'svc') statefulsets storageclasses thirdpartyresources

This command will hide resources that have completed. For instance, pods that ar e in the Succeeded or Failed phases. You can see the full results for any resour ce by providing the '--show-all' flag. By specifying the output as 'template' and providing a Go template as the value of the --template flag, you can filter the attributes of the fetched resource(s) . Examples: # List all pods in ps output format. kubectl get pods # List all pods in ps output format with more information (such as node name). kubectl get pods -o wide # List a single replication controller with specified NAME in ps output format . kubectl get replicationcontroller web # List a single pod in JSON output format. kubectl get -o json pod web-pod-13je7 # List a pod identified by type and name specified in "pod.yaml" in JSON outpu t format. kubectl get -f pod.yaml -o json # Return only the phase value of the specified pod. kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}} # List all replication controllers and services together in ps output format. kubectl get rc,services # List one or more resources by their type and names. kubectl get rc/web service/frontend pods/web-pod-13je7 Options: --all-namespaces=false: If present, list the requested object(s) across al l namespaces. Namespace in current context is ignored even if specified with --n amespace.

--export=false: If true, use 'export' for the resources. Exported resourc es are stripped of cluster-specific information. -f, --filename=[]: Filename, directory, or URL to files identifying the resour ce to get from a server. --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] -L, --label-columns=[]: Accepts a comma separated list of labels that are goin g to be presented as columns. Names are case-sensitive. You can also use multipl e flag options like -L label1 -L label2... --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --raw='': Raw URI to request from the server. Uses the transport specifie d by the kubeconfig file. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. -l, --selector='': Selector (label query) to filter on -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-kind=false: If present, list the resource type for the requested ob ject(s). --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. -w, --watch=false: After listing/getting the requested object, watch for chang es. --watch-only=false: Watch for changes to the requested object(s), without listing/getting first. Usage: kubectl get [(-o|--output=)json|yaml|wide|custom-columns=...|custom-columns-fi le=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...] (TYP E [NAME | -l label] | TYPE/NAME ...) [flags] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Documentation of resources. Valid resource types include: * * * *

clusters (valid only for federation apiservers) componentstatuses (aka 'cs') configmaps (aka 'cm') daemonsets (aka 'ds')

* * * * * * * * * * * * * * * * * * * * * * * *

deployments (aka 'deploy') endpoints (aka 'ep') events (aka 'ev') horizontalpodautoscalers (aka 'hpa') ingresses (aka 'ing') jobs limitranges (aka 'limits') namespaces (aka 'ns') networkpolicies nodes (aka 'no') persistentvolumeclaims (aka 'pvc') persistentvolumes (aka 'pv') pods (aka 'po') podsecuritypolicies (aka 'psp') podtemplates replicasets (aka 'rs') replicationcontrollers (aka 'rc') resourcequotas (aka 'quota') secrets serviceaccounts (aka 'sa') services (aka 'svc') statefulsets storageclasses thirdpartyresources

Examples: # Get the documentation of the resource and its fields kubectl explain pods # Get the documentation of a specific field of a resource kubectl explain pods.spec.containers Options: --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --recursive=false: Print the fields of fields (Currently only 1 level deep ) Usage: kubectl explain RESOURCE [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Edit a resource from the default editor. The edit command allows you to directly edit any API resource you can retrieve v ia 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' fo r Windows. You can edit multiple objects, although changes are applied one at a time. The command accepts filenames as well as command line arguments, although the files you point to must be previously saved versions of resources. The files to edit will be output in the default API version, or a version specif ied by --output-version. The default format is YAML - if you would like to edit in JSON pass -o json. The flag --windows-line-endings can be used to force Windo ws 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 occu rs, 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. Examples: # Edit the service named 'docker-registry': kubectl edit svc/docker-registry # Use an alternative editor KUBE_EDITOR="nano" kubectl edit svc/docker-registry # Edit the service 'docker-registry' in JSON using the v1 API format: kubectl edit svc/docker-registry --output-version=v1 -o json Options: -f, --filename=[]: Filename, directory, or URL to files to use to edit the res ource --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] -o, --output='yaml': Output format. One of: yaml|json. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --record=false: Record 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 alrea dy exists. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --save-config=false: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply o n this object in the future. --schema-cache-dir='~/.kube/schema': If non-empty, load/store cached API s chemas in this directory, default is '$HOME/.kube/schema' --validate=true: If true, use a schema to validate the input before sendin g it --windows-line-endings=false: Use Windows line-endings (default Unix lineendings) Usage: kubectl edit (RESOURCE/NAME | -f FILENAME) [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Delete resources by filenames, stdin, resources and names, or by resources and l abel selector. JSON and YAML formats are accepted. Only one type of the arguments may be specif ied: filenames, resources and names, or resources and label selector. Some resources, such as pods, support graceful deletion. These resources define a default period before they are forcibly terminated (the grace period) but you may override that value with the --grace-period flag, or pass --now to set a gra ce-period of 1. Because these resources often represent entities in the cluster, deletion may not be acknowledged immediately. If the node hosting a pod is down or cannot reach the API server, termination may take significantly longer than the grace period. To force delete a resource, you must pass a grace period of

0 and specify the --force flag. IMPORTANT: Force deleting pods does not wait for confirmation that the pod's pro cesses have been terminated, which can leave those processes running until the n ode detects the deletion and completes graceful deletion. If your processes use shared storage or talk to a remote API and depend on the name of the pod to iden tify themselves, force deleting those pods may result in multiple processes runn ing on different machines using the same identification which may lead to data c orruption or inconsistency. Only force delete pods when you are sure the pod is terminated, or if your application can tolerate multiple copies of the same pod running at once. Also, if you force delete pods the scheduler may place new pods on those nodes before the node has released those resources and causing those p ods to be evicted immediately. Note that the delete command does NOT do resource version checks, so if someone submits an update to a resource right when you submit a delete, their update wil l be lost along with the rest of the resource. Examples: # Delete a pod using the type and name specified in pod.json. kubectl delete -f ./pod.json # Delete a pod based on the type and name in the JSON passed into stdin. cat pod.json | kubectl delete -f # Delete pods and services with same names "baz" and "foo" kubectl delete pod,service baz foo # Delete pods and services with label name=myLabel. kubectl delete pods,services -l name=myLabel # Delete a pod with minimal delay kubectl delete pod foo --now # Force delete a pod on a dead node kubectl delete pod foo --grace-period=0 --force # Delete a pod with UID 1234-56-7890-234234-456456. kubectl delete pod 1234-56-7890-234234-456456 # Delete all pods kubectl delete pods --all Options: --all=false: [-all] to select all the specified resources. --cascade=true: If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true. -f, --filename=[]: Filename, directory, or URL to files containing the resourc e to delete. --force=false: Immediate deletion of some resources may result in inconsis tency or data loss and requires confirmation. --grace-period=-1: Period of time in seconds given to the resource to term inate gracefully. Ignored if negative. --ignore-not-found=false: Treat "resource not found" as a successful delet e. Defaults to "true" when --all is specified. --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --now=false: If true, resources are signaled for immediate shutdown (same as --grace-period=1). -o, --output='': Output mode. Use "-o name" for shorter output (resource/name)

. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. -l, --selector='': Selector (label query) to filter on. --timeout=0s: The length of time to wait before giving up on a delete, zer o means determine a timeout from the size of the object Usage: kubectl delete ([-f FILENAME] | TYPE [(NAME | -l label | --all)]) [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Manage a deployment using subcommands like "kubectl rollout undo deployment/abc" Examples: # Rollback to the previous deployment kubectl rollout undo deployment/abc Available Commands: history View rollout history pause Mark the provided resource as paused resume Resume a paused resource status Show the status of the rollout undo Undo a previous rollout Usage: kubectl rollout SUBCOMMAND [options] Use "kubectl --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Perform a rolling update of the given ReplicationController. Replaces the specified replication controller with a new replication controller by updating one pod at a time to use the new PodTemplate. The new-controller.jso n must specify the same namespace as the existing replication controller and ove rwrite at least one (common) label in its replicaSelector. ! http://kubernetes.io/images/docs/kubectl_rollingupdate.svg Aliases: rolling-update, rollingupdate Examples: # Update pods of frontend-v1 using new replication controller data in frontend -v2.json. kubectl rolling-update frontend-v1 -f frontend-v2.json # Update pods of frontend-v1 using JSON data passed into stdin. cat frontend-v2.json | kubectl rolling-update frontend-v1 -f # Update the pods of frontend-v1 to frontend-v2 by just changing the image, an d switching the # name of the replication controller. kubectl rolling-update frontend-v1 frontend-v2 --image=image:v2

# Update the pods of frontend by just changing the image, and keeping the old name. kubectl rolling-update frontend --image=image:v2 # Abort and reverse an existing rollout in progress (from frontend-v1 to front end-v2). kubectl rolling-update frontend-v1 frontend-v2 --rollback Options: --container='': Container name which will have its image upgraded. Only re levant when --image is specified, ignored otherwise. Required when using --image on a multi-container pod --deployment-label-key='deployment': The key to use to differentiate betwe en two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise --dry-run=false: If true, only print the object that would be sent, withou t sending it. -f, --filename=[]: Filename or URL to file to use to create the new replicatio n controller. --image='': Image to use for upgrading the replication controller. Must be distinct from the existing image (either new image or new image tag). Can not be used with --filename/-f --image-pull-policy='': Explicit policy for when to pull container images. Required when --image is same as existing image, ignored otherwise. --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --poll-interval=3s: Time delay between polling for replication controller status after the update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". --rollback=false: If true, this is a request to abort an existing rollout that is partially rolled out. It effectively reverses current and next and runs a rollout --schema-cache-dir='~/.kube/schema': If non-empty, load/store cached API s chemas in this directory, default is '$HOME/.kube/schema' -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. --timeout=5m0s: Max time to wait for a replication controller to update be fore giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". --update-period=1m0s: Time to wait between updating pods. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

--validate=true: If true, use a schema to validate the input before sendin g it Usage: kubectl rolling-update OLD_CONTROLLER_NAME ([NEW_CONTROLLER_NAME] --image=NEW_ CONTAINER_IMAGE | -f NEW_CONTROLLER_SPEC) [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job. Scale also allows users to specify one or more preconditions for the scale actio n. 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 w hen the scale is sent to the server. Aliases: scale, resize Examples: # Scale a replicaset 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/baz # Scale job named 'cron' to 3. kubectl scale --replicas=3 job/cron Options: --current-replicas=-1: Precondition for current size. Requires that the cu rrent size of the resource match this value in order to scale. -f, --filename=[]: Filename, directory, or URL to files identifying the resour ce to set a new size --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] -o, --output='': Output mode. Use "-o name" for shorter output (resource/name) . --record=false: Record 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 alrea dy exists. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --replicas=-1: The new desired number of replicas. Required. --resource-version='': Precondition for resource version. Requires that th e current resource version match this value in order to scale. --timeout=0s: The length of time to wait before giving up on a scale opera tion, zero means don't wait. Any other values should contain a corresponding tim

e unit (e.g. 1s, 2m, 3h). Usage: kubectl scale [--resource-version=version] [--current-replicas=count] --replic as=COUNT (-f FILENAME | TYPE NAME) [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Creates an autoscaler that automatically chooses and sets the number of pods tha t run in a kubernetes cluster. Looks up a Deployment, ReplicaSet, or ReplicationController by name and creates an autoscaler that uses the given resource as a reference. An autoscaler can aut omatically increase or decrease number of pods deployed within the system as nee ded. Examples: # Auto scale a deployment "foo", with the number of pods between 2 and 10, tar get CPU utilization specified so a default autoscaling policy will be used: kubectl autoscale deployment foo --min=2 --max=10 # Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%: kubectl autoscale rc foo --max=5 --cpu-percent=80 Options: --cpu-percent=-1: The target average CPU utilization (represented as a per cent of requested CPU) over all the pods. If it's not specified or negative, a d efault autoscaling policy will be used. --dry-run=false: If true, only print the object that would be sent, withou t sending it. -f, --filename=[]: Filename, directory, or URL to files identifying the resour ce to autoscale. --generator='horizontalpodautoscaler/v1': The name of the API generator to use. Currently there is only 1 generator. --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --max=-1: The upper limit for the number of pods that can be set by the au toscaler. Required. --min=-1: The lower limit for the number of pods that can be set by the au toscaler. If it's not specified or negative, the server will apply a default val ue. --name='': The name for the newly created object. If not specified, the na me of the input resource will be used. --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --record=false: Record 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 alrea dy exists.

-R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --save-config=false: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply o n this object in the future. -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. Usage: kubectl autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max= MAXPODS [--cpu-percent=CPU] [flags] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Modify certificate resources. Available Commands: approve Approve a certificate signing request deny Deny a certificate signing request Usage: kubectl certificate SUBCOMMAND [options] Use "kubectl --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Display addresses of the master and services with label kubernetes.io/cluster-se rvice=true To further debug and diagnose cluster problems, use 'kubectl clusterinfo dump'. Aliases: cluster-info, clusterinfo Available Commands: dump Dump lots of relevant info for debugging and diagnosis Options: --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] Usage: kubectl cluster-info [options] Use "kubectl --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands).

============ Display Resource (CPU/Memory/Storage) usage. The top command allows you to see the resource consumption for nodes or pods. Available Commands: node Display Resource (CPU/Memory/Storage) usage of nodes pod Display Resource (CPU/Memory/Storage) usage of pods Usage: kubectl top [options] Use "kubectl --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Mark node as unschedulable. Examples: # Mark node "foo" as unschedulable. kubectl cordon foo Usage: kubectl cordon NODE [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Mark node as schedulable. Examples: # Mark node "foo" as schedulable. $ kubectl uncordon foo Usage: kubectl uncordon NODE [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Drain node in preparation for maintenance. The given node will be marked unschedulable to prevent new pods from arriving. ' drain' evicts the pods if the APIServer supports eviciton (http://kubernetes.io/ docs/admin/disruptions/). Otherwise, it will use normal DELETE to delete the pod s. The 'drain' evicts or deletes all pods except mirror pods (which cannot be de leted through the API server). If there are DaemonSet-managed pods, drain will not proceed without --ignore-daemonsets, and regardless it will not delete any D aemonSet-managed pods, because those pods would be immediately replaced by the D aemonSet controller, which ignores unschedulable markings. If there are any pod s that are neither mirror pods nor managed by ReplicationController, ReplicaSet, DaemonSet, StatefulSet or Job, then drain will not delete any pods unless you u se --force. 'drain' waits for graceful termination. You should not operate on the machine un til the command completes.

When you are ready to put the node back into service, use kubectl uncordon, whic h will make the node schedulable again. ! http://kubernetes.io/images/docs/kubectl_drain.svg Examples: # Drain node "foo", even if there are pods not managed by a ReplicationControl ler, ReplicaSet, Job, DaemonSet or StatefulSet on it. $ kubectl drain foo --force # As above, but abort if there are pods not managed by a ReplicationController , ReplicaSet, Job, DaemonSet or StatefulSet, and use a grace period of 15 minute s. $ kubectl drain foo --grace-period=900 Options: --delete-local-data=false: Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained). --force=false: Continue even if there are pods not managed by a Replicatio nController, ReplicaSet, Job, DaemonSet or StatefulSet. --grace-period=-1: Period of time in seconds given to each pod to terminat e gracefully. If negative, the default value specified in the pod will be used. --ignore-daemonsets=false: Ignore DaemonSet-managed pods. --timeout=0s: The length of time to wait before giving up, zero means infi nite Usage: kubectl drain NODE [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Update the taints on one or more nodes. * A taint consists of a key, value, and effect. As an argument here, it is exp ressed as key=value:effect. * The key must begin with a letter or number, and may contain letters, numbers , hyphens, dots, and underscores, up to 253 characters. * The value must begin with a letter or number, and may contain letters, numbe rs, hyphens, dots, and underscores, up to 253 characters. * The effect must be NoSchedule or PreferNoSchedule. * Currently taint can only apply to node. Examples: # Update node 'foo' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule'. # If a taint with that key and effect already exists, its value is replaced as specified. kubectl taint nodes foo dedicated=special-user:NoSchedule # Remove from node 'foo' the taint with key 'dedicated' and effect 'NoSchedule ' if one exists. kubectl taint nodes foo dedicated:NoSchedule# Remove from node 'foo' all the taints with key 'dedicated' kubectl taint nodes foo dedicatedOptions:

--all=false: select all nodes in the cluster --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --overwrite=false: If true, allow taints to be overwritten, otherwise reje ct taint updates that overwrite existing taints. --schema-cache-dir='~/.kube/schema': If non-empty, load/store cached API s chemas in this directory, default is '$HOME/.kube/schema' -l, --selector='': Selector (label query) to filter on -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. --validate=true: If true, use a schema to validate the input before sendin g it Usage: kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFEC T_N [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Show details of a specific resource or group of resources. This command joins ma ny API calls together to form a detailed description of a given resource or grou p of resources. $ 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. Valid resource types include: * * * * * * * *

clusters (valid only for federation apiservers) componentstatuses (aka 'cs') configmaps (aka 'cm') daemonsets (aka 'ds') deployments (aka 'deploy') endpoints (aka 'ep') events (aka 'ev') horizontalpodautoscalers (aka 'hpa')

* * * * * * * * * * * * * * * * * * * *

ingresses (aka 'ing') jobs limitranges (aka 'limits') namespaces (aka 'ns') networkpolicies nodes (aka 'no') persistentvolumeclaims (aka 'pvc') persistentvolumes (aka 'pv') pods (aka 'po') podsecuritypolicies (aka 'psp') podtemplates replicasets (aka 'rs') replicationcontrollers (aka 'rc') resourcequotas (aka 'quota') secrets serviceaccounts (aka 'sa') services (aka 'svc') statefulsets storageclasses thirdpartyresources

Examples: # 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 po -l name=myLabel # Describe all pods managed by the 'frontend' replication controller (rc-creat ed pods # get the name of the rc as a prefix in the pod the name). kubectl describe pods frontend Options: --all-namespaces=false: If present, list the requested object(s) across al l namespaces. Namespace in current context is ignored even if specified with --n amespace. -f, --filename=[]: Filename, directory, or URL to files containing the resourc e to describe --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. -l, --selector='': Selector (label query) to filter on --show-events=true: If true, display events related to the described objec t. Usage: kubectl describe (-f FILENAME | TYPE [NAME_PREFIX | -l label] | TYPE/NAME) [op tions]

Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Print the logs for a container in a pod. If the pod has only one container, the container name is optional. Aliases: logs, log Examples: # Return snapshot logs from pod nginx with only one container kubectl logs nginx # 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 # 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 Options: -c, --container='': Print the logs of this container -f, --follow=false: Specify if the logs should be streamed. --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --interactive=false: If true, prompt the user for input when required. --limit-bytes=0: Maximum bytes of logs to return. Defaults to no limit. -p, --previous=false: If true, print the logs for the previous instance of the container in a pod if it exists. --since=0s: Only return logs newer than a relative duration like 5s, 2m, o r 3h. Defaults to all logs. Only one of since-time / since may be used. --since-time='': Only return logs after a specific date (RFC3339). Default s to all logs. Only one of since-time / since may be used. --tail=-1: Lines of recent log file to display. Defaults to -1, showing al l log lines. --timestamps=false: Include timestamps on each line in the log output Usage: kubectl logs [-f] [-p] POD [-c CONTAINER] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Attach to a process that is already running inside an existing container. Examples: # Get output from running pod 123456-7890, using the first container by defaul t kubectl attach 123456-7890 # Get output from ruby-container from pod 123456-7890 kubectl attach 123456-7890 -c ruby-container

# Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from po d 123456-7890 # and sends stdout/stderr from 'bash' back to the client kubectl attach 123456-7890 -c ruby-container -i -t Options: -c, --container='': Container name. If omitted, the first container in the pod will be chosen -i, --stdin=false: Pass stdin to the container -t, --tty=false: Stdin is a TTY Usage: kubectl attach POD -c CONTAINER [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Execute a command in a container. Examples: # Get output from running 'date' from pod 123456-7890, using the first contain er by default kubectl exec 123456-7890 date # Get output from running 'date' in ruby-container from pod 123456-7890 kubectl exec 123456-7890 -c ruby-container date # Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from po d 123456-7890 # and sends stdout/stderr from 'bash' back to the client kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il Options: -c, --container='': Container name. If omitted, the first container in the pod will be chosen -p, --pod='': Pod name -i, --stdin=false: Pass stdin to the container -t, --tty=false: Stdin is a TTY Usage: kubectl exec POD [-c CONTAINER] -- COMMAND [args...] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Forward one or more local ports to a pod. Examples: # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 an d 6000 in the pod kubectl port-forward mypod 5000 6000 # Listen on port 8888 locally, forwarding to 5000 in the pod kubectl port-forward mypod 8888:5000 # Listen on a random port locally, forwarding to 5000 in the pod kubectl port-forward mypod :5000

# Listen on a random port locally, forwarding to 5000 in the pod kubectl port-forward mypod 0:5000 Options: -p, --pod='': Pod name Usage: kubectl port-forward POD [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PO RT_N] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ To proxy all of the kubernetes api and nothing else, use: $ kubectl proxy --api-prefix=/ To proxy only part of the kubernetes api and also some static files: $ kubectl proxy --www=/my/files --www-prefix=/static/ --api-prefix=/api/ The above lets you 'curl localhost:8001/api/v1/pods'. To proxy the entire kubernetes api at a different root, use: $ kubectl proxy --api-prefix=/custom/ The above lets you 'curl localhost:8001/custom/api/v1/pods' Examples: # Run a proxy to kubernetes apiserver on port 8011, serving static content fro m ./local/www/ kubectl proxy --port=8011 --www=./local/www/ # Run a proxy to kubernetes apiserver on an arbitrary local port. # The chosen port for the server will be output to stdout. kubectl proxy --port=0 # Run a proxy to kubernetes apiserver, changing the api prefix to k8s-api # This makes e.g. the pods api available at localhost:8011/k8s-api/v1/pods/ kubectl proxy --api-prefix=/k8s-api Options: --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-filter=false: If true, disable request filtering in the proxy. T his is dangerous, and can leave you vulnerable to XSRF attacks, when used with a n accessible port. -p, --port=8001: The port on which to run the proxy. Set to 0 to pick a random port. --reject-methods='POST,PUT,PATCH': Regular expression for HTTP methods tha t the proxy should reject. --reject-paths='^/api/.*/pods/.*/exec,^/api/.*/pods/.*/attach': Regular ex pression for paths that the proxy should reject.

-u, --unix-socket='': Unix socket on which to run the proxy. -w, --www='': Also serve static files from the given directory under the speci fied prefix. -P, --www-prefix='/static/': Prefix to serve static files under, if static fil e directory is specified. Usage: kubectl proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-pr efix=prefix] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Copy files and directories to and from containers. Examples: # !!!Important Note!!! # Requires that the 'tar' binary is present in your container # image. If 'tar' is not present, 'kubectl cp' will fail. # Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the def ault 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> # Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-name space> 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 Options: -c, --container='': Container name. If omitted, the first container in the pod will be chosen Usage: kubectl cp [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Apply a configuration to a resource by filename or stdin. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource init ially with either 'apply' or 'create --save-config'. JSON and YAML formats are accepted. Alpha Disclaimer: the --prune functionality is not yet complete. Do not use unle ss you are aware of what the current state is. See https://issues.k8s.io/34274. Examples: # Apply the configuration in pod.json to a pod. kubectl apply -f ./pod.json # Apply the JSON passed into stdin to a pod.

cat pod.json | kubectl apply -f # Note: --prune is still in Alpha # Apply the configuration in manifest.yaml that matches label app=nginx and de lete all the other resources that are not in the file and match label app=nginx. kubectl apply --prune -f manifest.yaml -l app=nginx # Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file. kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigM ap Options: --all=false: [-all] to select all the specified resources. --cascade=true: Only relevant during a prune or a force apply. If true, ca scade the deletion of the resources managed by pruned or deleted resources (e.g. Pods created by a ReplicationController). --dry-run=false: If true, only print the object that would be sent, withou t sending it. -f, --filename=[]: Filename, directory, or URL to files that contains the conf iguration to apply --force=false: Delete and re-create the specified resource, when PATCH enc ounters conflict and has retried for 5 times. --grace-period=-1: Only relevant during a prune or a force apply. Period o f time in seconds given to pruned or deleted resources to terminate gracefully. Ignored if negative. --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --overwrite=true: Automatically resolve conflicts between the modified and live configuration by using values from the modified configuration --prune=false: Automatically delete resource objects that do not appear in the configs and are created by either apply or create --save-config. Should be used with either -l or --all. --prune-whitelist=[]: Overwrite the default whitelist with for --prune --record=false: Record 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 alrea dy exists. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --schema-cache-dir='~/.kube/schema': If non-empty, load/store cached API s chemas in this directory, default is '$HOME/.kube/schema' -l, --selector='': Selector (label query) to filter on -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification

. The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. --timeout=0s: Only relevant during a force apply. The length of time to wa it before giving up on a delete of the old resource, zero means determine a time out from the size of the object. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h). --validate=true: If true, use a schema to validate the input before sendin g it Usage: kubectl apply -f FILENAME [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Update field(s) of a resource using strategic merge patch JSON and YAML formats are accepted. Please refer to the models in https://htmlpreview.github.io/?https://github.com/ kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find i f a field is mutable. Examples: # Partially update a node using strategic merge patch kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}' # Partially update a node identified by the type and name specified in "node.j son" using strategic merge patch kubectl patch -f node.json -p '{"spec":{"unschedulable":true}}' # 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-ser ve-hostname","image":"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": "/spe c/containers/0/image", "value":"new image"}]' Options: -f, --filename=[]: Filename, directory, or URL to files identifying the resour ce to update --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --local=false: If true, patch will operate on the content of the file, not the server-side resource. --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h].

--output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). -p, --patch='': The patch to be applied to the resource JSON file. --record=false: Record 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 alrea dy exists. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. --type='strategic': The type of patch being provided; one of [json merge s trategic] Usage: kubectl patch (-f FILENAME | TYPE NAME) -p PATCH [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Replace a resource by filename or stdin. JSON and YAML formats are accepted. If replacing an existing resource, the compl ete resource spec must be provided. This can be obtained by $ kubectl get TYPE NAME -o yaml Please refer to the models in https://htmlpreview.github.io/?https://github.com/ kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find i f a field is mutable. Aliases: replace, update Examples: # 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/' | kubect l replace -f # Force replace, delete and then re-create the resource kubectl replace --force -f ./pod.json Options:

--cascade=false: Only relevant during a force replace. If true, cascade th e deletion of the resources managed by this resource (e.g. Pods created by a Rep licationController). -f, --filename=[]: Filename, directory, or URL to files to use to replace the resource. --force=false: Delete and re-create the specified resource --grace-period=-1: Only relevant during a force replace. Period of time in seconds given to the old resource to terminate gracefully. Ignored if negative. --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] -o, --output='': Output mode. Use "-o name" for shorter output (resource/name) . --record=false: Record 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 alrea dy exists. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --save-config=false: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply o n this object in the future. --schema-cache-dir='~/.kube/schema': If non-empty, load/store cached API s chemas in this directory, default is '$HOME/.kube/schema' --timeout=0s: Only relevant during a force replace. The length of time to wait before giving up on a delete of the old resource, zero means determine a ti meout from the size of the object. Any other values should contain a correspondi ng time unit (e.g. 1s, 2m, 3h). --validate=true: If true, use a schema to validate the input before sendin g it Usage: kubectl replace -f FILENAME [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Convert config files between different API versions. Both YAML and JSON formats are accepted. The command takes filename, directory, or URL as input, and convert it into form at of version specified by --output-version flag. If target version is not speci fied or not supported, convert to latest version. The default output will be printed to stdout in YAML format. One can use -o opti on to change to output destination. Examples: # Convert 'pod.yaml' to latest version and print to stdout. kubectl convert -f pod.yaml # Convert the live state of the resource specified by 'pod.yaml' to the latest version # and print to stdout in json format. kubectl convert -f pod.yaml --local -o json # Convert all files under current directory to latest version and create them all. kubectl convert -f . | kubectl create -f -

Options: -f, --filename=[]: Filename, directory, or URL to files to need to get convert ed. --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --local=true: If true, convert will NOT try to contact api-server but run locally. --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --schema-cache-dir='~/.kube/schema': If non-empty, load/store cached API s chemas in this directory, default is '$HOME/.kube/schema' -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. --validate=true: If true, use a schema to validate the input before sendin g it Usage: kubectl convert -f FILENAME [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Update the labels on a resource. * A label must begin with a letter or number, and may contain letters, numbers , hyphens, dots, and underscores, up to 63 characters. * If --overwrite is true, then existing labels can be overwritten, otherwise a ttempting to overwrite a label will result in an error. * If --resource-version is specified, then updates will use this resource vers ion, otherwise the existing resource-version will be used. Examples: # 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', overwrit ing any existing value. kubectl label --overwrite pods foo status=unhealthy

# 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 barOptions: --all=false: select all resources in the namespace of the specified resour ce types --dry-run=false: If true, only print the object that would be sent, withou t sending it. -f, --filename=[]: Filename, directory, or URL to files identifying the resour ce to update the labels --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --local=false: If true, label will NOT contact api-server but run locally. --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --overwrite=false: If true, allow labels to be overwritten, otherwise reje ct label updates that overwrite existing labels. --record=false: Record 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 alrea dy exists. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --resource-version='': If non-empty, the labels update will only succeed i f this is the current resource-version for the object. Only valid when specifyin g a single resource. -l, --selector='': Selector (label query) to filter on -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview]. Usage:

kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VA L_N [--resource-version=version] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Update the annotations on one or more resources. * An annotation is a key/value pair that can hold larger (compared to a label) , and possibly not human-readable, data. * It is intended to store non-identifying auxiliary data, especially data mani pulated by tools and system extensions. * If --overwrite is true, then existing annotations can be overwritten, otherw ise attempting to overwrite an annotation will result in an error. * If --resource-version is specified, then updates will use this resource vers ion, otherwise the existing resource-version will be used. Valid resource types include: * * * * * * * * * * * * * * * * * * * * * * * * * * * *

clusters (valid only for federation apiservers) componentstatuses (aka 'cs') configmaps (aka 'cm') daemonsets (aka 'ds') deployments (aka 'deploy') endpoints (aka 'ep') events (aka 'ev') horizontalpodautoscalers (aka 'hpa') ingresses (aka 'ing') jobs limitranges (aka 'limits') namespaces (aka 'ns') networkpolicies nodes (aka 'no') persistentvolumeclaims (aka 'pvc') persistentvolumes (aka 'pv') pods (aka 'po') podsecuritypolicies (aka 'psp') podtemplates replicasets (aka 'rs') replicationcontrollers (aka 'rc') resourcequotas (aka 'quota') secrets serviceaccounts (aka 'sa') services (aka 'svc') statefulsets storageclasses thirdpartyresources

Examples: # Update pod 'foo' with the annotation 'description' and the value 'my fronten d'. # If the same annotation is set multiple times, only the last value will be ap plied kubectl annotate pods foo description='my frontend' # Update a pod identified by type and name in "pod.json" kubectl annotate -f pod.json description='my frontend' # Update pod 'foo' with the annotation 'description' and the value 'my fronten

d running nginx', overwriting any existing value. kubectl annotate --overwrite pods foo description='my frontend running nginx' # Update all pods in the namespace kubectl annotate pods --all description='my frontend running nginx' # Update pod 'foo' only if the resource is unchanged from version 1. kubectl annotate pods foo description='my frontend running nginx' --resource-v ersion=1 # Update pod 'foo' by removing an annotation named 'description' if it exists. # Does not require the --overwrite flag. kubectl annotate pods foo descriptionOptions: --all=false: select all resources in the namespace of the specified resour ce types --dry-run=false: If true, only print the object that would be sent, withou t sending it. -f, --filename=[]: Filename, directory, or URL to files identifying the resour ce to update the annotation --include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] --local=false: If true, annotation will NOT contact api-server but run loc ally. --no-headers=false: When using the default or custom-column output format, don't print headers. -o, --output='': Output format. One of: json|yaml|wide|name|custom-columns=... |custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonp ath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-ov erview/#custom-columns], golang template [http://golang.org/pkg/text/template/#p kg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpat h]. --output-version='': Output the formatted object with the given group vers ion (for ex: 'extensions/v1beta1'). --overwrite=false: If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations. --record=false: Record 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 alrea dy exists. -R, --recursive=false: Process the directory used in -f, --filename recursivel y. Useful when you want to manage related manifests organized within the same di rectory. --resource-version='': If non-empty, the annotation update will only succe ed if this is the current resource-version for the object. Only valid when speci fying a single resource. -l, --selector='': Selector (label query) to filter on -a, --show-all=false: When printing, show all resources (default hide terminat ed pods.) --show-labels=false: When printing, show all labels as the last column (de fault hide labels column) --sort-by='': If non-empty, sort list types using this field specification . The field specification is expressed as a JSONPath expression (e.g. '{.metada ta.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template='': Template string or path to template file to use when -o=gotemplate, -o=go-template-file. The template format is golang templates [http://g olang.org/pkg/text/template/#pkg-overview].

Usage: kubectl annotate [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N =VAL_N [--resource-version=version] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Output shell completion code for the given shell (bash or zsh). This command prints shell code which must be evaluation to provide interactive c ompletion of kubectl commands. $ source <(kubectl completion bash) will load the kubectl completion code for bash. Note that this depends on the ba sh-completion framework. It must be sourced before sourcing the kubectl completi on, e.g. on the Mac: $ brew install bash-completion $ source $(brew --prefix)/etc/bash_completion $ source <(kubectl completion bash) If you use zsh [1], the following will load kubectl zsh completion: $ source <(kubectl completion zsh) [1] zsh completions are only supported in versions of zsh >= 5.2 Usage: kubectl completion SHELL [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Print the supported API versions on the server, in the form of "group/version" Aliases: api-versions, apiversions Usage: kubectl api-versions [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Modify kubeconfig files using subcommands like "kubectl config set current-conte xt my-context" The loading order follows these rules: 1. If the --kubeconfig flag is set, then only that file is loaded. The flag m ay only be set once and no merging takes place. 2. If $KUBECONFIG environment variable is set, then it is used a list of paths (normal path delimitting rules for your system). These paths are merged. When a value is modified, it is modified in the file that defines the stanza. When a value is created, it is created in the first file that exists. If no files in the chain exist, then it creates the last file in the list.

3. Otherwise, ${HOME}/.kube/config is used and no merging takes place. Available Commands: current-context Displays the current-context delete-cluster Delete the specified cluster from the kubeconfig delete-context Delete the specified context from the kubeconfig get-clusters Display clusters defined in the kubeconfig get-contexts Describe one or many contexts set Sets an individual value in a kubeconfig file set-cluster Sets a cluster entry in kubeconfig set-context Sets a context entry in kubeconfig set-credentials Sets a user entry in kubeconfig unset Unsets an individual value in a kubeconfig file use-context Sets the current-context in a kubeconfig file view Display merged kubeconfig settings or a specified kubeconfig f ile Usage: kubectl config SUBCOMMAND [options] Use "kubectl --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Help provides help for any command in the application. Simply type kubectl help [path to command] for full details. Usage: kubectl help [command] [options] Use "kubectl options" for a list of global command-line options (applies to all commands). ============ Print the client and server version information Options: -c, --client=false: Client version only (no server required). --short=false: Print just the version number. Usage: kubectl version [options] Use "kubectl options" for a list of global command-line options (applies to all commands).

Related Documents

Kubernetes Commands
January 2021 1
Commands
January 2021 1
Awesome Kubernetes
January 2021 0
Ccna4 Commands
March 2021 0
Moshell Commands V14
February 2021 1

More Documents from "Daniel-Adrian Becheanu"

Kubernetes Commands
January 2021 1
Succession
January 2021 1
Pil
January 2021 3
Insanity And Criminal
January 2021 4
International Law
January 2021 1