CINXE.COM

Kubectl Reference Docs

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Kubectl Reference Docs</title> <link rel="icon" href="/images/favicon.png"> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.min.css" type="text/css"> <link rel="stylesheet" href="node_modules/highlight.js/styles/default.css" type="text/css"> <link rel="stylesheet" href="stylesheet.css" type="text/css"> </head> <body> <div id="sidebar-wrapper" class="side-nav side-bar-nav"><ul><li class="nav-level-1 strong-nav"><a href="#-strong-getting-started-strong-" class="nav-item"><strong>GETTING STARTED</strong></a></li></ul><ul><li class="nav-level-1"><a href="#create" class="nav-item">create</a></li><ul id="create-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-clusterrole-em-" class="nav-item"><em>clusterrole</em></a></li><li class="nav-level-2"><a href="#-em-clusterrolebinding-em-" class="nav-item"><em>clusterrolebinding</em></a></li><li class="nav-level-2"><a href="#-em-configmap-em-" class="nav-item"><em>configmap</em></a></li><li class="nav-level-2"><a href="#-em-cronjob-em-" class="nav-item"><em>cronjob</em></a></li><li class="nav-level-2"><a href="#-em-deployment-em-" class="nav-item"><em>deployment</em></a></li><li class="nav-level-2"><a href="#-em-ingress-em-" class="nav-item"><em>ingress</em></a></li><li class="nav-level-2"><a href="#-em-job-em-" class="nav-item"><em>job</em></a></li><li class="nav-level-2"><a href="#-em-namespace-em-" class="nav-item"><em>namespace</em></a></li><li class="nav-level-2"><a href="#-em-poddisruptionbudget-em-" class="nav-item"><em>poddisruptionbudget</em></a></li><li class="nav-level-2"><a href="#-em-priorityclass-em-" class="nav-item"><em>priorityclass</em></a></li><li class="nav-level-2"><a href="#-em-quota-em-" class="nav-item"><em>quota</em></a></li><li class="nav-level-2"><a href="#-em-role-em-" class="nav-item"><em>role</em></a></li><li class="nav-level-2"><a href="#-em-rolebinding-em-" class="nav-item"><em>rolebinding</em></a></li><li class="nav-level-2"><a href="#-em-secret-em-" class="nav-item"><em>secret</em></a></li><li class="nav-level-2"><a href="#-em-secret-docker-registry-em-" class="nav-item"><em>secret docker-registry</em></a></li><li class="nav-level-2"><a href="#-em-secret-generic-em-" class="nav-item"><em>secret generic</em></a></li><li class="nav-level-2"><a href="#-em-secret-tls-em-" class="nav-item"><em>secret tls</em></a></li><li class="nav-level-2"><a href="#-em-service-em-" class="nav-item"><em>service</em></a></li><li class="nav-level-2"><a href="#-em-service-clusterip-em-" class="nav-item"><em>service clusterip</em></a></li><li class="nav-level-2"><a href="#-em-service-externalname-em-" class="nav-item"><em>service externalname</em></a></li><li class="nav-level-2"><a href="#-em-service-loadbalancer-em-" class="nav-item"><em>service loadbalancer</em></a></li><li class="nav-level-2"><a href="#-em-service-nodeport-em-" class="nav-item"><em>service nodeport</em></a></li><li class="nav-level-2"><a href="#-em-serviceaccount-em-" class="nav-item"><em>serviceaccount</em></a></li></ul></ul><ul><li class="nav-level-1"><a href="#get" class="nav-item">get</a></li></ul><ul><li class="nav-level-1"><a href="#run" class="nav-item">run</a></li></ul><ul><li class="nav-level-1"><a href="#expose" class="nav-item">expose</a></li></ul><ul><li class="nav-level-1"><a href="#delete" class="nav-item">delete</a></li></ul><ul><li class="nav-level-1 strong-nav"><a href="#-strong-app-management-strong-" class="nav-item"><strong>APP MANAGEMENT</strong></a></li></ul><ul><li class="nav-level-1"><a href="#apply" class="nav-item">apply</a></li><ul id="apply-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-edit-last-applied-em-" class="nav-item"><em>edit-last-applied</em></a></li><li class="nav-level-2"><a href="#-em-set-last-applied-em-" class="nav-item"><em>set-last-applied</em></a></li><li class="nav-level-2"><a href="#-em-view-last-applied-em-" class="nav-item"><em>view-last-applied</em></a></li></ul></ul><ul><li class="nav-level-1"><a href="#annotate" class="nav-item">annotate</a></li></ul><ul><li class="nav-level-1"><a href="#autoscale" class="nav-item">autoscale</a></li></ul><ul><li class="nav-level-1"><a href="#debug" class="nav-item">debug</a></li></ul><ul><li class="nav-level-1"><a href="#diff" class="nav-item">diff</a></li></ul><ul><li class="nav-level-1"><a href="#edit" class="nav-item">edit</a></li></ul><ul><li class="nav-level-1"><a href="#kustomize" class="nav-item">kustomize</a></li></ul><ul><li class="nav-level-1"><a href="#label" class="nav-item">label</a></li></ul><ul><li class="nav-level-1"><a href="#patch" class="nav-item">patch</a></li></ul><ul><li class="nav-level-1"><a href="#replace" class="nav-item">replace</a></li></ul><ul><li class="nav-level-1"><a href="#rollout" class="nav-item">rollout</a></li><ul id="rollout-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-history-em-" class="nav-item"><em>history</em></a></li><li class="nav-level-2"><a href="#-em-pause-em-" class="nav-item"><em>pause</em></a></li><li class="nav-level-2"><a href="#-em-restart-em-" class="nav-item"><em>restart</em></a></li><li class="nav-level-2"><a href="#-em-resume-em-" class="nav-item"><em>resume</em></a></li><li class="nav-level-2"><a href="#-em-status-em-" class="nav-item"><em>status</em></a></li><li class="nav-level-2"><a href="#-em-undo-em-" class="nav-item"><em>undo</em></a></li></ul></ul><ul><li class="nav-level-1"><a href="#scale" class="nav-item">scale</a></li></ul><ul><li class="nav-level-1"><a href="#set" class="nav-item">set</a></li><ul id="set-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-env-em-" class="nav-item"><em>env</em></a></li><li class="nav-level-2"><a href="#-em-image-em-" class="nav-item"><em>image</em></a></li><li class="nav-level-2"><a href="#-em-resources-em-" class="nav-item"><em>resources</em></a></li><li class="nav-level-2"><a href="#-em-selector-em-" class="nav-item"><em>selector</em></a></li><li class="nav-level-2"><a href="#-em-serviceaccount-em--1" class="nav-item"><em>serviceaccount</em></a></li><li class="nav-level-2"><a href="#-em-subject-em-" class="nav-item"><em>subject</em></a></li></ul></ul><ul><li class="nav-level-1"><a href="#wait" class="nav-item">wait</a></li></ul><ul><li class="nav-level-1 strong-nav"><a href="#-strong-working-with-apps-strong-" class="nav-item"><strong>WORKING WITH APPS</strong></a></li></ul><ul><li class="nav-level-1"><a href="#attach" class="nav-item">attach</a></li></ul><ul><li class="nav-level-1"><a href="#auth" class="nav-item">auth</a></li><ul id="auth-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-can-i-em-" class="nav-item"><em>can-i</em></a></li><li class="nav-level-2"><a href="#-em-reconcile-em-" class="nav-item"><em>reconcile</em></a></li></ul></ul><ul><li class="nav-level-1"><a href="#cp" class="nav-item">cp</a></li></ul><ul><li class="nav-level-1"><a href="#describe" class="nav-item">describe</a></li></ul><ul><li class="nav-level-1"><a href="#exec" class="nav-item">exec</a></li></ul><ul><li class="nav-level-1"><a href="#logs" class="nav-item">logs</a></li></ul><ul><li class="nav-level-1"><a href="#port-forward" class="nav-item">port-forward</a></li></ul><ul><li class="nav-level-1"><a href="#proxy" class="nav-item">proxy</a></li></ul><ul><li class="nav-level-1"><a href="#top" class="nav-item">top</a></li><ul id="top-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-node-em-" class="nav-item"><em>node</em></a></li><li class="nav-level-2"><a href="#-em-pod-em-" class="nav-item"><em>pod</em></a></li></ul></ul><ul><li class="nav-level-1 strong-nav"><a href="#-strong-cluster-management-strong-" class="nav-item"><strong>CLUSTER MANAGEMENT</strong></a></li></ul><ul><li class="nav-level-1"><a href="#api-versions" class="nav-item">api-versions</a></li></ul><ul><li class="nav-level-1"><a href="#certificate" class="nav-item">certificate</a></li><ul id="certificate-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-approve-em-" class="nav-item"><em>approve</em></a></li><li class="nav-level-2"><a href="#-em-deny-em-" class="nav-item"><em>deny</em></a></li></ul></ul><ul><li class="nav-level-1"><a href="#cluster-info" class="nav-item">cluster-info</a></li><ul id="cluster-info-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-dump-em-" class="nav-item"><em>dump</em></a></li></ul></ul><ul><li class="nav-level-1"><a href="#cordon" class="nav-item">cordon</a></li></ul><ul><li class="nav-level-1"><a href="#drain" class="nav-item">drain</a></li></ul><ul><li class="nav-level-1"><a href="#taint" class="nav-item">taint</a></li></ul><ul><li class="nav-level-1"><a href="#uncordon" class="nav-item">uncordon</a></li></ul><ul><li class="nav-level-1 strong-nav"><a href="#-strong-kubectl-settings-and-usage-strong-" class="nav-item"><strong>KUBECTL SETTINGS AND USAGE</strong></a></li></ul><ul><li class="nav-level-1"><a href="#alpha" class="nav-item">alpha</a></li></ul><ul><li class="nav-level-1"><a href="#api-resources" class="nav-item">api-resources</a></li></ul><ul><li class="nav-level-1"><a href="#completion" class="nav-item">completion</a></li></ul><ul><li class="nav-level-1"><a href="#config" class="nav-item">config</a></li><ul id="config-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-current-context-em-" class="nav-item"><em>current-context</em></a></li><li class="nav-level-2"><a href="#-em-delete-cluster-em-" class="nav-item"><em>delete-cluster</em></a></li><li class="nav-level-2"><a href="#-em-delete-context-em-" class="nav-item"><em>delete-context</em></a></li><li class="nav-level-2"><a href="#-em-delete-user-em-" class="nav-item"><em>delete-user</em></a></li><li class="nav-level-2"><a href="#-em-get-clusters-em-" class="nav-item"><em>get-clusters</em></a></li><li class="nav-level-2"><a href="#-em-get-contexts-em-" class="nav-item"><em>get-contexts</em></a></li><li class="nav-level-2"><a href="#-em-get-users-em-" class="nav-item"><em>get-users</em></a></li><li class="nav-level-2"><a href="#-em-rename-context-em-" class="nav-item"><em>rename-context</em></a></li><li class="nav-level-2"><a href="#-em-set-em-" class="nav-item"><em>set</em></a></li><li class="nav-level-2"><a href="#-em-set-cluster-em-" class="nav-item"><em>set-cluster</em></a></li><li class="nav-level-2"><a href="#-em-set-context-em-" class="nav-item"><em>set-context</em></a></li><li class="nav-level-2"><a href="#-em-set-credentials-em-" class="nav-item"><em>set-credentials</em></a></li><li class="nav-level-2"><a href="#-em-unset-em-" class="nav-item"><em>unset</em></a></li><li class="nav-level-2"><a href="#-em-use-context-em-" class="nav-item"><em>use-context</em></a></li><li class="nav-level-2"><a href="#-em-view-em-" class="nav-item"><em>view</em></a></li></ul></ul><ul><li class="nav-level-1"><a href="#explain" class="nav-item">explain</a></li></ul><ul><li class="nav-level-1"><a href="#options" class="nav-item">options</a></li></ul><ul><li class="nav-level-1"><a href="#plugin" class="nav-item">plugin</a></li><ul id="plugin-nav" style="display: none;"><li class="nav-level-2"><a href="#-em-list-em-" class="nav-item"><em>list</em></a></li></ul></ul><ul><li class="nav-level-1"><a href="#version" class="nav-item">version</a></li></ul><br/><div class="copyright"><a href="https://github.com/kubernetes/kubernetes">Copyright 2020 The Kubernetes Authors.</a></div></div> <div id="wrapper"> <div id="code-tabs-wrapper" class="code-tabs"><ul class="code-tab-list"><li class="code-tab" id="example">example</li></ul></div> <div id="page-content-wrapper" class="body-content container-fluid"><h1 id="-strong-getting-started-strong-"><strong>GETTING STARTED</strong></h1> <p>This section contains the most basic commands for getting a workload running on your cluster.</p> <ul> <li><code>run</code> will start running 1 or more instances of a container image on your cluster.</li> <li><code>expose</code> will load balance traffic across the running instances, and can create a HA proxy for accessing the containers from outside the cluster.</li> </ul> <p>Once your workloads are running, you can use the commands in the <a href="#-strong-working-with-apps-strong-">WORKING WITH APPS</a> section to inspect them.</p> <hr> <h1 id="create">create</h1> <blockquote class="code-block example"> <p> Create a pod using the data in pod.json</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">create</span> -f ./pod.json </code></pre> <blockquote class="code-block example"> <p> Create a pod based on the JSON passed into stdin</p> </blockquote> <pre class="code-block example"><code class="lang-shell">cat pod.json | kubectl <span class="hljs-keyword">create</span> -f - </code></pre> <blockquote class="code-block example"> <p> Edit the data in docker-registry.yaml in JSON then create the resource using the edited data</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">create</span> -f docker-registry.yaml --<span class="hljs-keyword">edit</span> -o json </code></pre> <p>Create a resource from a file or from stdin.</p> <p> JSON and YAML formats are accepted.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create -f FILENAME</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>edit</td> <td></td> <td>false</td> <td>Edit the API resource before creating </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files to use to create the resource </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>raw</td> <td></td> <td></td> <td>Raw URI to POST to the server. Uses the transport specified by the kubeconfig file. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> <tr> <td>windows-line-endings</td> <td></td> <td>false</td> <td>Only relevant if --edit=true. Defaults to the line ending native to your platform. </td> </tr> </tbody> </table> <hr> <h2 id="-em-clusterrole-em-"><em>clusterrole</em></h2> <blockquote class="code-block example"> <p> Create a cluster role named &quot;pod-reader&quot; that allows user to perform &quot;get&quot;, &quot;watch&quot; and &quot;list&quot; on pods</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create clusterrole pod-reader <span class="hljs-attribute">--verb</span>=get,list,watch <span class="hljs-attribute">--resource</span>=pods </code></pre> <blockquote class="code-block example"> <p> Create a cluster role named &quot;pod-reader&quot; with ResourceName specified</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create clusterrole pod-reader <span class="hljs-attribute">--verb</span>=get <span class="hljs-attribute">--resource</span>=pods <span class="hljs-attribute">--resource-name</span>=readablepod <span class="hljs-attribute">--resource-name</span>=anotherpod </code></pre> <blockquote class="code-block example"> <p> Create a cluster role named &quot;foo&quot; with API Group specified</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create clusterrole foo <span class="hljs-attribute">--verb</span>=get,list,watch <span class="hljs-attribute">--resource</span>=rs.extensions </code></pre> <blockquote class="code-block example"> <p> Create a cluster role named &quot;foo&quot; with SubResource specified</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create clusterrole foo <span class="hljs-attribute">--verb</span>=get,list,watch <span class="hljs-attribute">--resource</span>=pods,pods/status </code></pre> <blockquote class="code-block example"> <p> Create a cluster role name &quot;foo&quot; with NonResourceURL specified</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create clusterrole <span class="hljs-string">"foo"</span> <span class="hljs-attribute">--verb</span>=get <span class="hljs-attribute">--non-resource-url</span>=/logs/* </code></pre> <blockquote class="code-block example"> <p> Create a cluster role name &quot;monitoring&quot; with AggregationRule specified</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">create</span> clusterrole <span class="hljs-keyword">monitoring</span> <span class="hljs-comment">--aggregation-rule="rbac.example.com/aggregate-to-monitoring=true"</span> </code></pre> <p>Create a cluster role.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>aggregation-rule</td> <td></td> <td></td> <td>An aggregation label selector for combining ClusterRoles. </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>non-resource-url</td> <td></td> <td>[]</td> <td>A partial url that user should have access to. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>resource</td> <td></td> <td>[]</td> <td>Resource that the rule applies to </td> </tr> <tr> <td>resource-name</td> <td></td> <td>[]</td> <td>Resource in the white list that the rule applies to, repeat this flag for multiple items </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> <tr> <td>verb</td> <td></td> <td>[]</td> <td>Verb that applies to the resources contained in the rule </td> </tr> </tbody> </table> <hr> <h2 id="-em-clusterrolebinding-em-"><em>clusterrolebinding</em></h2> <blockquote class="code-block example"> <p> Create a cluster role binding for user1, user2, and group1 using the cluster-admin cluster role</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create clusterrolebinding cluster-admin <span class="hljs-attribute">--clusterrole</span>=cluster-admin <span class="hljs-attribute">--user</span>=user1 <span class="hljs-attribute">--user</span>=user2 <span class="hljs-attribute">--group</span>=group1 </code></pre> <p>Create a cluster role binding for a particular cluster role.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create clusterrolebinding NAME --clusterrole=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>clusterrole</td> <td></td> <td></td> <td>ClusterRole this ClusterRoleBinding should reference </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>group</td> <td></td> <td>[]</td> <td>Groups to bind to the clusterrole </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>serviceaccount</td> <td></td> <td>[]</td> <td>Service accounts to bind to the clusterrole, in the format &lt;namespace&gt;:&lt;name&gt; </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-configmap-em-"><em>configmap</em></h2> <blockquote class="code-block example"> <p> Create a new config map named my-config based on folder bar</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">create</span> configmap my-config --<span class="hljs-keyword">from</span>-file=<span class="hljs-keyword">path</span>/<span class="hljs-keyword">to</span>/bar </code></pre> <blockquote class="code-block example"> <p> Create a new config map named my-config with specified keys instead of file basenames on disk</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create configmap my-config --<span class="hljs-keyword">from</span>-<span class="hljs-keyword">file</span>=key1=<span class="hljs-regexp">/path/</span>to<span class="hljs-regexp">/bar/</span>file1.txt --<span class="hljs-keyword">from</span>-<span class="hljs-keyword">file</span>=key2=<span class="hljs-regexp">/path/</span>to<span class="hljs-regexp">/bar/</span>file2.txt </code></pre> <blockquote class="code-block example"> <p> Create a new config map named my-config with key1=config1 and key2=config2</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create configmap my-config <span class="hljs-attribute">--from-literal</span>=key1=config1 <span class="hljs-attribute">--from-literal</span>=key2=config2 </code></pre> <blockquote class="code-block example"> <p> Create a new config map named my-config from the key=value pairs in the file</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">create</span> configmap my-config --<span class="hljs-keyword">from</span>-file=<span class="hljs-keyword">path</span>/<span class="hljs-keyword">to</span>/bar </code></pre> <blockquote class="code-block example"> <p> Create a new config map named my-config from an env file</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">create</span> configmap my-config --<span class="hljs-keyword">from</span>-env-file=<span class="hljs-keyword">path</span>/<span class="hljs-keyword">to</span>/bar.env </code></pre> <p>Create a config map based on a file, directory, or specified literal value.</p> <p> A single config map may package one or more key/value pairs.</p> <p> When creating a config map based on a file, the key will default to the basename of the file, and the value will default to the file content. If the basename is an invalid key, you may specify an alternate key.</p> <p> When creating a config map based on a directory, each file whose basename is a valid key in the directory will be packaged into the config map. Any directory entries except regular files are ignored (e.g. subdirectories, symlinks, devices, pipes, etc).</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create configmap NAME [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>append-hash</td> <td></td> <td>false</td> <td>Append a hash of the configmap to its name. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>from-env-file</td> <td></td> <td></td> <td>Specify the path to a file to read lines of key=val pairs to create a configmap (i.e. a Docker .env file). </td> </tr> <tr> <td>from-file</td> <td></td> <td>[]</td> <td>Key file can be specified using its file path, in which case file basename will be used as configmap key, or optionally with a key and file path, in which case the given key will be used. Specifying a directory will iterate each named file in the directory whose basename is a valid configmap key. </td> </tr> <tr> <td>from-literal</td> <td></td> <td>[]</td> <td>Specify a key and literal value to insert in configmap (i.e. mykey=somevalue) </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-cronjob-em-"><em>cronjob</em></h2> <blockquote class="code-block example"> <p> Create a cron job</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create cronjob my-job <span class="hljs-attribute">--image</span>=busybox <span class="hljs-attribute">--schedule</span>=<span class="hljs-string">"*/1 * * * *"</span> </code></pre> <blockquote class="code-block example"> <p> Create a cron job with a command</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create cronjob my-job <span class="hljs-attribute">--image</span>=busybox <span class="hljs-attribute">--schedule</span>=<span class="hljs-string">"*/1 * * * *"</span> -- date </code></pre> <p>Create a cron job with the specified name.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create cronjob NAME --image=image --schedule=&#39;0/5 * * * ?&#39; -- [COMMAND] [args...]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>image</td> <td></td> <td></td> <td>Image name to run. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>restart</td> <td></td> <td></td> <td>job&#39;s restart policy. supported values: OnFailure, Never </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>schedule</td> <td></td> <td></td> <td>A schedule in the Cron format the job should be run with. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-deployment-em-"><em>deployment</em></h2> <blockquote class="code-block example"> <p> Create a deployment named my-dep that runs the busybox image</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create deployment <span class="hljs-keyword">my</span>-dep <span class="hljs-comment">--image=busybox</span> </code></pre> <blockquote class="code-block example"> <p> Create a deployment with a command</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create deployment <span class="hljs-keyword">my</span>-dep <span class="hljs-comment">--image=busybox -- date</span> </code></pre> <blockquote class="code-block example"> <p> Create a deployment named my-dep that runs the nginx image with 3 replicas</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create deployment my-dep <span class="hljs-attribute">--image</span>=nginx <span class="hljs-attribute">--replicas</span>=3 </code></pre> <blockquote class="code-block example"> <p> Create a deployment named my-dep that runs the busybox image and expose port 5701</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create deployment my-dep <span class="hljs-attribute">--image</span>=busybox <span class="hljs-attribute">--port</span>=5701 </code></pre> <p>Create a deployment with the specified name.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create deployment NAME --image=image -- [COMMAND] [args...]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>image</td> <td></td> <td>[]</td> <td>Image names to run. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>port</td> <td></td> <td>-1</td> <td>The port that this container exposes. </td> </tr> <tr> <td>replicas</td> <td>r</td> <td>1</td> <td>Number of replicas to create. Default is 1. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-ingress-em-"><em>ingress</em></h2> <blockquote class="code-block example"> <p> Create a single ingress called &#39;simple&#39; that directs requests to foo.com/bar to svc # svc1:8080 with a tls secret &quot;my-cert&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create ingress<span class="hljs-built_in"> simple </span><span class="hljs-attribute">--rule</span>=<span class="hljs-string">"foo.com/bar=svc1:8080,tls=my-cert"</span> </code></pre> <blockquote class="code-block example"> <p> Create a catch all ingress of &quot;/path&quot; pointing to service svc:port and Ingress Class as &quot;otheringress&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create ingress <span class="hljs-keyword">catch</span>-all --<span class="hljs-keyword">class</span>=otheringress --rule=<span class="hljs-string">"/path=svc:port"</span> </code></pre> <blockquote class="code-block example"> <p> Create an ingress with two annotations: ingress.annotation1 and ingress.annotations2</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create ingress annotated <span class="hljs-attribute">--class</span>=default <span class="hljs-attribute">--rule</span>=<span class="hljs-string">"foo.com/bar=svc:port"</span> \ --annotation ingress.<span class="hljs-attribute">annotation1</span>=foo \ --annotation ingress.<span class="hljs-attribute">annotation2</span>=bla </code></pre> <blockquote class="code-block example"> <p> Create an ingress with the same host and multiple paths</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create ingress multipath <span class="hljs-attribute">--class</span>=default \ <span class="hljs-attribute">--rule</span>=<span class="hljs-string">"foo.com/=svc:port"</span> \ <span class="hljs-attribute">--rule</span>=<span class="hljs-string">"foo.com/admin/=svcadmin:portadmin"</span> </code></pre> <blockquote class="code-block example"> <p> Create an ingress with multiple hosts and the pathType as Prefix</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create ingress ingress1 <span class="hljs-attribute">--class</span>=default \ <span class="hljs-attribute">--rule</span>=<span class="hljs-string">"foo.com/path*=svc:8080"</span> \ <span class="hljs-attribute">--rule</span>=<span class="hljs-string">"bar.com/admin*=svc2:http"</span> </code></pre> <blockquote class="code-block example"> <p> Create an ingress with TLS enabled using the default ingress certificate and different path types</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create ingress ingtls <span class="hljs-attribute">--class</span>=default \ <span class="hljs-attribute">--rule</span>=<span class="hljs-string">"foo.com/=svc:https,tls"</span> \ <span class="hljs-attribute">--rule</span>=<span class="hljs-string">"foo.com/path/subpath*=othersvc:8080"</span> </code></pre> <blockquote class="code-block example"> <p> Create an ingress with TLS enabled using a specific secret and pathType as Prefix</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create ingress ingsecret --<span class="hljs-keyword">class</span>=<span class="hljs-keyword">default</span> \ --rule=<span class="hljs-string">"foo.com/*=svc:8080,tls=secret1"</span> </code></pre> <blockquote class="code-block example"> <p> Create an ingress with a default backend</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create ingress ingdefault <span class="hljs-attribute">--class</span>=default \ <span class="hljs-attribute">--default-backend</span>=defaultsvc:http \ <span class="hljs-attribute">--rule</span>=<span class="hljs-string">"foo.com/*=svc:8080,tls=secret1"</span> </code></pre> <p>Create an ingress with the specified name.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>annotation</td> <td></td> <td>[]</td> <td>Annotation to insert in the ingress object, in the format annotation=value </td> </tr> <tr> <td>class</td> <td></td> <td></td> <td>Ingress Class to be used </td> </tr> <tr> <td>default-backend</td> <td></td> <td></td> <td>Default service for backend, in format of svcname:port </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>rule</td> <td></td> <td>[]</td> <td>Rule in format host/path=service:port<span>[</span>,tls=secretname<span>]</span>. Paths containing the leading character &#39;*&#39; are considered pathType=Prefix. tls argument is optional. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-job-em-"><em>job</em></h2> <blockquote class="code-block example"> <p> Create a job</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create job <span class="hljs-keyword">my</span>-job <span class="hljs-comment">--image=busybox</span> </code></pre> <blockquote class="code-block example"> <p> Create a job with a command</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create <span class="hljs-keyword">job </span>my-<span class="hljs-keyword">job </span>--image=<span class="hljs-keyword">busybox </span>-- date </code></pre> <blockquote class="code-block example"> <p> Create a job from a cron job named &quot;a-cronjob&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">create</span> job <span class="hljs-keyword">test</span>-job <span class="hljs-comment">--from=cronjob/a-cronjob</span> </code></pre> <p>Create a job with the specified name.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>from</td> <td></td> <td></td> <td>The name of the resource to create a Job from (only cronjob is supported). </td> </tr> <tr> <td>image</td> <td></td> <td></td> <td>Image name to run. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-namespace-em-"><em>namespace</em></h2> <blockquote class="code-block example"> <p> Create a new namespace named my-namespace</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">create</span> <span class="hljs-keyword">namespace</span> my-<span class="hljs-keyword">namespace</span> </code></pre> <p>Create a namespace with the specified name.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create namespace NAME [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-poddisruptionbudget-em-"><em>poddisruptionbudget</em></h2> <blockquote class="code-block example"> <p> Create a pod disruption budget named my-pdb that will select all pods with the app=rails label # and require at least one of them being available at any point in time</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create poddisruptionbudget my-pdb <span class="hljs-attribute">--selector</span>=app=rails <span class="hljs-attribute">--min-available</span>=1 </code></pre> <blockquote class="code-block example"> <p> Create a pod disruption budget named my-pdb that will select all pods with the app=nginx label # and require at least half of the pods selected to be available at any point in time</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create pdb my-pdb <span class="hljs-attribute">--selector</span>=app=nginx <span class="hljs-attribute">--min-available</span>=50% </code></pre> <p>Create a pod disruption budget with the specified name, selector, and desired minimum available pods.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>max-unavailable</td> <td></td> <td></td> <td>The maximum number or percentage of unavailable pods this budget requires. </td> </tr> <tr> <td>min-available</td> <td></td> <td></td> <td>The minimum number or percentage of available pods this budget requires. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>selector</td> <td></td> <td></td> <td>A label selector to use for this budget. Only equality-based selector requirements are supported. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-priorityclass-em-"><em>priorityclass</em></h2> <blockquote class="code-block example"> <p> Create a priority class named high-priority</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create priorityclass high-priority <span class="hljs-attribute">--value</span>=1000 <span class="hljs-attribute">--description</span>=<span class="hljs-string">"high priority"</span> </code></pre> <blockquote class="code-block example"> <p> Create a priority class named default-priority that is considered as the global default priority</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create priorityclass <span class="hljs-keyword">default</span>-priority --<span class="hljs-keyword">value</span>=<span class="hljs-number">1000</span> --<span class="hljs-keyword">global</span>-<span class="hljs-keyword">default</span>=<span class="hljs-literal">true</span> --description=<span class="hljs-string">"default priority"</span> </code></pre> <blockquote class="code-block example"> <p> Create a priority class named high-priority that cannot preempt pods with lower priority</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create priorityclass high-priority <span class="hljs-attribute">--value</span>=1000 <span class="hljs-attribute">--description</span>=<span class="hljs-string">"high priority"</span> <span class="hljs-attribute">--preemption-policy</span>=<span class="hljs-string">"Never"</span> </code></pre> <p>Create a priority class with the specified name, value, globalDefault and description.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create priorityclass NAME --value=VALUE --global-default=BOOL [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>description</td> <td></td> <td></td> <td>description is an arbitrary string that usually provides guidelines on when this priority class should be used. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>global-default</td> <td></td> <td>false</td> <td>global-default specifies whether this PriorityClass should be considered as the default priority. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>preemption-policy</td> <td></td> <td>PreemptLowerPriority</td> <td>preemption-policy is the policy for preempting pods with lower priority. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> <tr> <td>value</td> <td></td> <td>0</td> <td>the value of this priority class. </td> </tr> </tbody> </table> <hr> <h2 id="-em-quota-em-"><em>quota</em></h2> <blockquote class="code-block example"> <p> Create a new resource quota named my-quota</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create quota my-quota --hard=cpu=<span class="hljs-number">1</span>,memory=<span class="hljs-number">1</span>G,pods=<span class="hljs-number">2</span>,services=<span class="hljs-number">3</span>,replicationcontrollers=<span class="hljs-number">2</span>,resourcequotas=<span class="hljs-number">1</span>,secrets=<span class="hljs-number">5</span>,persistentvolumeclaims=<span class="hljs-number">10</span> </code></pre> <blockquote class="code-block example"> <p> Create a new resource quota named best-effort</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create quota best-effort <span class="hljs-attribute">--hard</span>=pods=100 <span class="hljs-attribute">--scopes</span>=BestEffort </code></pre> <p>Create a resource quota with the specified name, hard limits, and optional scopes.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create quota NAME [--hard=key1=value1,key2=value2] [--scopes=Scope1,Scope2] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>hard</td> <td></td> <td></td> <td>A comma-delimited set of resource=quantity pairs that define a hard limit. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>scopes</td> <td></td> <td></td> <td>A comma-delimited set of quota scopes that must all match each object tracked by the quota. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-role-em-"><em>role</em></h2> <blockquote class="code-block example"> <p> Create a role named &quot;pod-reader&quot; that allows user to perform &quot;get&quot;, &quot;watch&quot; and &quot;list&quot; on pods</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create role pod-reader <span class="hljs-attribute">--verb</span>=get <span class="hljs-attribute">--verb</span>=list <span class="hljs-attribute">--verb</span>=watch <span class="hljs-attribute">--resource</span>=pods </code></pre> <blockquote class="code-block example"> <p> Create a role named &quot;pod-reader&quot; with ResourceName specified</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create role pod-reader <span class="hljs-attribute">--verb</span>=get <span class="hljs-attribute">--resource</span>=pods <span class="hljs-attribute">--resource-name</span>=readablepod <span class="hljs-attribute">--resource-name</span>=anotherpod </code></pre> <blockquote class="code-block example"> <p> Create a role named &quot;foo&quot; with API Group specified</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create role foo <span class="hljs-attribute">--verb</span>=get,list,watch <span class="hljs-attribute">--resource</span>=rs.extensions </code></pre> <blockquote class="code-block example"> <p> Create a role named &quot;foo&quot; with SubResource specified</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create role foo <span class="hljs-attribute">--verb</span>=get,list,watch <span class="hljs-attribute">--resource</span>=pods,pods/status </code></pre> <p>Create a role with single rule.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>resource</td> <td></td> <td>[]</td> <td>Resource that the rule applies to </td> </tr> <tr> <td>resource-name</td> <td></td> <td>[]</td> <td>Resource in the white list that the rule applies to, repeat this flag for multiple items </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> <tr> <td>verb</td> <td></td> <td>[]</td> <td>Verb that applies to the resources contained in the rule </td> </tr> </tbody> </table> <hr> <h2 id="-em-rolebinding-em-"><em>rolebinding</em></h2> <blockquote class="code-block example"> <p> Create a role binding for user1, user2, and group1 using the admin cluster role</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create rolebinding admin <span class="hljs-attribute">--clusterrole</span>=admin <span class="hljs-attribute">--user</span>=user1 <span class="hljs-attribute">--user</span>=user2 <span class="hljs-attribute">--group</span>=group1 </code></pre> <p>Create a role binding for a particular role or cluster role.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>clusterrole</td> <td></td> <td></td> <td>ClusterRole this RoleBinding should reference </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>group</td> <td></td> <td>[]</td> <td>Groups to bind to the role </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>role</td> <td></td> <td></td> <td>Role this RoleBinding should reference </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>serviceaccount</td> <td></td> <td>[]</td> <td>Service accounts to bind to the role, in the format &lt;namespace&gt;:&lt;name&gt; </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-secret-em-"><em>secret</em></h2> <p>Create a secret using specified subcommand.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create secret</code></p> <hr> <h2 id="-em-secret-docker-registry-em-"><em>secret docker-registry</em></h2> <blockquote class="code-block example"> <p> If you don&#39;t already have a .dockercfg file, you can create a dockercfg secret directly by using:</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> secret </span>docker-registry my-secret <span class="hljs-attribute">--docker-server</span>=DOCKER_REGISTRY_SERVER <span class="hljs-attribute">--docker-username</span>=DOCKER_USER <span class="hljs-attribute">--docker-password</span>=DOCKER_PASSWORD <span class="hljs-attribute">--docker-email</span>=DOCKER_EMAIL </code></pre> <blockquote class="code-block example"> <p> Create a new secret named my-secret from ~/.docker/config.json</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> secret </span>docker-registry my-secret <span class="hljs-attribute">--from-file</span>=.dockerconfigjson=path/to/.docker/config.json </code></pre> <p>Create a new secret for use with Docker registries.</p> <p> Dockercfg secrets are used to authenticate against Docker registries.</p> <p> When using the Docker command line to push images, you can authenticate to a given registry by running: &#39;$ docker login DOCKER_REGISTRY_SERVER --username=DOCKER_USER --password=DOCKER_PASSWORD --email=DOCKER_EMAIL&#39;.</p> <p> That produces a ~/.dockercfg file that is used by subsequent &#39;docker push&#39; and &#39;docker pull&#39; commands to authenticate to the registry. The email address is optional.</p> <p> When creating applications, you may have a Docker registry that requires authentication. In order for the nodes to pull images on your behalf, they must have the credentials. You can provide this information by creating a dockercfg secret and attaching it to your service account.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create secret docker-registry NAME --docker-username=user --docker-password=password --docker-email=email [--docker-server=string] [--from-file=[key=]source] [--dry-run=server|client|none] </code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>append-hash</td> <td></td> <td>false</td> <td>Append a hash of the secret to its name. </td> </tr> <tr> <td>docker-email</td> <td></td> <td></td> <td>Email for Docker registry </td> </tr> <tr> <td>docker-password</td> <td></td> <td></td> <td>Password for Docker registry authentication </td> </tr> <tr> <td>docker-server</td> <td></td> <td><a href="https://index.docker.io/v1/">https://index.docker.io/v1/</a></td> <td>Server location for Docker registry </td> </tr> <tr> <td>docker-username</td> <td></td> <td></td> <td>Username for Docker registry authentication </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>from-file</td> <td></td> <td>[]</td> <td>Key files can be specified using their file path, in which case a default name will be given to them, or optionally with a name and file path, in which case the given name will be used. Specifying a directory will iterate each named file in the directory that is a valid secret key. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-secret-generic-em-"><em>secret generic</em></h2> <blockquote class="code-block example"> <p> Create a new secret named my-secret with keys for each file in folder bar</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> secret </span>generic my-secret <span class="hljs-attribute">--from-file</span>=path/to/bar </code></pre> <blockquote class="code-block example"> <p> Create a new secret named my-secret with specified keys instead of names on disk</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> secret </span>generic my-secret <span class="hljs-attribute">--from-file</span>=ssh-privatekey=path/to/id_rsa <span class="hljs-attribute">--from-file</span>=ssh-publickey=path/to/id_rsa.pub </code></pre> <blockquote class="code-block example"> <p> Create a new secret named my-secret with key1=supersecret and key2=topsecret</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> secret </span>generic my-secret <span class="hljs-attribute">--from-literal</span>=key1=supersecret <span class="hljs-attribute">--from-literal</span>=key2=topsecret </code></pre> <blockquote class="code-block example"> <p> Create a new secret named my-secret using a combination of a file and a literal</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> secret </span>generic my-secret <span class="hljs-attribute">--from-file</span>=ssh-privatekey=path/to/id_rsa <span class="hljs-attribute">--from-literal</span>=passphrase=topsecret </code></pre> <blockquote class="code-block example"> <p> Create a new secret named my-secret from an env file</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> secret </span>generic my-secret <span class="hljs-attribute">--from-env-file</span>=path/to/bar.env </code></pre> <p>Create a secret based on a file, directory, or specified literal value.</p> <p> A single secret may package one or more key/value pairs.</p> <p> When creating a secret based on a file, the key will default to the basename of the file, and the value will default to the file content. If the basename is an invalid key or you wish to chose your own, you may specify an alternate key.</p> <p> When creating a secret based on a directory, each file whose basename is a valid key in the directory will be packaged into the secret. Any directory entries except regular files are ignored (e.g. subdirectories, symlinks, devices, pipes, etc).</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create generic NAME [--type=string] [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>append-hash</td> <td></td> <td>false</td> <td>Append a hash of the secret to its name. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>from-env-file</td> <td></td> <td></td> <td>Specify the path to a file to read lines of key=val pairs to create a secret (i.e. a Docker .env file). </td> </tr> <tr> <td>from-file</td> <td></td> <td>[]</td> <td>Key files can be specified using their file path, in which case a default name will be given to them, or optionally with a name and file path, in which case the given name will be used. Specifying a directory will iterate each named file in the directory that is a valid secret key. </td> </tr> <tr> <td>from-literal</td> <td></td> <td>[]</td> <td>Specify a key and literal value to insert in secret (i.e. mykey=somevalue) </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>type</td> <td></td> <td></td> <td>The type of secret to create </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-secret-tls-em-"><em>secret tls</em></h2> <blockquote class="code-block example"> <p> Create a new TLS secret named tls-secret with the given key pair</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> secret </span>tls tls-secret <span class="hljs-attribute">--cert</span>=path/to/tls.cert <span class="hljs-attribute">--key</span>=path/to/tls.key </code></pre> <p>Create a TLS secret from the given public/private key pair.</p> <p> The public/private key pair must exist beforehand. The public key certificate must be .PEM encoded and match the given private key.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create secret tls NAME --cert=path/to/cert/file --key=path/to/key/file [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>append-hash</td> <td></td> <td>false</td> <td>Append a hash of the secret to its name. </td> </tr> <tr> <td>cert</td> <td></td> <td></td> <td>Path to PEM encoded public key certificate. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>key</td> <td></td> <td></td> <td>Path to private key associated with given certificate. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-service-em-"><em>service</em></h2> <p>Create a service using a specified subcommand.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create service</code></p> <hr> <h2 id="-em-service-clusterip-em-"><em>service clusterip</em></h2> <blockquote class="code-block example"> <p> Create a new ClusterIP service named my-cs</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> service </span>clusterip my-cs <span class="hljs-attribute">--tcp</span>=5678:8080 </code></pre> <blockquote class="code-block example"> <p> Create a new ClusterIP service named my-cs (in headless mode)</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> service </span>clusterip my-cs <span class="hljs-attribute">--clusterip</span>=<span class="hljs-string">"None"</span> </code></pre> <p>Create a ClusterIP service with the specified name.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create service clusterip NAME [--tcp=&lt;port&gt;:&lt;targetPort&gt;] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>clusterip</td> <td></td> <td></td> <td>Assign your own ClusterIP or set to &#39;None&#39; for a &#39;headless&#39; service (no loadbalancing). </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>tcp</td> <td></td> <td>[]</td> <td>Port pairs can be specified as &#39;&lt;port&gt;:&lt;targetPort&gt;&#39;. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-service-externalname-em-"><em>service externalname</em></h2> <blockquote class="code-block example"> <p> Create a new ExternalName service named my-ns</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> service </span>externalname my-ns --external-name bar.com </code></pre> <p>Create an ExternalName service with the specified name.</p> <p> ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference services that exist off platform, on other clusters, or locally.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create service externalname NAME --external-name external.name [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>external-name</td> <td></td> <td></td> <td>External name of service </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>tcp</td> <td></td> <td>[]</td> <td>Port pairs can be specified as &#39;&lt;port&gt;:&lt;targetPort&gt;&#39;. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-service-loadbalancer-em-"><em>service loadbalancer</em></h2> <blockquote class="code-block example"> <p> Create a new LoadBalancer service named my-lbs</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> service </span>loadbalancer my-lbs <span class="hljs-attribute">--tcp</span>=5678:8080 </code></pre> <p>Create a LoadBalancer service with the specified name.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>tcp</td> <td></td> <td>[]</td> <td>Port pairs can be specified as &#39;&lt;port&gt;:&lt;targetPort&gt;&#39;. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-service-nodeport-em-"><em>service nodeport</em></h2> <blockquote class="code-block example"> <p> Create a new NodePort service named my-ns</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> service </span>nodeport my-ns <span class="hljs-attribute">--tcp</span>=5678:8080 </code></pre> <p>Create a NodePort service with the specified name.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create service nodeport NAME [--tcp=port:targetPort] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>node-port</td> <td></td> <td>0</td> <td>Port used to expose the service on each node in a cluster. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>tcp</td> <td></td> <td>[]</td> <td>Port pairs can be specified as &#39;&lt;port&gt;:&lt;targetPort&gt;&#39;. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h2 id="-em-serviceaccount-em-"><em>serviceaccount</em></h2> <blockquote class="code-block example"> <p> Create a new service account named my-service-account</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">create</span> serviceaccount my-service-<span class="hljs-keyword">account</span> </code></pre> <p>Create a service account with the specified name.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl create serviceaccount NAME [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-create</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h1 id="get">get</h1> <blockquote class="code-block example"> <p> List all pods in ps output format</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">get</span> pods </code></pre> <blockquote class="code-block example"> <p> List all pods in ps output format with more information (such as node name)</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">get</span> pods -o wide </code></pre> <blockquote class="code-block example"> <p> List a single replication controller with specified NAME in ps output format</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">get</span> replicationcontroller web </code></pre> <blockquote class="code-block example"> <p> List deployments in JSON output format, in the &quot;v1&quot; version of the &quot;apps&quot; API group</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-selector-tag">kubectl</span> <span class="hljs-selector-tag">get</span> <span class="hljs-selector-tag">deployments</span><span class="hljs-selector-class">.v1</span><span class="hljs-selector-class">.apps</span> <span class="hljs-selector-tag">-o</span> <span class="hljs-selector-tag">json</span> </code></pre> <blockquote class="code-block example"> <p> List a single pod in JSON output format</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">get</span> -o <span class="hljs-type">json</span> pod web-pod<span class="hljs-number">-13</span>je7 </code></pre> <blockquote class="code-block example"> <p> List a pod identified by type and name specified in &quot;pod.yaml&quot; in JSON output format</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">get</span> -f pod.yaml -o <span class="hljs-type">json</span> </code></pre> <blockquote class="code-block example"> <p> List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">get</span> -k dir/ </code></pre> <blockquote class="code-block example"> <p> Return only the phase value of the specified pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">get</span> -o <span class="hljs-keyword">template</span> pod/web-pod<span class="hljs-number">-13</span>je7 --<span class="hljs-keyword">template</span>={{.status.phase}} </code></pre> <blockquote class="code-block example"> <p> List resource information in custom columns</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">get</span> pod test-pod -o <span class="hljs-attribute">custom-columns</span>=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image </code></pre> <blockquote class="code-block example"> <p> List all replication controllers and services together in ps output format</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">get</span> rc,services </code></pre> <blockquote class="code-block example"> <p> List one or more resources by their type and names</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">get</span> rc/web service/frontend pods/web-pod-13je7 </code></pre> <p>Display one or many resources.</p> <p> Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will only see results in your current namespace unless you pass --all-namespaces.</p> <p> Uninitialized objects are not shown unless --include-uninitialized is passed.</p> <p> By specifying the output as &#39;template&#39; and providing a Go template as the value of the --template flag, you can filter the attributes of the fetched resources.</p> <p>Use &quot;kubectl api-resources&quot; for a complete list of supported resources.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl get [(-o|--output=)json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file|custom-columns|custom-columns-file|wide] (TYPE[.VERSION][.GROUP] [NAME | -l label] | TYPE[.VERSION][.GROUP]/NAME ...) [flags]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all-namespaces</td> <td>A</td> <td>false</td> <td>If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>chunk-size</td> <td></td> <td>500</td> <td>Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may change in the future. </td> </tr> <tr> <td>field-selector</td> <td></td> <td></td> <td>Selector (field query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>ignore-not-found</td> <td></td> <td>false</td> <td>If the requested object does not exist the command will return exit code 0. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>label-columns</td> <td>L</td> <td>[]</td> <td>Accepts a comma separated list of labels that are going to be presented as columns. Names are case-sensitive. You can also use multiple flag options like -L label1 -L label2... </td> </tr> <tr> <td>no-headers</td> <td></td> <td>false</td> <td>When using the default or custom-column output format, don&#39;t print headers (default print headers). </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file&#124;custom-columns-file&#124;custom-columns&#124;wide See custom columns <span>[</span><a href="https://kubernetes.io/docs/reference/kubectl/overview/#custom-columns">https://kubernetes.io/docs/reference/kubectl/overview/#custom-columns</a><span>]</span>, golang template <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span> and jsonpath template <span>[</span><a href="https://kubernetes.io/docs/reference/kubectl/jsonpath/">https://kubernetes.io/docs/reference/kubectl/jsonpath/</a><span>]</span>. </td> </tr> <tr> <td>output-watch-events</td> <td></td> <td>false</td> <td>Output watch event objects when --watch or --watch-only is used. Existing objects are output as initial ADDED events. </td> </tr> <tr> <td>raw</td> <td></td> <td></td> <td>Raw URI to request from the server. Uses the transport specified by the kubeconfig file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>server-print</td> <td></td> <td>true</td> <td>If true, have the server return the appropriate table output. Supports extension APIs and CRDs. </td> </tr> <tr> <td>show-kind</td> <td></td> <td>false</td> <td>If present, list the resource type for the requested object(s). </td> </tr> <tr> <td>show-labels</td> <td></td> <td>false</td> <td>When printing, show all labels as the last column (default hide labels column) </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>sort-by</td> <td></td> <td></td> <td>If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. &#39;{.metadata.name}&#39;). The field in the API resource specified by this JSONPath expression must be an integer or a string. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>use-openapi-print-columns</td> <td></td> <td>false</td> <td>If true, use x-kubernetes-print-column metadata (if present) from the OpenAPI schema for displaying a resource. </td> </tr> <tr> <td>watch</td> <td>w</td> <td>false</td> <td>After listing/getting the requested object, watch for changes. Uninitialized objects are excluded if no object name is provided. </td> </tr> <tr> <td>watch-only</td> <td></td> <td>false</td> <td>Watch for changes to the requested object(s), without listing/getting first. </td> </tr> </tbody> </table> <hr> <h1 id="run">run</h1> <blockquote class="code-block example"> <p> Start a nginx pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">run</span> nginx <span class="hljs-attribute">--image</span>=nginx </code></pre> <blockquote class="code-block example"> <p> Start a hazelcast pod and let the container expose port 5701</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">run</span> hazelcast <span class="hljs-attribute">--image</span>=hazelcast/hazelcast <span class="hljs-attribute">--port</span>=5701 </code></pre> <blockquote class="code-block example"> <p> Start a hazelcast pod and set environment variables &quot;DNS_DOMAIN=cluster&quot; and &quot;POD_NAMESPACE=default&quot; in the container</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">run</span> hazelcast <span class="hljs-attribute">--image</span>=hazelcast/hazelcast <span class="hljs-attribute">--env</span>=<span class="hljs-string">"DNS_DOMAIN=cluster"</span> <span class="hljs-attribute">--env</span>=<span class="hljs-string">"POD_NAMESPACE=default"</span> </code></pre> <blockquote class="code-block example"> <p> Start a hazelcast pod and set labels &quot;app=hazelcast&quot; and &quot;env=prod&quot; in the container</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">run</span> hazelcast <span class="hljs-attribute">--image</span>=hazelcast/hazelcast <span class="hljs-attribute">--labels</span>=<span class="hljs-string">"app=hazelcast,env=prod"</span> </code></pre> <blockquote class="code-block example"> <p> Dry run; print the corresponding API objects without creating them</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">run</span> nginx <span class="hljs-attribute">--image</span>=nginx <span class="hljs-attribute">--dry-run</span>=client </code></pre> <blockquote class="code-block example"> <p> Start a nginx pod, but overload the spec with a partial set of values parsed from JSON</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl run nginx <span class="hljs-params">--image=nginx</span> <span class="hljs-params">--overrides=</span>'{ <span class="hljs-string">"apiVersion"</span>: <span class="hljs-string">"v1"</span>, <span class="hljs-string">"spec"</span>: { <span class="hljs-string">...</span> } }' </code></pre> <blockquote class="code-block example"> <p> Start a busybox pod and keep it in the foreground, don&#39;t restart it if it exits</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">run</span> -i -t busybox <span class="hljs-attribute">--image</span>=busybox <span class="hljs-attribute">--restart</span>=Never </code></pre> <blockquote class="code-block example"> <p> Start the nginx pod using the default command, but use custom arguments (arg1 .. argN) for that command</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">run</span> nginx <span class="hljs-attribute">--image</span>=nginx -- &lt;arg1&gt; &lt;arg2&gt; <span class="hljs-built_in">..</span>. &lt;argN&gt; </code></pre> <blockquote class="code-block example"> <p> Start the nginx pod using a different command and custom arguments</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">run</span> nginx <span class="hljs-attribute">--image</span>=nginx --command -- &lt;cmd&gt; &lt;arg1&gt; <span class="hljs-built_in">..</span>. &lt;argN&gt; </code></pre> <p>Create and run a particular image in a pod.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl run NAME --image=image [--env=&quot;key=value&quot;] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>annotations</td> <td></td> <td>[]</td> <td>Annotations to apply to the pod. </td> </tr> <tr> <td>attach</td> <td></td> <td>false</td> <td>If true, wait for the Pod to start running, and then attach to the Pod as if &#39;kubectl attach ...&#39; were called. Default false, unless &#39;-i/--stdin&#39; is set, in which case the default is true. With &#39;--restart=Never&#39; the exit code of the container process is returned. </td> </tr> <tr> <td>cascade</td> <td></td> <td>background</td> <td>Must be &quot;background&quot;, &quot;orphan&quot;, or &quot;foreground&quot;. Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background. </td> </tr> <tr> <td>command</td> <td></td> <td>false</td> <td>If true and extra arguments are present, use them as the &#39;command&#39; field in the container, rather than the &#39;args&#39; field which is the default. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>env</td> <td></td> <td>[]</td> <td>Environment variables to set in the container. </td> </tr> <tr> <td>expose</td> <td></td> <td>false</td> <td>If true, service is created for the container(s) which are run </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-run</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>to use to replace the resource. </td> </tr> <tr> <td>force</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>grace-period</td> <td></td> <td>-1</td> <td>Period 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). </td> </tr> <tr> <td>hostport</td> <td></td> <td>-1</td> <td>The host port mapping for the container port. To demonstrate a single-machine container. </td> </tr> <tr> <td>image</td> <td></td> <td></td> <td>The image for the container to run. </td> </tr> <tr> <td>image-pull-policy</td> <td></td> <td></td> <td>The image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process a kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>labels</td> <td>l</td> <td></td> <td>Comma separated labels to apply to the pod(s). Will override previous values. </td> </tr> <tr> <td>leave-stdin-open</td> <td></td> <td>false</td> <td>If the pod is started in interactive mode or with stdin, leave stdin open after the first attach completes. By default, stdin will be closed after the first attach completes. </td> </tr> <tr> <td>limits</td> <td></td> <td></td> <td>The resource requirement limits for this container. For example, &#39;cpu=200m,memory=512Mi&#39;. Note that server side components may assign limits depending on the server configuration, such as limit ranges. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>overrides</td> <td></td> <td></td> <td>An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. </td> </tr> <tr> <td>pod-running-timeout</td> <td></td> <td>1m0s</td> <td>The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running </td> </tr> <tr> <td>port</td> <td></td> <td></td> <td>The port that this container exposes. </td> </tr> <tr> <td>privileged</td> <td></td> <td>false</td> <td>If true, run the container in privileged mode. </td> </tr> <tr> <td>quiet</td> <td>q</td> <td>false</td> <td>If true, suppress prompt messages. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>requests</td> <td></td> <td></td> <td>The resource requirement requests for this container. For example, &#39;cpu=100m,memory=256Mi&#39;. Note that server side components may assign requests depending on the server configuration, such as limit ranges. </td> </tr> <tr> <td>restart</td> <td></td> <td>Always</td> <td>The restart policy for this Pod. Legal values <span>[</span>Always, OnFailure, Never<span>]</span>. </td> </tr> <tr> <td>rm</td> <td></td> <td>false</td> <td>If true, delete resources created in this command for attached containers. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>serviceaccount</td> <td></td> <td></td> <td>Service account to set in the pod spec. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>stdin</td> <td>i</td> <td>false</td> <td>Keep stdin open on the container(s) in the pod, even if nothing is attached. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>timeout</td> <td></td> <td>0s</td> <td>The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object </td> </tr> <tr> <td>tty</td> <td>t</td> <td>false</td> <td>Allocated a TTY for each container in the pod. </td> </tr> <tr> <td>wait</td> <td></td> <td>false</td> <td>If true, wait for resources to be gone before returning. This waits for finalizers. </td> </tr> </tbody> </table> <hr> <h1 id="expose">expose</h1> <blockquote class="code-block example"> <p> Create a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl expose rc nginx <span class="hljs-attribute">--port</span>=80 <span class="hljs-attribute">--target-port</span>=8000 </code></pre> <blockquote class="code-block example"> <p> Create a service for a replication controller identified by type and name specified in &quot;nginx-controller.yaml&quot;, which serves on port 80 and connects to the containers on port 8000</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl expose -f nginx-controller.yaml <span class="hljs-attribute">--port</span>=80 <span class="hljs-attribute">--target-port</span>=8000 </code></pre> <blockquote class="code-block example"> <p> Create a service for a pod valid-pod, which serves on port 444 with the name &quot;frontend&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl expose pod valid-pod <span class="hljs-attribute">--port</span>=444 <span class="hljs-attribute">--name</span>=frontend </code></pre> <blockquote class="code-block example"> <p> Create a second service based on the above service, exposing the container port 8443 as port 443 with the name &quot;nginx-https&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl expose<span class="hljs-built_in"> service </span>nginx <span class="hljs-attribute">--port</span>=443 <span class="hljs-attribute">--target-port</span>=8443 <span class="hljs-attribute">--name</span>=nginx-https </code></pre> <blockquote class="code-block example"> <p> Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named &#39;video-stream&#39;.</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl expose rc streamer <span class="hljs-attribute">--port</span>=4100 <span class="hljs-attribute">--protocol</span>=UDP <span class="hljs-attribute">--name</span>=video-stream </code></pre> <blockquote class="code-block example"> <p> Create a service for a replicated nginx using replica set, which serves on port 80 and connects to the containers on port 8000</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl expose rs nginx <span class="hljs-attribute">--port</span>=80 <span class="hljs-attribute">--target-port</span>=8000 </code></pre> <blockquote class="code-block example"> <p> Create a service for an nginx deployment, which serves on port 80 and connects to the containers on port 8000</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl expose deployment nginx <span class="hljs-attribute">--port</span>=80 <span class="hljs-attribute">--target-port</span>=8000 </code></pre> <p>Expose a resource as a new Kubernetes service.</p> <p> Looks up a deployment, service, replica set, replication controller or pod by name 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 only 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 specified via --port and the exposed resource has multiple ports, all will be re-used by the new service. Also if no labels are specified, the new service will re-use the labels from the resource it exposes.</p> <p> Possible resources include (case insensitive):</p> <p> pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs)</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP|SCTP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>cluster-ip</td> <td></td> <td></td> <td>ClusterIP to be assigned to the service. Leave empty to auto-allocate, or set to &#39;None&#39; to create a headless service. </td> </tr> <tr> <td>container-port</td> <td></td> <td></td> <td>Synonym for --target-port </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>external-ip</td> <td></td> <td></td> <td>Additional external IP address (not managed by Kubernetes) 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-expose</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to expose a service </td> </tr> <tr> <td>generator</td> <td></td> <td>service/v2</td> <td>The name of the API generator to use. There are 2 generators: &#39;service/v1&#39; and &#39;service/v2&#39;. The only difference between them is that service port in v1 is named &#39;default&#39;, while it is left unnamed in v2. Default is &#39;service/v2&#39;. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>labels</td> <td>l</td> <td></td> <td>Labels to apply to the service created by this call. </td> </tr> <tr> <td>load-balancer-ip</td> <td></td> <td></td> <td>IP to assign to the LoadBalancer. If empty, an ephemeral IP will be created and used (cloud-provider specific). </td> </tr> <tr> <td>name</td> <td></td> <td></td> <td>The name for the newly created object. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>overrides</td> <td></td> <td></td> <td>An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. </td> </tr> <tr> <td>port</td> <td></td> <td></td> <td>The port that the service should serve on. Copied from the resource being exposed, if unspecified </td> </tr> <tr> <td>protocol</td> <td></td> <td></td> <td>The network protocol for the service to be created. Default is &#39;TCP&#39;. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>selector</td> <td></td> <td></td> <td>A label selector to use for this service. Only equality-based selector requirements are supported. If empty (the default) infer the selector from the replication controller or replica set.) </td> </tr> <tr> <td>session-affinity</td> <td></td> <td></td> <td>If non-empty, set the session affinity for the service to this; legal values: &#39;None&#39;, &#39;ClientIP&#39; </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>target-port</td> <td></td> <td></td> <td>Name or number for the port on the container that the service should direct traffic to. Optional. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>type</td> <td></td> <td></td> <td>Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is &#39;ClusterIP&#39;. </td> </tr> </tbody> </table> <hr> <h1 id="delete">delete</h1> <blockquote class="code-block example"> <p> Delete a pod using the type and name specified in pod.json</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">delete</span> -f ./pod.json </code></pre> <blockquote class="code-block example"> <p> Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">delete</span> -k dir </code></pre> <blockquote class="code-block example"> <p> Delete a pod based on the type and name in the JSON passed into stdin</p> </blockquote> <pre class="code-block example"><code class="lang-shell">cat pod.json | kubectl <span class="hljs-keyword">delete</span> -f - </code></pre> <blockquote class="code-block example"> <p> Delete pods and services with same names &quot;baz&quot; and &quot;foo&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">delete</span> pod,service baz foo </code></pre> <blockquote class="code-block example"> <p> Delete pods and services with label name=myLabel</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">delete</span> pods,services -l <span class="hljs-type">name</span>=myLabel </code></pre> <blockquote class="code-block example"> <p> Delete a pod with minimal delay</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">delete</span> pod foo <span class="hljs-comment">--now</span> </code></pre> <blockquote class="code-block example"> <p> Force delete a pod on a dead node</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">delete</span> pod foo <span class="hljs-comment">--force</span> </code></pre> <blockquote class="code-block example"> <p> Delete all pods</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">delete</span> pods <span class="hljs-comment">--all</span> </code></pre> <p>Delete resources by file names, stdin, resources and names, or by resources and label selector.</p> <p> JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector.</p> <p> 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 grace-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 specify the --force flag. Note: only a subset of resources support graceful deletion. In absence of the support, the --grace-period flag is ignored.</p> <p> IMPORTANT: Force deleting pods does not wait for confirmation that the pod&#39;s processes have been terminated, which can leave those processes running until the node 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 identify themselves, force deleting those pods may result in multiple processes running on different machines using the same identification which may lead to data corruption 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 pods to be evicted immediately.</p> <p> 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 will be lost along with the rest of the resource.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl delete ([-f FILENAME] | [-k DIRECTORY] | TYPE [(NAME | -l label | --all)])</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Delete all resources, including uninitialized ones, in the namespace of the specified resource types. </td> </tr> <tr> <td>all-namespaces</td> <td>A</td> <td>false</td> <td>If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. </td> </tr> <tr> <td>cascade</td> <td></td> <td>background</td> <td>Must be &quot;background&quot;, &quot;orphan&quot;, or &quot;foreground&quot;. Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-selector</td> <td></td> <td></td> <td>Selector (field query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>containing the resource to delete. </td> </tr> <tr> <td>force</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>grace-period</td> <td></td> <td>-1</td> <td>Period 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). </td> </tr> <tr> <td>ignore-not-found</td> <td></td> <td>false</td> <td>Treat &quot;resource not found&quot; as a successful delete. Defaults to &quot;true&quot; when --all is specified. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process a kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>now</td> <td></td> <td>false</td> <td>If true, resources are signaled for immediate shutdown (same as --grace-period=1). </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output mode. Use &quot;-o name&quot; for shorter output (resource/name). </td> </tr> <tr> <td>raw</td> <td></td> <td></td> <td>Raw URI to DELETE to the server. Uses the transport specified by the kubeconfig file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, not including uninitialized ones. </td> </tr> <tr> <td>timeout</td> <td></td> <td>0s</td> <td>The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object </td> </tr> <tr> <td>wait</td> <td></td> <td>true</td> <td>If true, wait for resources to be gone before returning. This waits for finalizers. </td> </tr> </tbody> </table> <h1 id="-strong-app-management-strong-"><strong>APP MANAGEMENT</strong></h1> <p>This section contains commands for creating, updating, deleting, and viewing your workloads in a Kubernetes cluster.</p> <hr> <h1 id="apply">apply</h1> <blockquote class="code-block example"> <p> Apply the configuration in pod.json to a pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">apply</span> -f ./pod.json </code></pre> <blockquote class="code-block example"> <p> Apply resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">apply</span> -k dir/ </code></pre> <blockquote class="code-block example"> <p> Apply the JSON passed into stdin to a pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">cat pod.json | <span class="hljs-type">kubectl</span> <span class="hljs-built_in">apply</span> -f - </code></pre> <blockquote class="code-block example"> <p> Note: --prune is still in Alpha # Apply the configuration in manifest.yaml that matches label app=nginx and delete all other resources that are not in the file and match label app=nginx</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl apply --prune -f manifest.yaml -l <span class="hljs-attribute">app</span>=nginx </code></pre> <blockquote class="code-block example"> <p> Apply the configuration in manifest.yaml and delete all the other config maps that are not in the file</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-comment">kubectl</span> <span class="hljs-comment">apply</span> --<span class="hljs-comment">prune</span> <span class="hljs-literal">-</span><span class="hljs-comment">f</span> <span class="hljs-comment">manifest</span><span class="hljs-string">.</span><span class="hljs-comment">yaml</span> --<span class="hljs-comment">all</span> --<span class="hljs-comment">prune</span><span class="hljs-literal">-</span><span class="hljs-comment">whitelist=core/v1/ConfigMap</span> </code></pre> <p>Apply a configuration to a resource by file name or stdin. The resource name must be specified. This resource will be created if it doesn&#39;t exist yet. To use &#39;apply&#39;, always create the resource initially with either &#39;apply&#39; or &#39;create --save-config&#39;.</p> <p> JSON and YAML formats are accepted.</p> <p> Alpha Disclaimer: the --prune functionality is not yet complete. Do not use unless you are aware of what the current state is. See <a href="https://issues.k8s.io/34274">https://issues.k8s.io/34274</a>.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl apply (-f FILENAME | -k DIRECTORY)</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources in the namespace of the specified resource types. </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>cascade</td> <td></td> <td>background</td> <td>Must be &quot;background&quot;, &quot;orphan&quot;, or &quot;foreground&quot;. Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-client-side-apply</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>that contains the configuration to apply </td> </tr> <tr> <td>force</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>force-conflicts</td> <td></td> <td>false</td> <td>If true, server-side apply will force the changes against conflicts. </td> </tr> <tr> <td>grace-period</td> <td></td> <td>-1</td> <td>Period 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). </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process a kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>openapi-patch</td> <td></td> <td>true</td> <td>If true, use openapi to calculate diff when the openapi presents and the resource can be found in the openapi spec. Otherwise, fall back to use baked-in types. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>overwrite</td> <td></td> <td>true</td> <td>Automatically resolve conflicts between the modified and live configuration by using values from the modified configuration </td> </tr> <tr> <td>prune</td> <td></td> <td>false</td> <td>Automatically delete resource objects, including the uninitialized ones, 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. </td> </tr> <tr> <td>prune-whitelist</td> <td></td> <td>[]</td> <td>Overwrite the default whitelist with &lt;group/version/kind&gt; for --prune </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>server-side</td> <td></td> <td>false</td> <td>If true, apply runs in the server instead of the client. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>timeout</td> <td></td> <td>0s</td> <td>The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> <tr> <td>wait</td> <td></td> <td>false</td> <td>If true, wait for resources to be gone before returning. This waits for finalizers. </td> </tr> </tbody> </table> <hr> <h2 id="-em-edit-last-applied-em-"><em>edit-last-applied</em></h2> <blockquote class="code-block example"> <p> Edit the last-applied-configuration annotations by type/name in YAML</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">apply</span> edit-<span class="hljs-built_in">last</span>-applied deployment/nginx </code></pre> <blockquote class="code-block example"> <p> Edit the last-applied-configuration annotations by file in JSON</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">apply</span> edit-<span class="hljs-built_in">last</span>-applied -f deploy.yaml -o json </code></pre> <p>Edit the latest last-applied-configuration annotations of resources from the default editor.</p> <p> The edit-last-applied 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 &#39;vi&#39; for Linux or &#39;notepad&#39; 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.</p> <p> The default format is YAML. To edit in JSON, specify &quot;-o json&quot;.</p> <p> The flag --windows-line-endings can be used to force Windows line endings, otherwise the default for your operating system will be used.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl apply edit-last-applied (RESOURCE/NAME | -f FILENAME)</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-client-side-apply</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files to use to edit the resource </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>windows-line-endings</td> <td></td> <td>false</td> <td>Defaults to the line ending native to your platform. </td> </tr> </tbody> </table> <hr> <h2 id="-em-set-last-applied-em-"><em>set-last-applied</em></h2> <blockquote class="code-block example"> <p> Set the last-applied-configuration of a resource to match the contents of a file</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-string">kubectl </span><span class="hljs-string">apply </span><span class="hljs-built_in">set-last-applied</span> -f <span class="hljs-string">deploy.</span><span class="hljs-string">yaml</span> </code></pre> <blockquote class="code-block example"> <p> Execute set-last-applied against each configuration file in a directory</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-string">kubectl </span><span class="hljs-string">apply </span><span class="hljs-built_in">set-last-applied</span> -f <span class="hljs-string">path/</span> </code></pre> <blockquote class="code-block example"> <p> Set the last-applied-configuration of a resource to match the contents of a file; will create the annotation if it does not already exist</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-string">kubectl </span><span class="hljs-string">apply </span><span class="hljs-built_in">set-last-applied</span> -f <span class="hljs-string">deploy.</span><span class="hljs-string">yaml </span><span class="hljs-built_in">--create-annotation=true</span> </code></pre> <p>Set the latest last-applied-configuration annotations by setting it to match the contents of a file. This results in the last-applied-configuration being updated as though &#39;kubectl apply -f<file> &#39; was run, without updating any other parts of the object.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl apply set-last-applied -f FILENAME</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>create-annotation</td> <td></td> <td>false</td> <td>Will create &#39;last-applied-configuration&#39; annotations if current objects doesn&#39;t have one </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files that contains the last-applied-configuration annotations </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-view-last-applied-em-"><em>view-last-applied</em></h2> <blockquote class="code-block example"> <p> View the last-applied-configuration annotations by type/name in YAML</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">apply</span> <span class="hljs-built_in">view</span>-<span class="hljs-built_in">last</span>-applied deployment/nginx </code></pre> <blockquote class="code-block example"> <p> View the last-applied-configuration annotations by file in JSON</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">apply</span> <span class="hljs-built_in">view</span>-<span class="hljs-built_in">last</span>-applied -f deploy.yaml -o json </code></pre> <p>View the latest last-applied-configuration annotations by type/name or file.</p> <p> The default output will be printed to stdout in YAML format. You can use the -o option to change the output format.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl apply view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME)</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources in the namespace of the specified resource types </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files that contains the last-applied-configuration annotations </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td>yaml</td> <td>Output format. Must be one of yaml&#124;json </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> </tbody> </table> <hr> <h1 id="annotate">annotate</h1> <blockquote class="code-block example"> <p> Update pod &#39;foo&#39; with the annotation &#39;description&#39; and the value &#39;my frontend&#39; # If the same annotation is set multiple times, only the last value will be applied</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl annotate pods foo description</span>=<span class="hljs-string">'my frontend'</span> </code></pre> <blockquote class="code-block example"> <p> Update a pod identified by type and name in &quot;pod.json&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl annotate -f pod.json <span class="hljs-keyword">description</span>=<span class="hljs-string">'my frontend'</span> </code></pre> <blockquote class="code-block example"> <p> Update pod &#39;foo&#39; with the annotation &#39;description&#39; and the value &#39;my frontend running nginx&#39;, overwriting any existing value</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-string">kubectl </span><span class="hljs-string">annotate </span><span class="hljs-built_in">--overwrite</span> <span class="hljs-string">pods </span><span class="hljs-string">foo </span><span class="hljs-string">description=</span><span class="hljs-string">'my frontend running nginx'</span> </code></pre> <blockquote class="code-block example"> <p> Update all pods in the namespace</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-string">kubectl </span><span class="hljs-string">annotate </span><span class="hljs-string">pods </span><span class="hljs-built_in">--all</span> <span class="hljs-string">description=</span><span class="hljs-string">'my frontend running nginx'</span> </code></pre> <blockquote class="code-block example"> <p> Update pod &#39;foo&#39; only if the resource is unchanged from version 1</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl annotate pods foo <span class="hljs-attribute">description</span>=<span class="hljs-string">'my frontend running nginx'</span> <span class="hljs-attribute">--resource-version</span>=1 </code></pre> <blockquote class="code-block example"> <p> Update pod &#39;foo&#39; by removing an annotation named &#39;description&#39; if it exists # Does not require the --overwrite flag</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl annotate pods foo <span class="hljs-keyword">description</span>- </code></pre> <p>Update the annotations on one or more resources.</p> <p> All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary string values such as structured JSON. Tools and system extensions may use annotations to store their own data.</p> <p> Attempting to set an annotation that already exists will fail unless --overwrite is set. If --resource-version is specified and does not match the current resource version on the server the command will fail.</p> <p>Use &quot;kubectl api-resources&quot; for a complete list of supported resources.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl annotate [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources, including uninitialized ones, in the namespace of the specified resource types. </td> </tr> <tr> <td>all-namespaces</td> <td>A</td> <td>false</td> <td>If true, check the specified action in all namespaces. </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-annotate</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>field-selector</td> <td></td> <td></td> <td>Selector (field query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to update the annotation </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>list</td> <td></td> <td>false</td> <td>If true, display the annotations for a given resource. </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, annotation will NOT contact api-server but run locally. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>overwrite</td> <td></td> <td>false</td> <td>If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>resource-version</td> <td></td> <td></td> <td>If non-empty, the annotation update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, not including uninitialized ones, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2). </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h1 id="autoscale">autoscale</h1> <blockquote class="code-block example"> <p> Auto scale a deployment &quot;foo&quot;, with the number of pods between 2 and 10, no target CPU utilization specified so a default autoscaling policy will be used</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl autoscale deployment foo <span class="hljs-attribute">--min</span>=2 <span class="hljs-attribute">--max</span>=10 </code></pre> <blockquote class="code-block example"> <p> Auto scale a replication controller &quot;foo&quot;, with the number of pods between 1 and 5, target CPU utilization at 80%</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl autoscale rc foo <span class="hljs-attribute">--max</span>=5 <span class="hljs-attribute">--cpu-percent</span>=80 </code></pre> <p>Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.</p> <p> Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that uses the given resource as a reference. An autoscaler can automatically increase or decrease number of pods deployed within the system as needed.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>cpu-percent</td> <td></td> <td>-1</td> <td>The target average CPU utilization (represented as a percent of requested CPU) over all the pods. If it&#39;s not specified or negative, a default autoscaling policy will be used. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-autoscale</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to autoscale. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>max</td> <td></td> <td>-1</td> <td>The upper limit for the number of pods that can be set by the autoscaler. Required. </td> </tr> <tr> <td>min</td> <td></td> <td>-1</td> <td>The lower limit for the number of pods that can be set by the autoscaler. If it&#39;s not specified or negative, the server will apply a default value. </td> </tr> <tr> <td>name</td> <td></td> <td></td> <td>The name for the newly created object. If not specified, the name of the input resource will be used. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h1 id="debug">debug</h1> <blockquote class="code-block example"> <p> Create an interactive debugging session in pod mypod and immediately attach to it. # (requires the EphemeralContainers feature to be enabled in the cluster)</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">debug</span> mypod -it <span class="hljs-attribute">--image</span>=busybox </code></pre> <blockquote class="code-block example"> <p> Create a debug container named debugger using a custom automated debugging image. # (requires the EphemeralContainers feature to be enabled in the cluster)</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">debug</span> <span class="hljs-attribute">--image</span>=myproj/debug-tools -c debugger mypod </code></pre> <blockquote class="code-block example"> <p> Create a copy of mypod adding a debug container and attach to it</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">debug</span> mypod -it <span class="hljs-attribute">--image</span>=busybox <span class="hljs-attribute">--copy-to</span>=my-debugger </code></pre> <blockquote class="code-block example"> <p> Create a copy of mypod changing the command of mycontainer</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">debug</span> mypod -it <span class="hljs-attribute">--copy-to</span>=my-debugger <span class="hljs-attribute">--container</span>=mycontainer -- sh </code></pre> <blockquote class="code-block example"> <p> Create a copy of mypod changing all container images to busybox</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">debug</span> mypod <span class="hljs-attribute">--copy-to</span>=my-debugger <span class="hljs-attribute">--set-image</span>=*=busybox </code></pre> <blockquote class="code-block example"> <p> Create a copy of mypod adding a debug container and changing container images</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">debug</span> mypod -it <span class="hljs-attribute">--copy-to</span>=my-debugger <span class="hljs-attribute">--image</span>=debian <span class="hljs-attribute">--set-image</span>=app=app:debug,sidecar=sidecar:debug </code></pre> <blockquote class="code-block example"> <p> Create an interactive debugging session on a node and immediately attach to it. # The container will run in the host namespaces and the host&#39;s filesystem will be mounted at /host</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl debug <span class="hljs-keyword">node</span><span class="hljs-title">/mynode</span> -it --<span class="hljs-attr">image=</span>busybox </code></pre> <p>Debug cluster resources using interactive debugging containers.</p> <p> &#39;debug&#39; provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if no resource is specified.</p> <p> The action taken by &#39;debug&#39; varies depending on what resource is specified. Supported actions include:</p> <ul> <li>Workload: Create a copy of an existing pod with certain attributes changed, for example changing the image tag to a new version.</li> <li>Workload: Add an ephemeral container to an already running pod, for example to add debugging utilities without restarting the pod.</li> <li>Node: Create a new pod that runs in the node&#39;s host namespaces and can access the node&#39;s filesystem.</li> </ul> <h3 id="usage">Usage</h3> <p><code>$ kubectl debug (POD | TYPE[[.VERSION].GROUP]/NAME) [ -- COMMAND [args...] ]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>arguments-only</td> <td></td> <td>false</td> <td>If specified, everything after -- will be passed to the new container as Args instead of Command. </td> </tr> <tr> <td>attach</td> <td></td> <td>false</td> <td>If true, wait for the container to start running, and then attach as if &#39;kubectl attach ...&#39; were called. Default false, unless &#39;-i/--stdin&#39; is set, in which case the default is true. </td> </tr> <tr> <td>container</td> <td>c</td> <td></td> <td>Container name to use for debug container. </td> </tr> <tr> <td>copy-to</td> <td></td> <td></td> <td>Create a copy of the target Pod with this name. </td> </tr> <tr> <td>env</td> <td></td> <td>[]</td> <td>Environment variables to set in the container. </td> </tr> <tr> <td>image</td> <td></td> <td></td> <td>Container image to use for debug container. </td> </tr> <tr> <td>image-pull-policy</td> <td></td> <td></td> <td>The image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server. </td> </tr> <tr> <td>quiet</td> <td>q</td> <td>false</td> <td>If true, suppress informational messages. </td> </tr> <tr> <td>replace</td> <td></td> <td>false</td> <td>When used with &#39;--copy-to&#39;, delete the original Pod. </td> </tr> <tr> <td>same-node</td> <td></td> <td>false</td> <td>When used with &#39;--copy-to&#39;, schedule the copy of target Pod on the same node. </td> </tr> <tr> <td>set-image</td> <td></td> <td>[]</td> <td>When used with &#39;--copy-to&#39;, a list of name=image pairs for changing container images, similar to how &#39;kubectl set image&#39; works. </td> </tr> <tr> <td>share-processes</td> <td></td> <td>true</td> <td>When used with &#39;--copy-to&#39;, enable process namespace sharing in the copy. </td> </tr> <tr> <td>stdin</td> <td>i</td> <td>false</td> <td>Keep stdin open on the container(s) in the pod, even if nothing is attached. </td> </tr> <tr> <td>target</td> <td></td> <td></td> <td>When using an ephemeral container, target processes in this container name. </td> </tr> <tr> <td>tty</td> <td>t</td> <td>false</td> <td>Allocate a TTY for the debugging container. </td> </tr> </tbody> </table> <hr> <h1 id="diff">diff</h1> <blockquote class="code-block example"> <p> Diff resources included in pod.json</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-selector-tag">kubectl</span> <span class="hljs-selector-tag">diff</span> <span class="hljs-selector-tag">-f</span> <span class="hljs-selector-tag">pod</span><span class="hljs-selector-class">.json</span> </code></pre> <blockquote class="code-block example"> <p> Diff file read from stdin</p> </blockquote> <pre class="code-block example"><code class="lang-shell">cat service.yaml <span class="hljs-string">| kubectl diff -f -</span> </code></pre> <p>Diff configurations specified by file name or stdin between the current online configuration, and the configuration as it would be if applied.</p> <p> The output is always YAML.</p> <p> 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=&quot;colordiff -N -u&quot;</p> <p> By default, the &quot;diff&quot; command available in your path will be run with the &quot;-u&quot; (unified diff) and &quot;-N&quot; (treat absent files as empty) options.</p> <p> Exit status: 0 No differences were found. 1 Differences were found. &gt;1 Kubectl or diff failed with an error.</p> <p> Note: KUBECTL_EXTERNAL_DIFF, if used, is expected to follow that convention.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl diff -f FILENAME</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>field-manager</td> <td></td> <td>kubectl-client-side-apply</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files contains the configuration to diff </td> </tr> <tr> <td>force-conflicts</td> <td></td> <td>false</td> <td>If true, server-side apply will force the changes against conflicts. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>server-side</td> <td></td> <td>false</td> <td>If true, apply runs in the server instead of the client. </td> </tr> </tbody> </table> <hr> <h1 id="edit">edit</h1> <blockquote class="code-block example"> <p> Edit the service named &#39;docker-registry&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">edit</span> svc/docker-registry </code></pre> <blockquote class="code-block example"> <p> Use an alternative editor</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">KUBE_EDITOR</span>=<span class="hljs-string">"nano"</span> kubectl <span class="hljs-builtin-name">edit</span> svc/docker-registry </code></pre> <blockquote class="code-block example"> <p> Edit the job &#39;myjob&#39; in JSON using the v1 API format</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">edit</span> job.v1.batch/myjob -o json </code></pre> <blockquote class="code-block example"> <p> Edit the deployment &#39;mydeployment&#39; in YAML and save the modified config in its annotation</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">edit</span> deployment/mydeployment -o yaml --<span class="hljs-keyword">save</span>-config </code></pre> <p>Edit a resource from the default editor.</p> <p> 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 &#39;vi&#39; for Linux or &#39;notepad&#39; 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.</p> <p> Editing is done with the API version used to fetch the resource. To edit using a specific API version, fully-qualify the resource, version, and group.</p> <p> The default format is YAML. To edit in JSON, specify &quot;-o json&quot;.</p> <p> The flag --windows-line-endings can be used to force Windows line endings, otherwise the default for your operating system will be used.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl edit (RESOURCE/NAME | -f FILENAME)</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-edit</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files to use to edit the resource </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>output-patch</td> <td></td> <td>false</td> <td>Output the patch if the resource is edited. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> <tr> <td>windows-line-endings</td> <td></td> <td>false</td> <td>Defaults to the line ending native to your platform. </td> </tr> </tbody> </table> <hr> <h1 id="kustomize">kustomize</h1> <blockquote class="code-block example"> <p> Build the current working directory</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl kustomize</span> </code></pre> <blockquote class="code-block example"> <p> Build some shared configuration directory</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl kustomize /<span class="hljs-built_in">home</span>/<span class="hljs-built_in">config</span>/production </code></pre> <blockquote class="code-block example"> <p> Build from github</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl kustomize https:<span class="hljs-regexp">//gi</span>thub.com<span class="hljs-regexp">/kubernetes-sigs/</span>kustomize.git<span class="hljs-regexp">/examples/</span>helloWorld?ref=v1.<span class="hljs-number">0.6</span> </code></pre> <p>Build a set of KRM resources using a &#39;kustomization.yaml&#39; file. The DIR argument must be a path to a directory containing &#39;kustomization.yaml&#39;, or a git repository URL with a path suffix specifying same with respect to the repository root. If DIR is omitted, &#39;.&#39; is assumed.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl kustomize DIR</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>as-current-user</td> <td></td> <td>false</td> <td>use the uid and gid of the command executor to run the function in the container </td> </tr> <tr> <td>enable-alpha-plugins</td> <td></td> <td>false</td> <td>enable kustomize plugins </td> </tr> <tr> <td>enable-helm</td> <td></td> <td>false</td> <td>Enable use of the Helm chart inflator generator. </td> </tr> <tr> <td>enable-managedby-label</td> <td></td> <td>false</td> <td>enable adding app.kubernetes.io/managed-by </td> </tr> <tr> <td>env</td> <td>e</td> <td>[]</td> <td>a list of environment variables to be used by functions </td> </tr> <tr> <td>helm-command</td> <td></td> <td>helm</td> <td>helm command (path to executable) </td> </tr> <tr> <td>load-restrictor</td> <td></td> <td>LoadRestrictionsRootOnly</td> <td>if set to &#39;LoadRestrictionsNone&#39;, local kustomizations may load files from outside their root. This does, however, break the relocatability of the kustomization. </td> </tr> <tr> <td>mount</td> <td></td> <td>[]</td> <td>a list of storage options read from the filesystem </td> </tr> <tr> <td>network</td> <td></td> <td>false</td> <td>enable network access for functions that declare it </td> </tr> <tr> <td>network-name</td> <td></td> <td>bridge</td> <td>the docker network to run the container in </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>If specified, write output to this path. </td> </tr> <tr> <td>reorder</td> <td></td> <td>legacy</td> <td>Reorder the resources just before output. Use &#39;legacy&#39; to apply a legacy reordering (Namespaces first, Webhooks last, etc). Use &#39;none&#39; to suppress a final reordering. </td> </tr> </tbody> </table> <hr> <h1 id="label">label</h1> <blockquote class="code-block example"> <p> Update pod &#39;foo&#39; with the label &#39;unhealthy&#39; and the value &#39;true&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">label</span><span class="bash"> pods foo unhealthy=<span class="hljs-literal">true</span></span> </code></pre> <blockquote class="code-block example"> <p> Update pod &#39;foo&#39; with the label &#39;status&#39; and the value &#39;unhealthy&#39;, overwriting any existing value</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">label</span><span class="bash"> --overwrite pods foo status=unhealthy</span> </code></pre> <blockquote class="code-block example"> <p> Update all pods in the namespace</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">label</span><span class="bash"> pods --all status=unhealthy</span> </code></pre> <blockquote class="code-block example"> <p> Update a pod identified by the type and name in &quot;pod.json&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">label</span><span class="bash"> -f pod.json status=unhealthy</span> </code></pre> <blockquote class="code-block example"> <p> Update pod &#39;foo&#39; only if the resource is unchanged from version 1</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl label pods foo <span class="hljs-attribute">status</span>=unhealthy <span class="hljs-attribute">--resource-version</span>=1 </code></pre> <blockquote class="code-block example"> <p> Update pod &#39;foo&#39; by removing a label named &#39;bar&#39; if it exists # Does not require the --overwrite flag</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">label</span><span class="bash"> pods foo bar-</span> </code></pre> <p>Update the labels on a resource.</p> <ul> <li>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.</li> <li>Optionally, the key can begin with a DNS subdomain prefix and a single &#39;/&#39;, like example.com/my-app.</li> <li>If --overwrite is true, then existing labels can be overwritten, otherwise attempting to overwrite a label will result in an error.</li> <li>If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used.</li> </ul> <h3 id="usage">Usage</h3> <p><code>$ kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources, including uninitialized ones, in the namespace of the specified resource types </td> </tr> <tr> <td>all-namespaces</td> <td>A</td> <td>false</td> <td>If true, check the specified action in all namespaces. </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-label</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>field-selector</td> <td></td> <td></td> <td>Selector (field query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to update the labels </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>list</td> <td></td> <td>false</td> <td>If true, display the labels for a given resource. </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, label will NOT contact api-server but run locally. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>overwrite</td> <td></td> <td>false</td> <td>If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>resource-version</td> <td></td> <td></td> <td>If 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. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, not including uninitialized ones, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2). </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h1 id="patch">patch</h1> <blockquote class="code-block example"> <p> Partially update a node using a strategic merge patch, specifying the patch as JSON</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl patch <span class="hljs-keyword">node</span> <span class="hljs-title">k8s-node-1</span> -p '{<span class="hljs-string">"spec"</span>:{<span class="hljs-string">"unschedulable"</span>:<span class="hljs-literal">true</span>}}' </code></pre> <blockquote class="code-block example"> <p> Partially update a node using a strategic merge patch, specifying the patch as YAML</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl patch <span class="hljs-keyword">node</span> <span class="hljs-title">k8s-node-1</span> -p $'<span class="hljs-keyword">spec</span>:\n unschedulable: <span class="hljs-literal">true</span>' </code></pre> <blockquote class="code-block example"> <p> Partially update a node identified by the type and name specified in &quot;node.json&quot; using strategic merge patch</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl patch -f <span class="hljs-keyword">node</span>.<span class="hljs-title">json</span> -p '{<span class="hljs-string">"spec"</span>:{<span class="hljs-string">"unschedulable"</span>:<span class="hljs-literal">true</span>}}' </code></pre> <blockquote class="code-block example"> <p> Update a container&#39;s image; spec.containers[*].name is required because it&#39;s a merge key</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">patch</span> pod valid-pod -p '{<span class="hljs-string">"spec"</span>:{<span class="hljs-string">"containers"</span>:[{<span class="hljs-string">"name"</span>:<span class="hljs-string">"kubernetes-serve-hostname"</span>,<span class="hljs-string">"image"</span>:<span class="hljs-string">"new image"</span>}]}}' </code></pre> <blockquote class="code-block example"> <p> Update a container&#39;s image using a JSON patch with positional arrays</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl patch pod valid-pod --<span class="hljs-class"><span class="hljs-keyword">type</span></span>=<span class="hljs-symbol">'jso</span>n' -p='[{<span class="hljs-string">"op"</span>: <span class="hljs-string">"replace"</span>, <span class="hljs-string">"path"</span>: <span class="hljs-string">"/spec/containers/0/image"</span>, <span class="hljs-string">"value"</span>:<span class="hljs-string">"new image"</span>}]' </code></pre> <p>Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.</p> <p> JSON and YAML formats are accepted.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-patch</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to update </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, patch will operate on the content of the file, not the server-side resource. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>patch</td> <td>p</td> <td></td> <td>The patch to be applied to the resource JSON file. </td> </tr> <tr> <td>patch-file</td> <td></td> <td></td> <td>A file containing a patch to be applied to the resource. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>type</td> <td></td> <td>strategic</td> <td>The type of patch being provided; one of <span>[</span>json merge strategic<span>]</span> </td> </tr> </tbody> </table> <hr> <h1 id="replace">replace</h1> <blockquote class="code-block example"> <p> Replace a pod using the data in pod.json</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">replace</span> -f ./pod.json </code></pre> <blockquote class="code-block example"> <p> Replace a pod based on the JSON passed into stdin</p> </blockquote> <pre class="code-block example"><code class="lang-shell">cat pod.json | <span class="hljs-type">kubectl</span> <span class="hljs-built_in">replace</span> -f - </code></pre> <blockquote class="code-block example"> <p> Update a single-container pod&#39;s image version (tag) to v4</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl get pod mypod -o yaml | <span class="hljs-type">sed</span> 's/\(image: myimage\):.*$/\<span class="hljs-number">1</span>:v4/' | <span class="hljs-type">kubectl</span> <span class="hljs-built_in">replace</span> -f - </code></pre> <blockquote class="code-block example"> <p> Force replace, delete and then re-create the resource</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl replace <span class="hljs-params">--force</span> -f <span class="hljs-string">./pod.json</span> </code></pre> <p>Replace a resource by file name or stdin.</p> <p> JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by</p> <p> $ kubectl get TYPE NAME -o yaml</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl replace -f FILENAME</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>cascade</td> <td></td> <td>background</td> <td>Must be &quot;background&quot;, &quot;orphan&quot;, or &quot;foreground&quot;. Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-replace</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>to use to replace the resource. </td> </tr> <tr> <td>force</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>grace-period</td> <td></td> <td>-1</td> <td>Period 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). </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process a kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>raw</td> <td></td> <td></td> <td>Raw URI to PUT to the server. Uses the transport specified by the kubeconfig file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>save-config</td> <td></td> <td>false</td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>timeout</td> <td></td> <td>0s</td> <td>The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> <tr> <td>wait</td> <td></td> <td>false</td> <td>If true, wait for resources to be gone before returning. This waits for finalizers. </td> </tr> </tbody> </table> <hr> <h1 id="rollout">rollout</h1> <blockquote class="code-block example"> <p> Rollback to the previous deployment</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-keyword">undo</span> deployment/<span class="hljs-keyword">abc</span> </code></pre> <blockquote class="code-block example"> <p> Check the rollout status of a daemonset</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-keyword">status</span> daemonset/foo </code></pre> <p>Manage the rollout of a resource.</p> <p> Valid resource types include:</p> <ul> <li>deployments</li> <li>daemonsets</li> <li>statefulsets</li> </ul> <h3 id="usage">Usage</h3> <p><code>$ kubectl rollout SUBCOMMAND</code></p> <hr> <h2 id="-em-history-em-"><em>history</em></h2> <blockquote class="code-block example"> <p> View the rollout history of a deployment</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-keyword">history</span> deployment/<span class="hljs-keyword">abc</span> </code></pre> <blockquote class="code-block example"> <p> View the details of daemonset revision 3</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-keyword">history</span> daemonset/abc <span class="hljs-params">--revision=3</span> </code></pre> <p>View previous rollout revisions and configurations.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl rollout history (TYPE NAME | TYPE/NAME) [flags]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>revision</td> <td></td> <td>0</td> <td>See the details, including podTemplate of the revision specified </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-pause-em-"><em>pause</em></h2> <blockquote class="code-block example"> <p> 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</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-keyword">pause</span> deployment/nginx </code></pre> <p>Mark the provided resource as paused.</p> <p> Paused resources will not be reconciled by a controller. Use &quot;kubectl rollout resume&quot; to resume a paused resource. Currently only deployments support being paused.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl rollout pause RESOURCE</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-rollout</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-restart-em-"><em>restart</em></h2> <blockquote class="code-block example"> <p> Restart a deployment</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-built_in">restart</span> deployment/nginx </code></pre> <blockquote class="code-block example"> <p> Restart a daemon set</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-built_in">restart</span> daemonset/abc </code></pre> <p>Restart a resource.</p> <p> Resource rollout will be restarted.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl rollout restart RESOURCE</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-rollout</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-resume-em-"><em>resume</em></h2> <blockquote class="code-block example"> <p> Resume an already paused deployment</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-keyword">resume</span> deployment/nginx </code></pre> <p>Resume a paused resource.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl rollout resume RESOURCE</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-rollout</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-status-em-"><em>status</em></h2> <blockquote class="code-block example"> <p> Watch the rollout status of a deployment</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-keyword">status</span> deployment/nginx </code></pre> <p>Show the status of the rollout.</p> <p> By default &#39;rollout status&#39; will watch the status of the latest rollout until it&#39;s done. If you don&#39;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 &#39;rollout status&#39; 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl rollout status (TYPE NAME | TYPE/NAME) [flags]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>revision</td> <td></td> <td>0</td> <td>Pin to a specific revision for showing its status. Defaults to 0 (last revision). </td> </tr> <tr> <td>timeout</td> <td></td> <td>0s</td> <td>The 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). </td> </tr> <tr> <td>watch</td> <td>w</td> <td>true</td> <td>Watch the status of the rollout until it&#39;s done. </td> </tr> </tbody> </table> <hr> <h2 id="-em-undo-em-"><em>undo</em></h2> <blockquote class="code-block example"> <p> Roll back to the previous deployment</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-keyword">undo</span> deployment/<span class="hljs-keyword">abc</span> </code></pre> <blockquote class="code-block example"> <p> Roll back to daemonset revision 3</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout <span class="hljs-keyword">undo</span> daemonset/<span class="hljs-keyword">abc</span> --<span class="hljs-keyword">to</span>-revision=<span class="hljs-number">3</span> </code></pre> <blockquote class="code-block example"> <p> Roll back to the previous deployment with dry-run</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl rollout undo --dry-<span class="hljs-keyword">run</span><span class="bash">=server deployment/abc</span> </code></pre> <p>Roll back to a previous rollout.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>to-revision</td> <td></td> <td>0</td> <td>The revision to rollback to. Default to 0 (last revision). </td> </tr> </tbody> </table> <hr> <h1 id="scale">scale</h1> <blockquote class="code-block example"> <p> Scale a replica set named &#39;foo&#39; to 3</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl scale <span class="hljs-attribute">--replicas</span>=3 rs/foo </code></pre> <blockquote class="code-block example"> <p> Scale a resource identified by type and name specified in &quot;foo.yaml&quot; to 3</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl scale <span class="hljs-attribute">--replicas</span>=3 -f foo.yaml </code></pre> <blockquote class="code-block example"> <p> If the deployment named mysql&#39;s current size is 2, scale mysql to 3</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl scale <span class="hljs-attribute">--current-replicas</span>=2 <span class="hljs-attribute">--replicas</span>=3 deployment/mysql </code></pre> <blockquote class="code-block example"> <p> Scale multiple replication controllers</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">scale</span> --replicas=<span class="hljs-number">5</span> rc/foo rc/<span class="hljs-built_in">bar</span> rc/baz </code></pre> <blockquote class="code-block example"> <p> Scale stateful set named &#39;web&#39; to 3</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl scale <span class="hljs-attribute">--replicas</span>=3 statefulset/web </code></pre> <p>Set a new size for a deployment, replica set, replication controller, or stateful set.</p> <p> Scale also allows users to specify one or more preconditions for the scale action.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT (-f FILENAME | TYPE NAME)</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources in the namespace of the specified resource types </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>current-replicas</td> <td></td> <td>-1</td> <td>Precondition for current size. Requires that the current size of the resource match this value in order to scale. -1 (default) for no condition. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to set a new size </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>replicas</td> <td></td> <td>0</td> <td>The new desired number of replicas. Required. </td> </tr> <tr> <td>resource-version</td> <td></td> <td></td> <td>Precondition for resource version. Requires that the current resource version match this value in order to scale. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>timeout</td> <td></td> <td>0s</td> <td>The length of time to wait before giving up on a scale operation, zero means don&#39;t wait. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h). </td> </tr> </tbody> </table> <hr> <h1 id="set">set</h1> <p>Configure application resources.</p> <p> These commands help you make changes to existing application resources.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl set SUBCOMMAND</code></p> <hr> <h2 id="-em-env-em-"><em>env</em></h2> <blockquote class="code-block example"> <p> Update deployment &#39;registry&#39; with a new environment variable</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> env deployment/registry <span class="hljs-attribute">STORAGE_DIR</span>=/local </code></pre> <blockquote class="code-block example"> <p> List the environment variables defined on a deployments &#39;sample-build&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">set</span> env deployment/<span class="hljs-keyword">sample</span>-<span class="hljs-keyword">build</span> <span class="hljs-comment">--list</span> </code></pre> <blockquote class="code-block example"> <p> List the environment variables defined on all pods</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">set</span> env pods <span class="hljs-params">--all</span> <span class="hljs-params">--list</span> </code></pre> <blockquote class="code-block example"> <p> Output modified deployment in YAML, and does not alter the object on the server</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> env deployment/sample-build <span class="hljs-attribute">STORAGE_DIR</span>=/data -o yaml </code></pre> <blockquote class="code-block example"> <p> Update all containers in all replication controllers in the project to have ENV=prod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> env rc --all <span class="hljs-attribute">ENV</span>=prod </code></pre> <blockquote class="code-block example"> <p> Import environment from a secret</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> env <span class="hljs-attribute">--from</span>=secret/mysecret deployment/myapp </code></pre> <blockquote class="code-block example"> <p> Import environment from a config map with a prefix</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> env <span class="hljs-attribute">--from</span>=configmap/myconfigmap <span class="hljs-attribute">--prefix</span>=MYSQL_ deployment/myapp </code></pre> <blockquote class="code-block example"> <p> Import specific keys from a config map</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> env <span class="hljs-attribute">--keys</span>=my-example-key <span class="hljs-attribute">--from</span>=configmap/myconfigmap deployment/myapp </code></pre> <blockquote class="code-block example"> <p> Remove the environment variable ENV from container &#39;c1&#39; in all deployment configs</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">set</span> env deployments <span class="hljs-params">--all</span> <span class="hljs-params">--containers=</span><span class="hljs-string">"c1"</span> ENV- </code></pre> <blockquote class="code-block example"> <p> Remove the environment variable ENV from a deployment definition on disk and # update the deployment config on the server</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl set <span class="hljs-keyword">env</span> -f deploy.json <span class="hljs-keyword">ENV</span>- </code></pre> <blockquote class="code-block example"> <p> Set some of the local shell environment into a deployment config on the server</p> </blockquote> <pre class="code-block example"><code class="lang-shell">env | <span class="hljs-type">grep</span> RAILS_ | <span class="hljs-type">kubectl</span> <span class="hljs-built_in">set</span> env -e - deployment/registry </code></pre> <p>Update environment variables on a pod template.</p> <p> 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 environment variable definitions on all containers in the specified pods or pod templates, or just those that match a wildcard.</p> <p> If &quot;--env -&quot; is passed, environment variables can be read from STDIN using the standard env syntax.</p> <p> Possible resources include (case insensitive):</p> <p> pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs)</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl set env RESOURCE/NAME KEY_1=VAL_1 ... KEY_N=VAL_N</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>If true, select all resources in the namespace of the specified resource types </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>containers</td> <td>c</td> <td>*</td> <td>The names of containers in the selected pod templates to change - may use wildcards </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>env</td> <td>e</td> <td>[]</td> <td>Specify a key-value pair for an environment variable to set into each container. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-set</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files the resource to update the env </td> </tr> <tr> <td>from</td> <td></td> <td></td> <td>The name of a resource from which to inject environment variables </td> </tr> <tr> <td>keys</td> <td></td> <td>[]</td> <td>Comma-separated list of keys to import from specified resource </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>list</td> <td></td> <td>false</td> <td>If true, display the environment and any changes in the standard format. this flag will removed when we have kubectl view env. </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, set env will NOT contact api-server but run locally. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>overwrite</td> <td></td> <td>true</td> <td>If true, allow environment to be overwritten, otherwise reject updates that overwrite existing environment. </td> </tr> <tr> <td>prefix</td> <td></td> <td></td> <td>Prefix to append to variable names </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>resolve</td> <td></td> <td>false</td> <td>If true, show secret or configmap references when listing variables </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-image-em-"><em>image</em></h2> <blockquote class="code-block example"> <p> Set a deployment&#39;s nginx container image to &#39;nginx:1.9.1&#39;, and its busybox container image to &#39;busybox&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> image deployment/nginx <span class="hljs-attribute">busybox</span>=busybox <span class="hljs-attribute">nginx</span>=nginx:1.9.1 </code></pre> <blockquote class="code-block example"> <p> Update all deployments&#39; and rc&#39;s nginx container&#39;s image to &#39;nginx:1.9.1&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> image deployments,rc <span class="hljs-attribute">nginx</span>=nginx:1.9.1 --all </code></pre> <blockquote class="code-block example"> <p> Update image of all containers of daemonset abc to &#39;nginx:1.9.1&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">set</span> image daemonset abc *=nginx:<span class="hljs-number">1.9</span><span class="hljs-number">.1</span> </code></pre> <blockquote class="code-block example"> <p> Print result (in yaml format) of updating nginx container image from local file, without hitting the server</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> image -f path/<span class="hljs-keyword">to</span>/file.yaml <span class="hljs-attribute">nginx</span>=nginx:1.9.1 --local -o yaml </code></pre> <p>Update existing container image(s) of resources.</p> <p> Possible resources include (case insensitive):</p> <p> pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs)</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl set image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources, including uninitialized ones, in the namespace of the specified resource types </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-set</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, set image will NOT contact api-server but run locally. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, not including uninitialized ones, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-resources-em-"><em>resources</em></h2> <blockquote class="code-block example"> <p> Set a deployments nginx container cpu limits to &quot;200m&quot; and memory to &quot;512Mi&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> resources deployment nginx <span class="hljs-attribute">-c</span>=nginx <span class="hljs-attribute">--limits</span>=cpu=200m,memory=512Mi </code></pre> <blockquote class="code-block example"> <p> Set the resource request and limits for all containers in nginx</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> resources deployment nginx <span class="hljs-attribute">--limits</span>=cpu=200m,memory=512Mi <span class="hljs-attribute">--requests</span>=cpu=100m,memory=256Mi </code></pre> <blockquote class="code-block example"> <p> Remove the resource requests for resources on containers in nginx</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> resources deployment nginx <span class="hljs-attribute">--limits</span>=cpu=0,memory=0 <span class="hljs-attribute">--requests</span>=cpu=0,memory=0 </code></pre> <blockquote class="code-block example"> <p> Print the result (in yaml format) of updating nginx container limits from a local, without hitting the server</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> resources -f path/<span class="hljs-keyword">to</span>/file.yaml <span class="hljs-attribute">--limits</span>=cpu=200m,memory=512Mi --local -o yaml </code></pre> <p>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.</p> <p> For each compute resource, if a limit is specified and a request is omitted, the request will default to the limit.</p> <p> Possible resources include (case insensitive): Use &quot;kubectl api-resources&quot; for a complete list of supported resources..</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl set resources (-f FILENAME | TYPE NAME) ([--limits=LIMITS &amp; --requests=REQUESTS]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources, including uninitialized ones, in the namespace of the specified resource types </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>containers</td> <td>c</td> <td>*</td> <td>The names of containers in the selected pod templates to change, all containers are selected by default - may use wildcards </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-set</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>limits</td> <td></td> <td></td> <td>The resource requirement requests for this container. For example, &#39;cpu=100m,memory=256Mi&#39;. Note that server side components may assign requests depending on the server configuration, such as limit ranges. </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, set resources will NOT contact api-server but run locally. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>requests</td> <td></td> <td></td> <td>The resource requirement requests for this container. For example, &#39;cpu=100m,memory=256Mi&#39;. Note that server side components may assign requests depending on the server configuration, such as limit ranges. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, not including uninitialized ones,supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-selector-em-"><em>selector</em></h2> <blockquote class="code-block example"> <p> Set the labels and selector before creating a deployment/service pair</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create<span class="hljs-built_in"> service </span>clusterip my-svc <span class="hljs-attribute">--clusterip</span>=<span class="hljs-string">"None"</span> -o yaml <span class="hljs-attribute">--dry-run</span>=client | kubectl <span class="hljs-builtin-name">set</span> selector --local -f - <span class="hljs-string">'environment=qa'</span> -o yaml | kubectl create -f - kubectl create deployment my-dep -o yaml <span class="hljs-attribute">--dry-run</span>=client | kubectl label --local -f - <span class="hljs-attribute">environment</span>=qa -o yaml | kubectl create -f - </code></pre> <p>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 &#39;set selector&#39;.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl set selector (-f FILENAME | TYPE NAME) EXPRESSIONS [--resource-version=version]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources in the namespace of the specified resource types </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-set</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>identifying the resource. </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, annotation will NOT contact api-server but run locally. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>true</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>resource-version</td> <td></td> <td></td> <td>If 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. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-serviceaccount-em--1"><em>serviceaccount</em></h2> <blockquote class="code-block example"> <p> Set deployment nginx-deployment&#39;s service account to serviceaccount1</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">set</span> serviceaccount <span class="hljs-comment">deployment nginx-deployment serviceaccount1</span> </code></pre> <blockquote class="code-block example"> <p> Print the result (in YAML format) of updated nginx deployment with the service account from local file, without hitting the API server</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> sa -f nginx-deployment.yaml serviceaccount1 --local <span class="hljs-attribute">--dry-run</span>=client -o yaml </code></pre> <p>Update the service account of pod template resources.</p> <p> Possible resources (case insensitive) can be:</p> <p> replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl set serviceaccount (-f FILENAME | TYPE NAME) SERVICE_ACCOUNT</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources, including uninitialized ones, in the namespace of the specified resource types </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-set</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to get from a server. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, set serviceaccount will NOT contact api-server but run locally. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>record</td> <td></td> <td>false</td> <td>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 already exists. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-subject-em-"><em>subject</em></h2> <blockquote class="code-block example"> <p> Update a cluster role binding for serviceaccount1</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> subject clusterrolebinding admin <span class="hljs-attribute">--serviceaccount</span>=namespace:serviceaccount1 </code></pre> <blockquote class="code-block example"> <p> Update a role binding for user1, user2, and group1</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">set</span> subject rolebinding admin <span class="hljs-attribute">--user</span>=user1 <span class="hljs-attribute">--user</span>=user2 <span class="hljs-attribute">--group</span>=group1 </code></pre> <blockquote class="code-block example"> <p> Print the result (in YAML format) of updating rolebinding subjects from a local, without hitting the server</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl create rolebinding admin <span class="hljs-attribute">--role</span>=admin <span class="hljs-attribute">--user</span>=admin -o yaml <span class="hljs-attribute">--dry-run</span>=client | kubectl <span class="hljs-builtin-name">set</span> subject --local -f - <span class="hljs-attribute">--user</span>=foo -o yaml </code></pre> <p>Update the user, group, or service account in a role binding or cluster role binding.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl set subject (-f FILENAME | TYPE NAME) [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run=server|client|none]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources, including uninitialized ones, in the namespace of the specified resource types </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-set</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files the resource to update the subjects </td> </tr> <tr> <td>group</td> <td></td> <td>[]</td> <td>Groups to bind to the role </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, set subject will NOT contact api-server but run locally. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, not including uninitialized ones, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>serviceaccount</td> <td></td> <td>[]</td> <td>Service accounts to bind to the role </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h1 id="wait">wait</h1> <blockquote class="code-block example"> <p> Wait for the pod &quot;busybox1&quot; to contain the status condition of type &quot;Ready&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">wait</span> <span class="hljs-comment">--for=condition=Ready pod/busybox1</span> </code></pre> <blockquote class="code-block example"> <p> The default value of status condition is true; you can set it to false</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">wait</span> --<span class="hljs-keyword">for</span>=condition=Ready=<span class="hljs-literal">false</span> pod/busybox1 </code></pre> <blockquote class="code-block example"> <p> Wait for the pod &quot;busybox1&quot; to be deleted, with a timeout of 60s, after having issued the &quot;delete&quot; command</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl delete pod/busybox1 kubectl wait <span class="hljs-attribute">--for</span>=delete pod/busybox1 <span class="hljs-attribute">--timeout</span>=60s </code></pre> <p>Experimental: Wait for a specific condition on one or many resources.</p> <p> The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resource.</p> <p> Alternatively, the command can wait for the given set of resources to be deleted by providing the &quot;delete&quot; keyword as the value to the --for flag.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl wait ([-f FILENAME] | resource.group/resource.name | resource.group [(-l label | --all)]) [--for=delete|--for condition=available]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all resources in the namespace of the specified resource types </td> </tr> <tr> <td>all-namespaces</td> <td>A</td> <td>false</td> <td>If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>field-selector</td> <td></td> <td></td> <td>Selector (field query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>identifying the resource. </td> </tr> <tr> <td>for</td> <td></td> <td></td> <td>The condition to wait on: <span>[</span>delete&#124;condition=condition-name<span>]</span>. The default status value of condition-name is true, you can set false with condition=condition-name=false </td> </tr> <tr> <td>local</td> <td></td> <td>false</td> <td>If true, annotation will NOT contact api-server but run locally. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>true</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>timeout</td> <td></td> <td>30s</td> <td>The length of time to wait before giving up. Zero means check once and don&#39;t wait, negative means wait for a week. </td> </tr> </tbody> </table> <h1 id="-strong-working-with-apps-strong-"><strong>WORKING WITH APPS</strong></h1> <p>This section contains commands for inspecting and debugging your applications.</p> <ul> <li><code>logs</code> will print the logs from the specified pod + container.</li> <li><code>exec</code> can be used to get an interactive shell on a pod + container.</li> <li><code>describe</code> will print debug information about the given resource.</li> </ul> <hr> <h1 id="attach">attach</h1> <blockquote class="code-block example"> <p> Get output from running pod mypod; use the &#39;kubectl.kubernetes.io/default-container&#39; annotation # for selecting the container to be attached or the first container in the pod will be chosen</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">attach</span> mypod </code></pre> <blockquote class="code-block example"> <p> Get output from ruby-container from pod mypod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">attach</span> mypod -c ruby-container </code></pre> <blockquote class="code-block example"> <p> Switch to raw terminal mode; sends stdin to &#39;bash&#39; in ruby-container from pod mypod # and sends stdout/stderr from &#39;bash&#39; back to the client</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">attach</span> mypod -c ruby-container -i -t </code></pre> <blockquote class="code-block example"> <p> Get output from the first pod of a replica set named nginx</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">attach</span> rs/nginx </code></pre> <p>Attach to a process that is already running inside an existing container.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl attach (POD | TYPE/NAME) -c CONTAINER</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>container</td> <td>c</td> <td></td> <td>Container 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 </td> </tr> <tr> <td>pod-running-timeout</td> <td></td> <td>1m0s</td> <td>The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running </td> </tr> <tr> <td>quiet</td> <td>q</td> <td>false</td> <td>Only print output from the remote session </td> </tr> <tr> <td>stdin</td> <td>i</td> <td>false</td> <td>Pass stdin to the container </td> </tr> <tr> <td>tty</td> <td>t</td> <td>false</td> <td>Stdin is a TTY </td> </tr> </tbody> </table> <hr> <h1 id="auth">auth</h1> <p>Inspect authorization</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl auth</code></p> <hr> <h2 id="-em-can-i-em-"><em>can-i</em></h2> <blockquote class="code-block example"> <p> Check to see if I can create pods in any namespace</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl auth can-i <span class="hljs-built_in">create</span> pods <span class="hljs-comment">--all-namespaces</span> </code></pre> <blockquote class="code-block example"> <p> Check to see if I can list deployments in my current namespace</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl auth can-i <span class="hljs-built_in">list</span> deployments.apps </code></pre> <blockquote class="code-block example"> <p> Check to see if I can do everything in my current namespace (&quot;*&quot; means all)</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl auth can-<span class="hljs-built_in">i</span> <span class="hljs-string">'*'</span> <span class="hljs-string">'*'</span> </code></pre> <blockquote class="code-block example"> <p> Check to see if I can get the job named &quot;bar&quot; in namespace &quot;foo&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl auth can-i <span class="hljs-built_in">list</span> jobs.batch/bar -n foo </code></pre> <blockquote class="code-block example"> <p> Check to see if I can read pod logs</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl auth can-i <span class="hljs-builtin-name">get</span> pods <span class="hljs-attribute">--subresource</span>=log </code></pre> <blockquote class="code-block example"> <p> Check to see if I can access the URL /logs/</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl auth can-i <span class="hljs-builtin-name">get</span> /logs/ </code></pre> <blockquote class="code-block example"> <p> List all allowed actions in namespace &quot;foo&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl auth can-i --list --<span class="hljs-keyword">namespace</span>=<span class="hljs-symbol">foo</span> </code></pre> <p>Check whether an action is allowed.</p> <p> VERB is a logical Kubernetes API verb like &#39;get&#39;, &#39;list&#39;, &#39;watch&#39;, &#39;delete&#39;, etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL that starts with &quot;/&quot;. NAME is the name of a particular Kubernetes resource.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl auth can-i VERB [TYPE | TYPE/NAME | NONRESOURCEURL]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all-namespaces</td> <td>A</td> <td>false</td> <td>If true, check the specified action in all namespaces. </td> </tr> <tr> <td>list</td> <td></td> <td>false</td> <td>If true, prints all allowed actions. </td> </tr> <tr> <td>no-headers</td> <td></td> <td>false</td> <td>If true, prints allowed actions without headers </td> </tr> <tr> <td>quiet</td> <td>q</td> <td>false</td> <td>If true, suppress output and just return the exit code. </td> </tr> <tr> <td>subresource</td> <td></td> <td></td> <td>SubResource such as pod/log or deployment/scale </td> </tr> </tbody> </table> <hr> <h2 id="-em-reconcile-em-"><em>reconcile</em></h2> <blockquote class="code-block example"> <p> Reconcile RBAC resources from a file</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl auth reconcile -f <span class="hljs-keyword">my</span>-rbac-rules.yaml </code></pre> <p>Reconciles rules for RBAC role, role binding, cluster role, and cluster role binding objects.</p> <p> Missing objects are created, and the containing namespace is created for namespaced objects, if required.</p> <p> Existing roles are updated to include the permissions in the input objects, and remove extra permissions if --remove-extra-permissions is specified.</p> <p> Existing bindings are updated to include the subjects in the input objects, and remove extra subjects if --remove-extra-subjects is specified.</p> <p> This is preferred to &#39;apply&#39; for RBAC resources so that semantically-aware merging of rules and subjects is done.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl auth reconcile -f FILENAME</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to reconcile. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>remove-extra-permissions</td> <td></td> <td>false</td> <td>If true, removes extra permissions added to roles </td> </tr> <tr> <td>remove-extra-subjects</td> <td></td> <td>false</td> <td>If true, removes extra subjects added to rolebindings </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h1 id="cp">cp</h1> <blockquote class="code-block example"> <p> !!!Important Note!!! # Requires that the &#39;tar&#39; binary is present in your container # image. If &#39;tar&#39; is not present, &#39;kubectl cp&#39; will fail. # # For advanced use cases, such as symlinks, wildcard expansion or # file mode preservation, consider using &#39;kubectl exec&#39;. # Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace></p> </blockquote> <pre class="code-block example"><code class="lang-shell">tar cf - <span class="hljs-meta-keyword">/tmp/</span>foo | kubectl exec -i -n <span class="hljs-params">&lt;some-namespace&gt;</span> <span class="hljs-params">&lt;some-pod&gt;</span> -- tar xf - -C <span class="hljs-meta-keyword">/tmp/</span>bar </code></pre> <blockquote class="code-block example"> <p> Copy /tmp/foo from a remote pod to /tmp/bar locally</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl exec -n <span class="hljs-params">&lt;some-namespace&gt;</span> <span class="hljs-params">&lt;some-pod&gt;</span> -- tar cf - <span class="hljs-meta-keyword">/tmp/</span>foo | tar xf - -C <span class="hljs-meta-keyword">/tmp/</span>bar </code></pre> <blockquote class="code-block example"> <p> Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl cp /tmp/foo_dir &lt;some-pod&gt;<span class="hljs-symbol">:/tmp/bar_dir</span> </code></pre> <blockquote class="code-block example"> <p> Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl cp <span class="hljs-meta-keyword">/tmp/</span>foo <span class="hljs-params">&lt;some-pod&gt;</span>:<span class="hljs-meta-keyword">/tmp/</span>bar -c <span class="hljs-params">&lt;specific-container&gt;</span> </code></pre> <blockquote class="code-block example"> <p> Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace></p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl cp <span class="hljs-meta-keyword">/tmp/</span>foo <span class="hljs-params">&lt;some-namespace&gt;</span>/<span class="hljs-params">&lt;some-pod&gt;</span>:<span class="hljs-meta-keyword">/tmp/</span>bar </code></pre> <blockquote class="code-block example"> <p> Copy /tmp/foo from a remote pod to /tmp/bar locally</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl cp <span class="hljs-params">&lt;some-namespace&gt;</span>/<span class="hljs-params">&lt;some-pod&gt;</span>:<span class="hljs-meta-keyword">/tmp/</span>foo <span class="hljs-meta-keyword">/tmp/</span>bar </code></pre> <p>Copy files and directories to and from containers.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl cp &lt;file-spec-src&gt; &lt;file-spec-dest&gt;</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>container</td> <td>c</td> <td></td> <td>Container 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 </td> </tr> <tr> <td>no-preserve</td> <td></td> <td>false</td> <td>The copied file/directory&#39;s ownership and permissions will not be preserved in the container </td> </tr> </tbody> </table> <hr> <h1 id="describe">describe</h1> <blockquote class="code-block example"> <p> Describe a node</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl describe nodes kubernetes-<span class="hljs-keyword">node</span><span class="hljs-title">-emt8</span>.c.myproject.internal </code></pre> <blockquote class="code-block example"> <p> Describe a pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">describe</span> pods/nginx </code></pre> <blockquote class="code-block example"> <p> Describe a pod identified by type and name in &quot;pod.json&quot;</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-selector-tag">kubectl</span> <span class="hljs-selector-tag">describe</span> <span class="hljs-selector-tag">-f</span> <span class="hljs-selector-tag">pod</span><span class="hljs-selector-class">.json</span> </code></pre> <blockquote class="code-block example"> <p> Describe all pods</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl describe pods</span> </code></pre> <blockquote class="code-block example"> <p> Describe pods by label name=myLabel</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl describe po -l <span class="hljs-attribute">name</span>=myLabel </code></pre> <blockquote class="code-block example"> <p> Describe all pods managed by the &#39;frontend&#39; replication controller (rc-created pods # get the name of the rc as a prefix in the pod the name)</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl describe pods frontend</span> </code></pre> <p>Show details of a specific resource or group of resources.</p> <p> 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:</p> <p> $ kubectl describe TYPE NAME_PREFIX</p> <p> 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.</p> <p>Use &quot;kubectl api-resources&quot; for a complete list of supported resources.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl describe (-f FILENAME | TYPE [NAME_PREFIX | -l label] | TYPE/NAME)</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all-namespaces</td> <td>A</td> <td>false</td> <td>If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. </td> </tr> <tr> <td>chunk-size</td> <td></td> <td>500</td> <td>Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may change in the future. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files containing the resource to describe </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>show-events</td> <td></td> <td>true</td> <td>If true, display events related to the described object. </td> </tr> </tbody> </table> <hr> <h1 id="exec">exec</h1> <blockquote class="code-block example"> <p> Get output from running the &#39;date&#39; command from pod mypod, using the first container by default</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">exec</span> mypod -- <span class="hljs-built_in">date</span> </code></pre> <blockquote class="code-block example"> <p> Get output from running the &#39;date&#39; command in ruby-container from pod mypod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">exec</span> mypod -c ruby-<span class="hljs-keyword">container</span> -- <span class="hljs-keyword">date</span> </code></pre> <blockquote class="code-block example"> <p> Switch to raw terminal mode; sends stdin to &#39;bash&#39; in ruby-container from pod mypod # and sends stdout/stderr from &#39;bash&#39; back to the client</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">exec</span> mypod -c ruby-<span class="hljs-keyword">container</span> -i -t -- bash -il </code></pre> <blockquote class="code-block example"> <p> 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&#39;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 &quot;ls -t /usr&quot;)</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl exec mypod -i -<span class="hljs-built_in">t</span> -- ls -<span class="hljs-built_in">t</span> /usr </code></pre> <blockquote class="code-block example"> <p> Get output from running &#39;date&#39; command from the first pod of the deployment mydeployment, using the first container by default</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">exec</span> deploy/mydeployment -- <span class="hljs-built_in">date</span> </code></pre> <blockquote class="code-block example"> <p> Get output from running &#39;date&#39; command from the first pod of the service myservice, using the first container by default</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">exec</span> svc/myservice -- <span class="hljs-built_in">date</span> </code></pre> <p>Execute a command in a container.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>container</td> <td>c</td> <td></td> <td>Container 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 </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>to use to exec into the resource </td> </tr> <tr> <td>pod-running-timeout</td> <td></td> <td>1m0s</td> <td>The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running </td> </tr> <tr> <td>quiet</td> <td>q</td> <td>false</td> <td>Only print output from the remote session </td> </tr> <tr> <td>stdin</td> <td>i</td> <td>false</td> <td>Pass stdin to the container </td> </tr> <tr> <td>tty</td> <td>t</td> <td>false</td> <td>Stdin is a TTY </td> </tr> </tbody> </table> <hr> <h1 id="logs">logs</h1> <blockquote class="code-block example"> <p> Return snapshot logs from pod nginx with only one container</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl logs nginx</span> </code></pre> <blockquote class="code-block example"> <p> Return snapshot logs from pod nginx with multi containers</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs nginx --<span class="hljs-built_in">all</span>-containers=<span class="hljs-literal">true</span> </code></pre> <blockquote class="code-block example"> <p> Return snapshot logs from all containers in pods defined by label app=nginx</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs -l <span class="hljs-attribute">app</span>=nginx <span class="hljs-attribute">--all-containers</span>=<span class="hljs-literal">true</span> </code></pre> <blockquote class="code-block example"> <p> Return snapshot of previous terminated ruby container logs from pod web-1</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs -p -c ruby web<span class="hljs-number">-1</span> </code></pre> <blockquote class="code-block example"> <p> Begin streaming the logs of the ruby container in pod web-1</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs -f -c ruby web<span class="hljs-number">-1</span> </code></pre> <blockquote class="code-block example"> <p> Begin streaming the logs from all containers in pods defined by label app=nginx</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs -f -l <span class="hljs-attribute">app</span>=nginx <span class="hljs-attribute">--all-containers</span>=<span class="hljs-literal">true</span> </code></pre> <blockquote class="code-block example"> <p> Display only the most recent 20 lines of output in pod nginx</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs <span class="hljs-attribute">--tail</span>=20 nginx </code></pre> <blockquote class="code-block example"> <p> Show all logs from pod nginx written in the last hour</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs <span class="hljs-attribute">--since</span>=1h nginx </code></pre> <blockquote class="code-block example"> <p> Show logs from a kubelet with an expired serving certificate</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs <span class="hljs-comment">--insecure-skip-tls-verify-backend nginx</span> </code></pre> <blockquote class="code-block example"> <p> Return snapshot logs from first container of a job named hello</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs <span class="hljs-keyword">job</span>/hello </code></pre> <blockquote class="code-block example"> <p> Return snapshot logs from container nginx-1 of a deployment named nginx</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl logs deployment/nginx -c nginx<span class="hljs-number">-1</span> </code></pre> <p>Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all-containers</td> <td></td> <td>false</td> <td>Get all containers&#39; logs in the pod(s). </td> </tr> <tr> <td>container</td> <td>c</td> <td></td> <td>Print the logs of this container </td> </tr> <tr> <td>follow</td> <td>f</td> <td>false</td> <td>Specify if the logs should be streamed. </td> </tr> <tr> <td>ignore-errors</td> <td></td> <td>false</td> <td>If watching / following pod logs, allow for any errors that occur to be non-fatal </td> </tr> <tr> <td>insecure-skip-tls-verify-backend</td> <td></td> <td>false</td> <td>Skip 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. </td> </tr> <tr> <td>limit-bytes</td> <td></td> <td>0</td> <td>Maximum bytes of logs to return. Defaults to no limit. </td> </tr> <tr> <td>max-log-requests</td> <td></td> <td>5</td> <td>Specify maximum number of concurrent logs to follow when using by a selector. Defaults to 5. </td> </tr> <tr> <td>pod-running-timeout</td> <td></td> <td>20s</td> <td>The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running </td> </tr> <tr> <td>prefix</td> <td></td> <td>false</td> <td>Prefix each log line with the log source (pod name and container name) </td> </tr> <tr> <td>previous</td> <td>p</td> <td>false</td> <td>If true, print the logs for the previous instance of the container in a pod if it exists. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on. </td> </tr> <tr> <td>since</td> <td></td> <td>0s</td> <td>Only 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. </td> </tr> <tr> <td>since-time</td> <td></td> <td></td> <td>Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used. </td> </tr> <tr> <td>tail</td> <td></td> <td>-1</td> <td>Lines of recent log file to display. Defaults to -1 with no selector, showing all log lines otherwise 10, if a selector is provided. </td> </tr> <tr> <td>timestamps</td> <td></td> <td>false</td> <td>Include timestamps on each line in the log output </td> </tr> </tbody> </table> <hr> <h1 id="port-forward">port-forward</h1> <blockquote class="code-block example"> <p> Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl port-forward pod/mypod <span class="hljs-number">5000</span> <span class="hljs-number">6000</span> </code></pre> <blockquote class="code-block example"> <p> Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl port-forward deployment/mydeployment <span class="hljs-number">5000</span> <span class="hljs-number">6000</span> </code></pre> <blockquote class="code-block example"> <p> Listen on port 8443 locally, forwarding to the targetPort of the service&#39;s port named &quot;https&quot; in a pod selected by the service</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl port-forward service/myservice <span class="hljs-number">8443</span>:https </code></pre> <blockquote class="code-block example"> <p> Listen on port 8888 locally, forwarding to 5000 in the pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl port-forward pod/mypod <span class="hljs-number">8888</span>:<span class="hljs-number">5000</span> </code></pre> <blockquote class="code-block example"> <p> Listen on port 8888 on all addresses, forwarding to 5000 in the pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl port-forward --address <span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span> pod/mypod <span class="hljs-number">8888</span>:<span class="hljs-number">5000</span> </code></pre> <blockquote class="code-block example"> <p> Listen on port 8888 on localhost and selected IP, forwarding to 5000 in the pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl port-forward --address localhost,<span class="hljs-number">10.19</span><span class="hljs-number">.21</span><span class="hljs-number">.23</span> pod/mypod <span class="hljs-number">8888</span>:<span class="hljs-number">5000</span> </code></pre> <blockquote class="code-block example"> <p> Listen on a random port locally, forwarding to 5000 in the pod</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl port-forward pod/mypod :<span class="hljs-number">5000</span> </code></pre> <p>Forward one or more local ports to a pod.</p> <p> Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to &#39;pod&#39; if omitted.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl port-forward TYPE/NAME [options] [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>address</td> <td></td> <td>[localhost]</td> <td>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. </td> </tr> <tr> <td>pod-running-timeout</td> <td></td> <td>1m0s</td> <td>The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running </td> </tr> </tbody> </table> <hr> <h1 id="proxy">proxy</h1> <blockquote class="code-block example"> <p> To proxy all of the Kubernetes API and nothing else</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> proxy </span><span class="hljs-attribute">--api-prefix</span>=/ </code></pre> <blockquote class="code-block example"> <p> To proxy only part of the Kubernetes API and also some static files # You can get pods info with &#39;curl localhost:8001/api/v1/pods&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> proxy </span><span class="hljs-attribute">--www</span>=/my/files <span class="hljs-attribute">--www-prefix</span>=/static/ <span class="hljs-attribute">--api-prefix</span>=/api/ </code></pre> <blockquote class="code-block example"> <p> To proxy the entire Kubernetes API at a different root # You can get pods info with &#39;curl localhost:8001/custom/api/v1/pods&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> proxy </span><span class="hljs-attribute">--api-prefix</span>=/custom/ </code></pre> <blockquote class="code-block example"> <p> Run a proxy to the Kubernetes API server on port 8011, serving static content from ./local/www/</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> proxy </span><span class="hljs-attribute">--port</span>=8011 <span class="hljs-attribute">--www</span>=./local/www/ </code></pre> <blockquote class="code-block example"> <p> Run a proxy to the Kubernetes API server on an arbitrary local port # The chosen port for the server will be output to stdout</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> proxy </span><span class="hljs-attribute">--port</span>=0 </code></pre> <blockquote class="code-block example"> <p> 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/</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> proxy </span><span class="hljs-attribute">--api-prefix</span>=/k8s-api </code></pre> <p>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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>accept-hosts</td> <td></td> <td>^localhost$,^127.0.0.1$,^[::1]$</td> <td>Regular expression for hosts that the proxy should accept. </td> </tr> <tr> <td>accept-paths</td> <td></td> <td>^.*</td> <td>Regular expression for paths that the proxy should accept. </td> </tr> <tr> <td>address</td> <td></td> <td>127.0.0.1</td> <td>The IP address on which to serve on. </td> </tr> <tr> <td>api-prefix</td> <td></td> <td>/</td> <td>Prefix to serve the proxied API under. </td> </tr> <tr> <td>disable-filter</td> <td></td> <td>false</td> <td>If true, disable request filtering in the proxy. This is dangerous, and can leave you vulnerable to XSRF attacks, when used with an accessible port. </td> </tr> <tr> <td>keepalive</td> <td></td> <td>0s</td> <td>keepalive specifies the keep-alive period for an active network connection. Set to 0 to disable keepalive. </td> </tr> <tr> <td>port</td> <td>p</td> <td>8001</td> <td>The port on which to run the proxy. Set to 0 to pick a random port. </td> </tr> <tr> <td>reject-methods</td> <td></td> <td>^$</td> <td>Regular expression for HTTP methods that the proxy should reject (example --reject-methods=&#39;POST,PUT,PATCH&#39;). </td> </tr> <tr> <td>reject-paths</td> <td></td> <td>^/api/.<em>/pods/.</em>/exec,^/api/.<em>/pods/.</em>/attach</td> <td>Regular expression for paths that the proxy should reject. Paths specified here will be rejected even accepted by --accept-paths. </td> </tr> <tr> <td>unix-socket</td> <td>u</td> <td></td> <td>Unix socket on which to run the proxy. </td> </tr> <tr> <td>www</td> <td>w</td> <td></td> <td>Also serve static files from the given directory under the specified prefix. </td> </tr> <tr> <td>www-prefix</td> <td>P</td> <td>/static/</td> <td>Prefix to serve static files under, if static file directory is specified. </td> </tr> </tbody> </table> <hr> <h1 id="top">top</h1> <p>Display Resource (CPU/Memory) usage.</p> <p> The top command allows you to see the resource consumption for nodes or pods.</p> <p> This command requires Metrics Server to be correctly configured and working on the server.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl top</code></p> <hr> <h2 id="-em-node-em-"><em>node</em></h2> <blockquote class="code-block example"> <p> Show metrics for all nodes</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl top <span class="hljs-keyword">node</span><span class="hljs-title"></span> </code></pre> <blockquote class="code-block example"> <p> Show metrics for a given node</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl top <span class="hljs-keyword">node</span> <span class="hljs-title">NODE_NAME</span> </code></pre> <p>Display resource (CPU/memory) usage of nodes.</p> <p> The top-node command allows you to see the resource consumption of nodes.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl top node [NAME | -l label]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>no-headers</td> <td></td> <td>false</td> <td>If present, print output without headers </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>sort-by</td> <td></td> <td></td> <td>If non-empty, sort nodes list using specified field. The field can be either &#39;cpu&#39; or &#39;memory&#39;. </td> </tr> <tr> <td>use-protocol-buffers</td> <td></td> <td>true</td> <td>Enables using protocol-buffers to access Metrics API. </td> </tr> </tbody> </table> <hr> <h2 id="-em-pod-em-"><em>pod</em></h2> <blockquote class="code-block example"> <p> Show metrics for all pods in the default namespace</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">top</span> pod </code></pre> <blockquote class="code-block example"> <p> Show metrics for all pods in the given namespace</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl top pod --<span class="hljs-keyword">namespace</span>=<span class="hljs-symbol">NAMESPACE</span> </code></pre> <blockquote class="code-block example"> <p> Show metrics for a given pod and its containers</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl top pod POD_NAME <span class="hljs-comment">--containers</span> </code></pre> <blockquote class="code-block example"> <p> Show metrics for the pods defined by label name=myLabel</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl top pod -l <span class="hljs-attribute">name</span>=myLabel </code></pre> <p>Display resource (CPU/memory) usage of pods.</p> <p> The &#39;top pod&#39; command allows you to see the resource consumption of pods.</p> <p> Due to the metrics pipeline delay, they may be unavailable for a few minutes since pod creation.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl top pod [NAME | -l label]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all-namespaces</td> <td>A</td> <td>false</td> <td>If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. </td> </tr> <tr> <td>containers</td> <td></td> <td>false</td> <td>If present, print usage of containers within a pod. </td> </tr> <tr> <td>field-selector</td> <td></td> <td></td> <td>Selector (field query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </td> </tr> <tr> <td>no-headers</td> <td></td> <td>false</td> <td>If present, print output without headers. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>sort-by</td> <td></td> <td></td> <td>If non-empty, sort pods list using specified field. The field can be either &#39;cpu&#39; or &#39;memory&#39;. </td> </tr> <tr> <td>use-protocol-buffers</td> <td></td> <td>true</td> <td>Enables using protocol-buffers to access Metrics API. </td> </tr> </tbody> </table> <h1 id="-strong-cluster-management-strong-"><strong>CLUSTER MANAGEMENT</strong></h1> <hr> <h1 id="api-versions">api-versions</h1> <blockquote class="code-block example"> <p> Print the supported API versions</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl api-versions</span> </code></pre> <p>Print the supported API versions on the server, in the form of &quot;group/version&quot;.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl api-versions</code></p> <hr> <h1 id="certificate">certificate</h1> <p>Modify certificate resources.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl certificate SUBCOMMAND</code></p> <hr> <h2 id="-em-approve-em-"><em>approve</em></h2> <blockquote class="code-block example"> <p> Approve CSR &#39;csr-sqgzp&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl certificate approve csr-sqgzp</span> </code></pre> <p>Approve a certificate signing request.</p> <p> 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.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl certificate approve (-f FILENAME | NAME)</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to update </td> </tr> <tr> <td>force</td> <td></td> <td>false</td> <td>Update the CSR even if it is already approved. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h2 id="-em-deny-em-"><em>deny</em></h2> <blockquote class="code-block example"> <p> Deny CSR &#39;csr-sqgzp&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl certificate <span class="hljs-keyword">deny</span> csr-sqgzp </code></pre> <p>Deny a certificate signing request.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl certificate deny (-f FILENAME | NAME)</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>filename</td> <td>f</td> <td>[]</td> <td>Filename, directory, or URL to files identifying the resource to update </td> </tr> <tr> <td>force</td> <td></td> <td>false</td> <td>Update the CSR even if it is already denied. </td> </tr> <tr> <td>kustomize</td> <td>k</td> <td></td> <td>Process the kustomization directory. This flag can&#39;t be used together with -f or -R. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>recursive</td> <td>R</td> <td>false</td> <td>Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h1 id="cluster-info">cluster-info</h1> <blockquote class="code-block example"> <p> Print the address of the control plane and cluster services</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl</span> cluster-<span class="hljs-literal">info</span> </code></pre> <p>Display addresses of the control plane and services with label kubernetes.io/cluster-service=true. To further debug and diagnose cluster problems, use &#39;kubectl cluster-info dump&#39;.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl cluster-info</code></p> <hr> <h2 id="-em-dump-em-"><em>dump</em></h2> <blockquote class="code-block example"> <p> Dump current cluster state to stdout</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl</span> cluster-<span class="hljs-literal">info</span> dump </code></pre> <blockquote class="code-block example"> <p> Dump current cluster state to /path/to/cluster-state</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl cluster-<span class="hljs-builtin-name">info</span> dump <span class="hljs-attribute">--output-directory</span>=/path/to/cluster-state </code></pre> <blockquote class="code-block example"> <p> Dump all namespaces to stdout</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">cluster</span>-<span class="hljs-keyword">info</span> dump <span class="hljs-comment">--all-namespaces</span> </code></pre> <blockquote class="code-block example"> <p> Dump a set of namespaces to /path/to/cluster-state</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">cluster</span>-info dump --namespaces <span class="hljs-keyword">default</span>,kube-<span class="hljs-keyword">system</span> --output-directory=/path/to/<span class="hljs-keyword">cluster</span>-state </code></pre> <p>Dump cluster information out suitable for debugging and diagnosing cluster problems. By default, dumps everything to stdout. You can optionally specify a directory with --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 &#39;kube-system&#39; namespace, but you can switch to a different namespace with the --namespaces flag, or specify --all-namespaces to dump all namespaces.</p> <p> 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.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl cluster-info dump</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all-namespaces</td> <td>A</td> <td>false</td> <td>If true, dump all namespaces. If true, --namespaces is ignored. </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>namespaces</td> <td></td> <td>[]</td> <td>A comma separated list of namespaces to dump. </td> </tr> <tr> <td>output</td> <td>o</td> <td>json</td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>output-directory</td> <td></td> <td></td> <td>Where to output the files. If empty or &#39;-&#39; uses stdout, otherwise creates a directory hierarchy in that directory </td> </tr> <tr> <td>pod-running-timeout</td> <td></td> <td>20s</td> <td>The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h1 id="cordon">cordon</h1> <blockquote class="code-block example"> <p> Mark node &quot;foo&quot; as unschedulable</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl cordon foo</span> </code></pre> <p>Mark node as unschedulable.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl cordon NODE</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on </td> </tr> </tbody> </table> <hr> <h1 id="drain">drain</h1> <blockquote class="code-block example"> <p> Drain node &quot;foo&quot;, even if there are pods not managed by a replication controller, replica set, job, daemon set or stateful set on it</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl drain foo <span class="hljs-comment">--force</span> </code></pre> <blockquote class="code-block example"> <p> As above, but abort if there are pods not managed by a replication controller, replica set, job, daemon set or stateful set, and use a grace period of 15 minutes</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl drain foo <span class="hljs-attribute">--grace-period</span>=900 </code></pre> <p>Drain node in preparation for maintenance.</p> <p> The given node will be marked unschedulable to prevent new pods from arriving. &#39;drain&#39; evicts the pods if the API server supports <a href="https://kubernetes.io/docs/concepts/workloads/pods/disruptions/">https://kubernetes.io/docs/concepts/workloads/pods/disruptions/</a> . Otherwise, it will use normal DELETE to delete the pods. The &#39;drain&#39; evicts or deletes all pods except mirror pods (which cannot be deleted through the API server). If there are daemon set-managed pods, drain will not proceed without --ignore-daemonsets, and regardless it will not delete any daemon set-managed pods, because those pods would be immediately replaced by the daemon set controller, which ignores unschedulable markings. If there are any pods that are neither mirror pods nor managed by a replication controller, replica set, daemon set, stateful set, or job, then drain will not delete any pods unless you use --force. --force will also allow deletion to proceed if the managing resource of one or more pods is missing.</p> <p> &#39;drain&#39; waits for graceful termination. You should not operate on the machine until the command completes.</p> <p> When you are ready to put the node back into service, use kubectl uncordon, which will make the node schedulable again.</p> <p> <a href="https://kubernetes.io/images/docs/kubectl_drain.svg">https://kubernetes.io/images/docs/kubectl_drain.svg</a></p> <h3 id="usage">Usage</h3> <p><code>$ kubectl drain NODE</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>chunk-size</td> <td></td> <td>500</td> <td>Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may change in the future. </td> </tr> <tr> <td>delete-emptydir-data</td> <td></td> <td>false</td> <td>Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained). </td> </tr> <tr> <td>delete-local-data</td> <td></td> <td>false</td> <td>Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained). </td> </tr> <tr> <td>disable-eviction</td> <td></td> <td>false</td> <td>Force drain to use delete, even if eviction is supported. This will bypass checking PodDisruptionBudgets, use with caution. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>force</td> <td></td> <td>false</td> <td>Continue even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet. </td> </tr> <tr> <td>grace-period</td> <td></td> <td>-1</td> <td>Period of time in seconds given to each pod to terminate gracefully. If negative, the default value specified in the pod will be used. </td> </tr> <tr> <td>ignore-daemonsets</td> <td></td> <td>false</td> <td>Ignore DaemonSet-managed pods. </td> </tr> <tr> <td>ignore-errors</td> <td></td> <td>false</td> <td>Ignore errors occurred between drain nodes in group. </td> </tr> <tr> <td>pod-selector</td> <td></td> <td></td> <td>Label selector to filter pods on the node </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on </td> </tr> <tr> <td>skip-wait-for-delete-timeout</td> <td></td> <td>0</td> <td>If pod DeletionTimestamp older than N seconds, skip waiting for the pod. Seconds must be greater than 0 to skip. </td> </tr> <tr> <td>timeout</td> <td></td> <td>0s</td> <td>The length of time to wait before giving up, zero means infinite </td> </tr> </tbody> </table> <hr> <h1 id="taint">taint</h1> <blockquote class="code-block example"> <p> Update node &#39;foo&#39; with a taint with key &#39;dedicated&#39; and value &#39;special-user&#39; and effect &#39;NoSchedule&#39; # If a taint with that key and effect already exists, its value is replaced as specified</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl taint nodes foo <span class="hljs-attribute">dedicated</span>=special-user:NoSchedule </code></pre> <blockquote class="code-block example"> <p> Remove from node &#39;foo&#39; the taint with key &#39;dedicated&#39; and effect &#39;NoSchedule&#39; if one exists</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-selector-tag">kubectl</span> <span class="hljs-selector-tag">taint</span> <span class="hljs-selector-tag">nodes</span> <span class="hljs-selector-tag">foo</span> <span class="hljs-selector-tag">dedicated</span><span class="hljs-selector-pseudo">:NoSchedule-</span> </code></pre> <blockquote class="code-block example"> <p> Remove from node &#39;foo&#39; all the taints with key &#39;dedicated&#39;</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl</span> taint nodes foo dedicated- </code></pre> <blockquote class="code-block example"> <p> Add a taint with key &#39;dedicated&#39; on nodes having label mylabel=X</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl taint <span class="hljs-keyword">node</span> <span class="hljs-title">-l</span> <span class="hljs-attr">myLabel=</span>X <span class="hljs-attr">dedicated=</span>foo:PreferNoSchedule </code></pre> <blockquote class="code-block example"> <p> Add to node &#39;foo&#39; a taint with key &#39;bar&#39; and no value</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-selector-tag">kubectl</span> <span class="hljs-selector-tag">taint</span> <span class="hljs-selector-tag">nodes</span> <span class="hljs-selector-tag">foo</span> <span class="hljs-selector-tag">bar</span><span class="hljs-selector-pseudo">:NoSchedule</span> </code></pre> <p>Update the taints on one or more nodes.</p> <ul> <li>A taint consists of a key, value, and effect. As an argument here, it is expressed as key=value:effect.</li> <li>The key must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 253 characters.</li> <li>Optionally, the key can begin with a DNS subdomain prefix and a single &#39;/&#39;, like example.com/my-app.</li> <li>The value is optional. If given, it must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters.</li> <li>The effect must be NoSchedule, PreferNoSchedule or NoExecute.</li> <li>Currently taint can only apply to node.</li> </ul> <h3 id="usage">Usage</h3> <p><code>$ kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>all</td> <td></td> <td>false</td> <td>Select all nodes in the cluster </td> </tr> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>field-manager</td> <td></td> <td>kubectl-taint</td> <td>Name of the manager used to track field ownership. </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>overwrite</td> <td></td> <td>false</td> <td>If true, allow taints to be overwritten, otherwise reject taint updates that overwrite existing taints. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on, supports &#39;=&#39;, &#39;==&#39;, and &#39;!=&#39;.(e.g. -l key1=value1,key2=value2) </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> <tr> <td>validate</td> <td></td> <td>true</td> <td>If true, use a schema to validate the input before sending it </td> </tr> </tbody> </table> <hr> <h1 id="uncordon">uncordon</h1> <blockquote class="code-block example"> <p> Mark node &quot;foo&quot; as schedulable</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl uncordon foo</span> </code></pre> <p>Mark node as schedulable.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl uncordon NODE</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>dry-run</td> <td></td> <td>none</td> <td>Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;. 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. </td> </tr> <tr> <td>selector</td> <td>l</td> <td></td> <td>Selector (label query) to filter on </td> </tr> </tbody> </table> <h1 id="-strong-kubectl-settings-and-usage-strong-"><strong>KUBECTL SETTINGS AND USAGE</strong></h1> <hr> <h1 id="alpha">alpha</h1> <p>These commands correspond to alpha features that are not enabled in Kubernetes clusters by default.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl alpha</code></p> <hr> <h1 id="api-resources">api-resources</h1> <blockquote class="code-block example"> <p> Print the supported API resources</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl api-resources</span> </code></pre> <blockquote class="code-block example"> <p> Print the supported API resources with more information</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl api-resources -o wide</span> </code></pre> <blockquote class="code-block example"> <p> Print the supported API resources sorted by a column</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl api-<span class="hljs-built_in">resources</span> --<span class="hljs-built_in">sort</span>-by=<span class="hljs-built_in">name</span> </code></pre> <blockquote class="code-block example"> <p> Print the supported namespaced resources</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl</span> api-resources --namespaced=<span class="hljs-literal">true</span> </code></pre> <blockquote class="code-block example"> <p> Print the supported non-namespaced resources</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl</span> api-resources --namespaced=<span class="hljs-literal">false</span> </code></pre> <blockquote class="code-block example"> <p> Print the supported API resources with a specific APIGroup</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl api-resources <span class="hljs-attribute">--api-group</span>=extensions </code></pre> <p>Print the supported API resources on the server.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl api-resources</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>api-group</td> <td></td> <td></td> <td>Limit to resources in the specified API group. </td> </tr> <tr> <td>cached</td> <td></td> <td>false</td> <td>Use the cached list of resources if available. </td> </tr> <tr> <td>namespaced</td> <td></td> <td>true</td> <td>If false, non-namespaced resources will be returned, otherwise returning namespaced resources by default. </td> </tr> <tr> <td>no-headers</td> <td></td> <td>false</td> <td>When using the default or custom-column output format, don&#39;t print headers (default print headers). </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: wide&#124;name. </td> </tr> <tr> <td>sort-by</td> <td></td> <td></td> <td>If non-empty, sort list of resources using specified field. The field can be either &#39;name&#39; or &#39;kind&#39;. </td> </tr> <tr> <td>verbs</td> <td></td> <td>[]</td> <td>Limit to resources that support the specified verbs. </td> </tr> </tbody> </table> <hr> <h1 id="completion">completion</h1> <blockquote class="code-block example"> <p> Installing bash completion on macOS using homebrew ## If running Bash 3.2 included with macOS</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-keyword">brew </span><span class="hljs-keyword">install </span><span class="hljs-keyword">bash-completion</span> </code></pre> <blockquote class="code-block example#"> <p> or, if running Bash 4.1+</p> </blockquote> <pre class="code-block example"><code class="lang-shell">brew install bash-<span class="hljs-symbol">completion@</span><span class="hljs-number">2</span> </code></pre> <blockquote class="code-block example#"> <p> If kubectl is installed via homebrew, this should start working immediately ## If you&#39;ve installed via other means, you may need add the completion to your completion directory</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl completion bash &gt; <span class="hljs-constructor">$(<span class="hljs-params">brew</span> --<span class="hljs-params">prefix</span>)</span>/etc/bash_completion.d/kubectl </code></pre> <blockquote class="code-block example"> <p> Installing bash completion on Linux ## If bash-completion is not installed on Linux, install the &#39;bash-completion&#39; package ## via your distribution&#39;s package manager. ## Load the kubectl completion code for bash into the current shell</p> </blockquote> <pre class="code-block example"><code class="lang-shell">source &lt;(<span class="hljs-name">kubectl</span> completion bash) </code></pre> <blockquote class="code-block example#"> <p> Write bash completion code to a file and source it from .bash_profile</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-symbol">kubectl</span> completion <span class="hljs-keyword">bash </span>&gt; ~/.kube/completion.<span class="hljs-keyword">bash.inc </span><span class="hljs-symbol">printf</span> <span class="hljs-string">"</span> </code></pre> <blockquote class="code-block example"> <p> Kubectl shell completion</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">source</span> <span class="hljs-string">'<span class="hljs-variable">$HOME</span>/.kube/completion.bash.inc'</span> <span class="hljs-string">" &gt;&gt; <span class="hljs-variable">$HOME</span>/.bash_profile source <span class="hljs-variable">$HOME</span>/.bash_profile</span> </code></pre> <blockquote class="code-block example"> <p> Load the kubectl completion code for zsh[1] into the current shell</p> </blockquote> <pre class="code-block example"><code class="lang-shell">source &lt;(<span class="hljs-name">kubectl</span> completion zsh) </code></pre> <blockquote class="code-block example"> <p> Set the kubectl completion code for zsh[1] to autoload on startup</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl</span> completion zsh &gt; <span class="hljs-string">"<span class="hljs-variable">${fpath[1]}</span>/_kubectl"</span> </code></pre> <p>Output shell completion code for the specified shell (bash or zsh). The shell code must be evaluated to provide interactive completion of kubectl commands. This can be done by sourcing it from the .bash_profile.</p> <p> Detailed instructions on how to do this are available here:</p> <p> for macOS: <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/#enable-shell-autocompletion">https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/#enable-shell-autocompletion</a></p> <p> for linux: <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#enable-shell-autocompletion">https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#enable-shell-autocompletion</a></p> <p> for windows: <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/#enable-shell-autocompletion">https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/#enable-shell-autocompletion</a></p> <p> Note for zsh users: <span>[</span>1<span>]</span> zsh completions are only supported in versions of zsh &gt;= 5.2.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl completion SHELL</code></p> <hr> <h1 id="config">config</h1> <p>Modify kubeconfig files using subcommands like &quot;kubectl config set current-context my-context&quot;</p> <p> The loading order follows these rules:</p> <ol> <li>If the --kubeconfig flag is set, then only that file is loaded. The flag may only be set once and no merging takes place.</li> <li>If $KUBECONFIG environment variable is set, then it is used as a list of paths (normal path delimiting 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.</li> <li>Otherwise, ${HOME}/.kube/config is used and no merging takes place.</li> </ol> <h3 id="usage">Usage</h3> <p><code>$ kubectl config SUBCOMMAND</code></p> <hr> <h2 id="-em-current-context-em-"><em>current-context</em></h2> <blockquote class="code-block example"> <p> Display the current-context</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>current-context </code></pre> <p>Display the current-context.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config current-context</code></p> <hr> <h2 id="-em-delete-cluster-em-"><em>delete-cluster</em></h2> <blockquote class="code-block example"> <p> Delete the minikube cluster</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-string">kubectl </span><span class="hljs-string">config </span><span class="hljs-built_in">delete-cluster</span> <span class="hljs-string">minikube</span> </code></pre> <p>Delete the specified cluster from the kubeconfig.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config delete-cluster NAME</code></p> <hr> <h2 id="-em-delete-context-em-"><em>delete-context</em></h2> <blockquote class="code-block example"> <p> Delete the context for the minikube cluster</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-string">kubectl </span><span class="hljs-string">config </span><span class="hljs-built_in">delete-context</span> <span class="hljs-string">minikube</span> </code></pre> <p>Delete the specified context from the kubeconfig.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config delete-context NAME</code></p> <hr> <h2 id="-em-delete-user-em-"><em>delete-user</em></h2> <blockquote class="code-block example"> <p> Delete the minikube user</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-string">kubectl </span><span class="hljs-string">config </span><span class="hljs-built_in">delete-user</span> <span class="hljs-string">minikube</span> </code></pre> <p>Delete the specified user from the kubeconfig.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config delete-user NAME</code></p> <hr> <h2 id="-em-get-clusters-em-"><em>get-clusters</em></h2> <blockquote class="code-block example"> <p> List the clusters that kubectl knows about</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>get-clusters </code></pre> <p>Display clusters defined in the kubeconfig.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config get-clusters</code></p> <hr> <h2 id="-em-get-contexts-em-"><em>get-contexts</em></h2> <blockquote class="code-block example"> <p> List all the contexts in your kubeconfig file</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>get-contexts </code></pre> <blockquote class="code-block example"> <p> Describe one context in your kubeconfig file</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-string">kubectl </span><span class="hljs-string">config </span><span class="hljs-built_in">get-contexts</span> <span class="hljs-string">my-context</span> </code></pre> <p>Display one or many contexts from the kubeconfig file.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config get-contexts [(-o|--output=)name)]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>no-headers</td> <td></td> <td>false</td> <td>When using the default or custom-column output format, don&#39;t print headers (default print headers). </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>Output format. One of: name </td> </tr> </tbody> </table> <hr> <h2 id="-em-get-users-em-"><em>get-users</em></h2> <blockquote class="code-block example"> <p> List the users that kubectl knows about</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>get-users </code></pre> <p>Display users defined in the kubeconfig.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config get-users</code></p> <hr> <h2 id="-em-rename-context-em-"><em>rename-context</em></h2> <blockquote class="code-block example"> <p> Rename the context &#39;old-name&#39; to &#39;new-name&#39; in your kubeconfig file</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>rename-context old-name new-name </code></pre> <p>Renames a context from the kubeconfig file.</p> <p> CONTEXT_NAME is the context name that you want to change.</p> <p> NEW_NAME is the new name you want to set.</p> <p> Note: If the context being renamed is the &#39;current-context&#39;, this field will also be updated.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config rename-context CONTEXT_NAME NEW_NAME</code></p> <hr> <h2 id="-em-set-em-"><em>set</em></h2> <blockquote class="code-block example"> <p> Set the server field on the my-cluster cluster to <a href="https://1.2.3.4">https://1.2.3.4</a></p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">config</span> <span class="hljs-built_in">set</span> clusters.my-cluster.server https:<span class="hljs-comment">//1.2.3.4</span> </code></pre> <blockquote class="code-block example"> <p> Set the certificate-authority-data field on the my-cluster cluster</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span><span class="hljs-builtin-name">set</span> clusters.my-cluster.certificate-authority-data $(echo <span class="hljs-string">"cert_data_here"</span> | base64 -i -) </code></pre> <blockquote class="code-block example"> <p> Set the cluster field in the my-context context to my-cluster</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span><span class="hljs-builtin-name">set</span> contexts.my-context.cluster my-cluster </code></pre> <blockquote class="code-block example"> <p> Set the client-key-data field in the cluster-admin user using --set-raw-bytes option</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span><span class="hljs-builtin-name">set</span> users.cluster-admin.client-key-data cert_data_here <span class="hljs-attribute">--set-raw-bytes</span>=<span class="hljs-literal">true</span> </code></pre> <p>Set an individual value in a kubeconfig file.</p> <p> PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.</p> <p> PROPERTY_VALUE is the new value you want to set. Binary fields such as &#39;certificate-authority-data&#39; expect a base64 encoded string unless the --set-raw-bytes flag is used.</p> <p> Specifying an attribute name that already exists will merge new fields on top of existing values.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config set PROPERTY_NAME PROPERTY_VALUE</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>set-raw-bytes</td> <td></td> <td>false</td> <td>When writing a <span>[</span><span>]</span>byte PROPERTY_VALUE, write the given string directly without base64 decoding. </td> </tr> </tbody> </table> <hr> <h2 id="-em-set-cluster-em-"><em>set-cluster</em></h2> <blockquote class="code-block example"> <p> Set only the server field on the e2e cluster entry without touching other values</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-cluster e2e <span class="hljs-attribute">--server</span>=https://1.2.3.4 </code></pre> <blockquote class="code-block example"> <p> Embed certificate authority data for the e2e cluster entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-cluster e2e --embed-certs <span class="hljs-attribute">--certificate-authority</span>=~/.kube/e2e/kubernetes.ca.crt </code></pre> <blockquote class="code-block example"> <p> Disable cert checking for the dev cluster entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-cluster e2e <span class="hljs-attribute">--insecure-skip-tls-verify</span>=<span class="hljs-literal">true</span> </code></pre> <blockquote class="code-block example"> <p> Set custom TLS server name to use for validation for the e2e cluster entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-cluster e2e <span class="hljs-attribute">--tls-server-name</span>=my-cluster-name </code></pre> <p>Set a cluster entry in kubeconfig.</p> <p> Specifying a name that already exists will merge new fields on top of existing values for those fields.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config set-cluster NAME [--server=server] [--certificate-authority=path/to/certificate/authority] [--insecure-skip-tls-verify=true] [--tls-server-name=example.com]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>embed-certs</td> <td></td> <td>false</td> <td>embed-certs for the cluster entry in kubeconfig </td> </tr> </tbody> </table> <hr> <h2 id="-em-set-context-em-"><em>set-context</em></h2> <blockquote class="code-block example"> <p> Set the user field on the gce context entry without touching other values</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-context gce <span class="hljs-attribute">--user</span>=cluster-admin </code></pre> <p>Set a context entry in kubeconfig.</p> <p> Specifying a name that already exists will merge new fields on top of existing values for those fields.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config set-context [NAME | --current] [--cluster=cluster_nickname] [--user=user_nickname] [--namespace=namespace]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>current</td> <td></td> <td>false</td> <td>Modify the current context </td> </tr> </tbody> </table> <hr> <h2 id="-em-set-credentials-em-"><em>set-credentials</em></h2> <blockquote class="code-block example"> <p> Set only the &quot;client-key&quot; field on the &quot;cluster-admin&quot; # entry, without touching other values</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--client-key</span>=~/.kube/admin.key </code></pre> <blockquote class="code-block example"> <p> Set basic auth for the &quot;cluster-admin&quot; entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--username</span>=admin <span class="hljs-attribute">--password</span>=uXFGweU9l35qcif </code></pre> <blockquote class="code-block example"> <p> Embed client certificate data in the &quot;cluster-admin&quot; entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--client-certificate</span>=~/.kube/admin.crt <span class="hljs-attribute">--embed-certs</span>=<span class="hljs-literal">true</span> </code></pre> <blockquote class="code-block example"> <p> Enable the Google Compute Platform auth provider for the &quot;cluster-admin&quot; entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--auth-provider</span>=gcp </code></pre> <blockquote class="code-block example"> <p> Enable the OpenID Connect auth provider for the &quot;cluster-admin&quot; entry with additional args</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--auth-provider</span>=oidc <span class="hljs-attribute">--auth-provider-arg</span>=client-id=foo <span class="hljs-attribute">--auth-provider-arg</span>=client-secret=bar </code></pre> <blockquote class="code-block example"> <p> Remove the &quot;client-secret&quot; config value for the OpenID Connect auth provider for the &quot;cluster-admin&quot; entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--auth-provider</span>=oidc <span class="hljs-attribute">--auth-provider-arg</span>=client-secret- </code></pre> <blockquote class="code-block example"> <p> Enable new exec auth plugin for the &quot;cluster-admin&quot; entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--exec-command</span>=/path/to/the/executable <span class="hljs-attribute">--exec-api-version</span>=client.authentication.k8s.io/v1beta1 </code></pre> <blockquote class="code-block example"> <p> Define new exec auth plugin args for the &quot;cluster-admin&quot; entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--exec-arg</span>=arg1 <span class="hljs-attribute">--exec-arg</span>=arg2 </code></pre> <blockquote class="code-block example"> <p> Create or update exec auth plugin environment variables for the &quot;cluster-admin&quot; entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--exec-env</span>=key1=val1 <span class="hljs-attribute">--exec-env</span>=key2=val2 </code></pre> <blockquote class="code-block example"> <p> Remove exec auth plugin environment variables for the &quot;cluster-admin&quot; entry</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>set-credentials cluster-admin <span class="hljs-attribute">--exec-env</span>=var-to-remove- </code></pre> <p>Set a user entry in kubeconfig.</p> <p> Specifying a name that already exists will merge new fields on top of existing values.</p> <p> Client-certificate flags: --client-certificate=certfile --client-key=keyfile</p> <p> Bearer token flags: --token=bearer_token</p> <p> Basic auth flags: --username=basic_user --password=basic_password</p> <p> Bearer token and basic auth are mutually exclusive.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config set-credentials NAME [--client-certificate=path/to/certfile] [--client-key=path/to/keyfile] [--token=bearer_token] [--username=basic_user] [--password=basic_password] [--auth-provider=provider_name] [--auth-provider-arg=key=value] [--exec-command=exec_command] [--exec-api-version=exec_api_version] [--exec-arg=arg] [--exec-env=key=value]</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>auth-provider</td> <td></td> <td></td> <td>Auth provider for the user entry in kubeconfig </td> </tr> <tr> <td>auth-provider-arg</td> <td></td> <td>[]</td> <td>&#39;key=value&#39; arguments for the auth provider </td> </tr> <tr> <td>embed-certs</td> <td></td> <td>false</td> <td>Embed client cert/key for the user entry in kubeconfig </td> </tr> <tr> <td>exec-api-version</td> <td></td> <td></td> <td>API version of the exec credential plugin for the user entry in kubeconfig </td> </tr> <tr> <td>exec-arg</td> <td></td> <td>[]</td> <td>New arguments for the exec credential plugin command for the user entry in kubeconfig </td> </tr> <tr> <td>exec-command</td> <td></td> <td></td> <td>Command for the exec credential plugin for the user entry in kubeconfig </td> </tr> <tr> <td>exec-env</td> <td></td> <td>[]</td> <td>&#39;key=value&#39; environment values for the exec credential plugin </td> </tr> </tbody> </table> <hr> <h2 id="-em-unset-em-"><em>unset</em></h2> <blockquote class="code-block example"> <p> Unset the current-context</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>unset current-context </code></pre> <blockquote class="code-block example"> <p> Unset namespace in foo context</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>unset contexts.foo.namespace </code></pre> <p>Unset an individual value in a kubeconfig file.</p> <p> PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config unset PROPERTY_NAME</code></p> <hr> <h2 id="-em-use-context-em-"><em>use-context</em></h2> <blockquote class="code-block example"> <p> Use the context for the minikube cluster</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>use-context minikube </code></pre> <p>Set the current-context in a kubeconfig file.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config use-context CONTEXT_NAME</code></p> <hr> <h2 id="-em-view-em-"><em>view</em></h2> <blockquote class="code-block example"> <p> Show merged kubeconfig settings</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>view </code></pre> <blockquote class="code-block example"> <p> Show merged kubeconfig settings and raw certificate data</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>view --raw </code></pre> <blockquote class="code-block example"> <p> Get the password for the e2e user</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl<span class="hljs-built_in"> config </span>view -o <span class="hljs-attribute">jsonpath</span>=<span class="hljs-string">'{.users[?(@.name == "e2e")].user.password}'</span> </code></pre> <p>Display merged kubeconfig settings or a specified kubeconfig file.</p> <p> You can use --output jsonpath={...} to extract specific values using a jsonpath expression.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl config view</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>allow-missing-template-keys</td> <td></td> <td>true</td> <td>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. </td> </tr> <tr> <td>flatten</td> <td></td> <td>false</td> <td>Flatten the resulting kubeconfig file into self-contained output (useful for creating portable kubeconfig files) </td> </tr> <tr> <td>merge</td> <td></td> <td>true</td> <td>Merge the full hierarchy of kubeconfig files </td> </tr> <tr> <td>minify</td> <td></td> <td>false</td> <td>Remove all information not used by current-context from the output </td> </tr> <tr> <td>output</td> <td>o</td> <td>yaml</td> <td>Output format. One of: json&#124;yaml&#124;name&#124;go-template&#124;go-template-file&#124;template&#124;templatefile&#124;jsonpath&#124;jsonpath-as-json&#124;jsonpath-file. </td> </tr> <tr> <td>raw</td> <td></td> <td>false</td> <td>Display raw byte data </td> </tr> <tr> <td>show-managed-fields</td> <td></td> <td>false</td> <td>If true, keep the managedFields when printing objects in JSON or YAML format. </td> </tr> <tr> <td>template</td> <td></td> <td></td> <td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td> </tr> </tbody> </table> <hr> <h1 id="explain">explain</h1> <blockquote class="code-block example"> <p> Get the documentation of the resource and its fields</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl explain pods</span> </code></pre> <blockquote class="code-block example"> <p> Get the documentation of a specific field of a resource</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-selector-tag">kubectl</span> <span class="hljs-selector-tag">explain</span> <span class="hljs-selector-tag">pods</span><span class="hljs-selector-class">.spec</span><span class="hljs-selector-class">.containers</span> </code></pre> <p>List the fields for supported resources.</p> <p> This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:</p> <p> &lt;type&gt;.&lt;fieldName&gt;<span>[</span>.&lt;fieldName&gt;<span>]</span></p> <p> Add the --recursive flag to display all of the fields at once without descriptions. Information about each field is retrieved from the server in OpenAPI format.</p> <p>Use &quot;kubectl api-resources&quot; for a complete list of supported resources.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl explain RESOURCE</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>api-version</td> <td></td> <td></td> <td>Get different explanations for particular API version (API group/version) </td> </tr> <tr> <td>recursive</td> <td></td> <td>false</td> <td>Print the fields of fields (Currently only 1 level deep) </td> </tr> </tbody> </table> <hr> <h1 id="options">options</h1> <blockquote class="code-block example"> <p> Print flags inherited by all commands</p> </blockquote> <pre class="code-block example"><code class="lang-shell"><span class="hljs-attribute">kubectl options</span> </code></pre> <p>Print the list of flags inherited by all commands</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl options</code></p> <hr> <h1 id="plugin">plugin</h1> <p>Provides utilities for interacting with plugins.</p> <p> Plugins provide extended functionality that is not part of the major command-line distribution. Please refer to the documentation and examples for more information about how write your own plugins.</p> <p> The easiest way to discover and install plugins is via the kubernetes sub-project krew. To install krew, visit <a href="https://krew.sigs.k8s.io/docs/user-guide/setup/install/">https://krew.sigs.k8s.io/docs/user-guide/setup/install/</a></p> <h3 id="usage">Usage</h3> <p><code>$ kubectl plugin [flags]</code></p> <hr> <h2 id="-em-list-em-"><em>list</em></h2> <p>List all available plugin files on a user&#39;s PATH.</p> <p> Available plugin files are those that are: - executable - anywhere on the user&#39;s PATH - begin with &quot;kubectl-&quot;</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl plugin list</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>name-only</td> <td></td> <td>false</td> <td>If true, display only the binary name of each plugin, rather than its full path </td> </tr> </tbody> </table> <hr> <h1 id="version">version</h1> <blockquote class="code-block example"> <p> Print the client and server versions for the current context</p> </blockquote> <pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">version</span> </code></pre> <p>Print the client and server version information for the current context.</p> <h3 id="usage">Usage</h3> <p><code>$ kubectl version</code></p> <h3 id="flags">Flags</h3> <table> <thead> <tr> <th>Name</th> <th>Shorthand</th> <th>Default</th> <th>Usage</th> </tr> </thead> <tbody> <tr> <td>client</td> <td></td> <td>false</td> <td>If true, shows client version only (no server required). </td> </tr> <tr> <td>output</td> <td>o</td> <td></td> <td>One of &#39;yaml&#39; or &#39;json&#39;. </td> </tr> <tr> <td>short</td> <td></td> <td>false</td> <td>If true, print just the version number. </td> </tr> </tbody> </table> </div> </div> <script src="node_modules/jquery/dist/jquery.min.js"></script> <script src="node_modules/jquery.scrollto/jquery.scrollTo.min.js"></script> <script src="navData.js"></script> <script src="scroll.js"></script> <!--<script src="actions.js"></script>--> <script src="tabvisibility.js"></script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10