7608 lines
306 KiB
HTML
7608 lines
306 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Kubectl Reference Docs</title>
|
|
<link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon">
|
|
<!-- 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-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="#convert" class="nav-item">convert</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="#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-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-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-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="#kustomize" class="nav-item">kustomize</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><ul><li class="nav-level-1 strong-nav"><a href="#-strong-deprecated-commands-strong-" class="nav-item"><strong>DEPRECATED COMMANDS</strong></a></li></ul><ul><li class="nav-level-1"><a href="#rolling-update" class="nav-item">rolling-update</a></li></ul><br/><div class="copyright"><a href="https://github.com/kubernetes/kubernetes">Copyright 2019 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 <span class="hljs-string">| kubectl create -f -</span>
|
|
</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>$ 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>edit</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>Edit the API resource before creating </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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 ClusterRole named "pod-reader" that allows user to perform "get", "watch" and "list" 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 ClusterRole named "pod-reader" 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 ClusterRole named "foo" 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 ClusterRole named "foo" 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 ClusterRole name "foo" 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 ClusterRole name "monitoring" 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 ClusterRole.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 ClusterRoleBinding for user1, user2, and group1 using the cluster-admin ClusterRole</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 ClusterRoleBinding for a particular ClusterRole.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ clusterrolebinding NAME --clusterrole=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>clusterrolebinding.rbac.authorization.k8s.io/v1alpha1</td>
|
|
<td>The name of the API generator to use. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 <namespace>:<name> </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 configmap 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 configmap 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 configmap 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 configmap 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 configmap 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 configmap based on a file, directory, or specified literal value.</p>
|
|
<p> A single configmap may package one or more key/value pairs.</p>
|
|
<p> When creating a configmap 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 configmap based on a directory, each file whose basename is a valid key in the directory will be packaged into the configmap. Any directory entries except regular files are ignored (e.g. subdirectories, symlinks, devices, pipes, etc).</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ configmap NAME [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>generator</td>
|
|
<td></td>
|
|
<td>configmap/v1</td>
|
|
<td>The name of the API generator to use. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 cronjob</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl create cronjob <span class="hljs-keyword">my</span>-job <span class="hljs-comment">--image=busybox</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Create a cronjob with command</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl create cronjob <span class="hljs-keyword">my</span>-job <span class="hljs-comment">--image=busybox -- date</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Create a cronjob with schedule</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl create cronjob test-job <span class="hljs-attribute">--image</span>=busybox <span class="hljs-attribute">--schedule</span>=<span class="hljs-string">"*/1 * * * *"</span>
|
|
</code></pre>
|
|
<p>Create a cronjob with the specified name.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ cronjob NAME --image=image --schedule='0/5 * * * ?' -- [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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>restart</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>job'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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 new 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>
|
|
<p>Create a deployment with the specified name.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ deployment NAME --image=image [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>The name of the API generator to use. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 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 CronJob named "a-cronjob"</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>$ 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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>$ namespace NAME [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>namespace/v1</td>
|
|
<td>The name of the API generator to use. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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>$ poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>poddisruptionbudget/v1beta1/v2</td>
|
|
<td>The name of the API generator to use. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 priorityclass 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 priorityclass named default-priority that 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>
|
|
<p>Create a priorityclass with the specified name, value, globalDefault and description</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ priorityclass NAME --value=VALUE --global-default=BOOL [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>priorityclass/v1alpha1</td>
|
|
<td>The name of the API generator to use. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 resourcequota 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 resourcequota 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 resourcequota with the specified name, hard limits and optional scopes</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ quota NAME [--hard=key1=value1,key2=value2] [--scopes=Scope1,Scope2] [--dry-run=bool]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>resourcequotas/v1</td>
|
|
<td>The name of the API generator to use. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 "pod-reader" that allows user to perform "get", "watch" and "list" 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 "pod-reader" 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 "foo" 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 "foo" 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>$ role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 RoleBinding for user1, user2, and group1 using the admin ClusterRole</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 RoleBinding for a particular Role or ClusterRole.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>rolebinding.rbac.authorization.k8s.io/v1alpha1</td>
|
|
<td>The name of the API generator to use. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 <namespace>:<name> </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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>$ 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'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>
|
|
<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:
|
|
'$ docker login DOCKER_REGISTRY_SERVER --username=DOCKER_USER --password=DOCKER_PASSWORD --email=DOCKER_EMAIL'.</p>
|
|
<p> That produces a ~/.dockercfg file that is used by subsequent 'docker push' and 'docker pull' 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 have to 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>$ docker-registry NAME --docker-username=user --docker-password=password --docker-email=email [--docker-server=string] [--from-literal=key1=value1] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>generator</td>
|
|
<td></td>
|
|
<td>secret-for-docker-registry/v1</td>
|
|
<td>The name of the API generator to use. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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=~/.ssh/id_rsa <span class="hljs-attribute">--from-file</span>=ssh-publickey=~/.ssh/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=~/.ssh/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>$ generic NAME [--type=string] [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>generator</td>
|
|
<td></td>
|
|
<td>secret/v1</td>
|
|
<td>The name of the API generator to use. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 before hand. The public key certificate must be .PEM encoded and match the given private key.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ tls NAME --cert=path/to/cert/file --key=path/to/key/file [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>secret-for-tls/v1</td>
|
|
<td>The name of the API generator to use. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 specified subcommand.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>$ clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run]</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 'None' for a 'headless' service (no loadbalancing). </td>
|
|
</tr>
|
|
<tr>
|
|
<td>dry-run</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>service-clusterip/v1</td>
|
|
<td>The name of the API generator to use. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>tcp</td>
|
|
<td></td>
|
|
<td>[]</td>
|
|
<td>Port pairs can be specified as '<port>:<targetPort>'. </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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>$ externalname NAME --external-name external.name [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>external-name</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>External name of service </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>service-externalname/v1</td>
|
|
<td>The name of the API generator to use. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>tcp</td>
|
|
<td></td>
|
|
<td>[]</td>
|
|
<td>Port pairs can be specified as '<port>:<targetPort>'. </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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>$ loadbalancer NAME [--tcp=port:targetPort] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>service-loadbalancer/v1</td>
|
|
<td>The name of the API generator to use. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>tcp</td>
|
|
<td></td>
|
|
<td>[]</td>
|
|
<td>Port pairs can be specified as '<port>:<targetPort>'. </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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>$ nodeport NAME [--tcp=port:targetPort] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>service-nodeport/v1</td>
|
|
<td>The name of the API generator to use. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>tcp</td>
|
|
<td></td>
|
|
<td>[]</td>
|
|
<td>Port pairs can be specified as '<port>:<targetPort>'. </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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>$ serviceaccount NAME [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>generator</td>
|
|
<td></td>
|
|
<td>serviceaccount/v1</td>
|
|
<td>The name of the API generator to use. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 "v1" version of the "apps" API group:</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl get deployments<span class="hljs-selector-class">.v1</span><span class="hljs-selector-class">.apps</span> -o json
|
|
</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-builtin-name">get</span> -o json pod web-pod-13je7
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> List a pod identified by type and name specified in "pod.yaml" in JSON output format.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-builtin-name">get</span> -f pod.yaml -o json
|
|
</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 'template' and providing a Go template as the value of the --template flag, you can filter the attributes of the fetched resources.</p>
|
|
<p>Use "kubectl api-resources" for a complete list of supported resources.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ get [(-o|--output=)json|yaml|wide|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...] (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>export</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, use 'export' for the resources. Exported resources are stripped of cluster-specific information. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>field-selector</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </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>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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't print headers (default print headers). </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [<a href="http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns]">http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns]</a>, golang template [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a> and jsonpath template [<a href="http://kubernetes.io/docs/user-guide/jsonpath]">http://kubernetes.io/docs/user-guide/jsonpath]</a>. </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 '=', '==', and '!='.(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>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. '{.metadata.name}'). 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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 single instance of nginx.</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 single instance of hazelcast 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 <span class="hljs-attribute">--port</span>=5701
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Start a single instance of hazelcast and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" 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 <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 single instance of hazelcast and set labels "app=hazelcast" and "env=prod" 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 <span class="hljs-attribute">--labels</span>=<span class="hljs-string">"app=hazelcast,env=prod"</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Start a replicated instance of nginx.</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">--replicas</span>=5
|
|
</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 --dry-run
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Start a single instance of nginx, but overload the spec of the deployment 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 pod of busybox and keep it in the foreground, don'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 container 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 -- <arg1> <arg2> <span class="hljs-built_in">..</span>. <argN>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Start the nginx container 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 -- <cmd> <arg1> <span class="hljs-built_in">..</span>. <argN>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Start the perl container to compute π to 2000 places and print it out.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">run</span> <span class="hljs-literal">pi</span> <span class="hljs-comment">--image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Start the cron job to compute π to 2000 places and print it out every 5 minutes.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">run</span> pi --schedule=<span class="hljs-string">"0/5 * * * ?"</span> --<span class="hljs-built_in">image</span>=perl --restart=OnFailure -- perl -Mbignum=bpi -wle <span class="hljs-string">'print bpi(2000)'</span>
|
|
</code></pre>
|
|
<p>Create and run a particular image, possibly replicated.</p>
|
|
<p> Creates a deployment or job to manage the created container(s).</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--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>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 'kubectl attach ...' were called. Default false, unless '-i/--stdin' is set, in which case the default is true. With '--restart=Never' the exit code of the container process is returned. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>cascade</td>
|
|
<td></td>
|
|
<td>true</td>
|
|
<td>If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>command</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true and extra arguments are present, use them as the 'command' field in the container, rather than the 'args' field which is the default. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>dry-run</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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, a public, external service is created for the container(s) which are run </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>Only used when grace-period=0. 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>generator</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>The name of the API generator to use, see <a href="http://kubernetes.io/docs/user-guide/kubectl-conventions/#generators">http://kubernetes.io/docs/user-guide/kubectl-conventions/#generators</a> for a list. </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'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, 'cpu=200m,memory=512Mi'. 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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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. If --expose is true, this is also the port used by the service that is created. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>quiet</td>
|
|
<td></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>replicas</td>
|
|
<td>r</td>
|
|
<td>1</td>
|
|
<td>Number of replicas to create for this container. Default is 1. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>requests</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>restart</td>
|
|
<td></td>
|
|
<td>Always</td>
|
|
<td>The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a deployment is created, if set to 'OnFailure' a job is created, if set to 'Never', a regular pod is created. For the latter two --replicas must be 1. Default 'Always', for CronJobs <code>Never</code>. </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>schedule</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>A schedule in the Cron format the job should be run with. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>service-generator</td>
|
|
<td></td>
|
|
<td>service/v2</td>
|
|
<td>The name of the generator to use for creating a service. Only used if --expose is true </td>
|
|
</tr>
|
|
<tr>
|
|
<td>service-overrides</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>An inline JSON override for the generated service object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. Only used if --expose is true. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>serviceaccount</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Service account to set in the pod spec </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 "nginx-controller.yaml", 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 "frontend"</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 "nginx-https"</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 'video-stream'.</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>$ 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 'None' 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>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: 'service/v1' and 'service/v2'. The only difference between them is that service port in v1 is named 'default', while it is left unnamed in v2. Default is 'service/v2'. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 'TCP'. </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: 'None', 'ClientIP' </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>type</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is 'ClusterIP'. </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"><span class="hljs-keyword">cat</span> pod.json | kubectl <span class="hljs-keyword">delete</span> -<span class="hljs-keyword">f</span> -
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Delete pods and services with same names "baz" and "foo"</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 delete pods,services -l <span class="hljs-attribute">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"><span class="hljs-comment">kubectl</span> <span class="hljs-comment">delete</span> <span class="hljs-comment">pod</span> <span class="hljs-comment">foo</span> <span class="hljs-literal">-</span><span class="hljs-literal">-</span><span class="hljs-comment">grace</span><span class="hljs-literal">-</span><span class="hljs-comment">period=0</span> <span class="hljs-literal">-</span><span class="hljs-literal">-</span><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 filenames, stdin, resources and names, or by resources and label selector.</p>
|
|
<p> JSON and YAML formats are accepted. Only one type of the arguments may be specified: filenames, 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 pass a grace period of 0 and specify the --force flag.</p>
|
|
<p> IMPORTANT: Force deleting pods does not wait for confirmation that the pod'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>$ 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>true</td>
|
|
<td>If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>field-selector</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </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>Only used when grace-period=0. 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 "resource not found" as a successful delete. Defaults to "true" when --all is specified. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process a kustomization directory. This flag can'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 "-o name" for shorter output (resource/name). </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 the 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 configmaps 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-literal">-</span><span class="hljs-literal">-</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-literal">-</span><span class="hljs-literal">-</span><span class="hljs-comment">all</span> <span class="hljs-literal">-</span><span class="hljs-literal">-</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 filename or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.</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>$ 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>true</td>
|
|
<td>If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>dry-run</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. Warning: --dry-run cannot accurately output the result of merging the local manifest and the server-side data. Use --server-dry-run to get the merged result instead. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>experimental-field-manager</td>
|
|
<td></td>
|
|
<td>kubectl</td>
|
|
<td>Name of the manager used to track field ownership. This is an alpha feature and flag. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>experimental-force-conflicts</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, server-side apply will force the changes against conflicts. This is an alpha feature and flag. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>experimental-server-side</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, apply runs in the server instead of the client. This is an alpha feature and flag. </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>Only used when grace-period=0. 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>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process a kustomization directory. This flag can'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 <group/version/kind> 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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) </td>
|
|
</tr>
|
|
<tr>
|
|
<td>server-dry-run</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, request will be sent to server with dry-run flag, which means the modifications won't be persisted. This is an alpha feature and flag. </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 'vi' for Linux or 'notepad' for Windows. You can edit multiple objects, although changes are applied one at a time. The command accepts filenames as well as command line arguments, although the files you point to must be previously saved versions of resources.</p>
|
|
<p> The default format is YAML. To edit in JSON, specify "-o json".</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>$ 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>filename</td>
|
|
<td>f</td>
|
|
<td>[]</td>
|
|
<td>Filename, directory, or URL to files to use to edit the resource </td>
|
|
</tr>
|
|
<tr>
|
|
<td>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 'kubectl apply -f<file> ' was run, without updating any other parts of the object.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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 'last-applied-configuration' annotations if current objects doesn't have one </td>
|
|
</tr>
|
|
<tr>
|
|
<td>dry-run</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file. </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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. One can use -o option to change output format.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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'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|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 '=', '==', and '!='.(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 'foo' with the annotation 'description' and the value 'my frontend'. # 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 "pod.json"</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl annotate -f pod<span class="hljs-selector-class">.json</span> description=<span class="hljs-string">'my frontend'</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Update pod 'foo' with the annotation 'description' and the value 'my frontend running nginx', 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 'foo' 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 'foo' by removing an annotation named 'description' 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 "kubectl api-resources" for a complete list of supported resources.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>field-selector</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </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>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can't be used together with -f or -R. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h1 id="autoscale">autoscale</h1>
|
|
<blockquote class="code-block example">
|
|
<p> Auto scale a deployment "foo", 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 "foo", 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, ReplicaSet, StatefulSet, or ReplicationController 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>$ 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's not specified or negative, a default autoscaling policy will be used. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>dry-run</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>generator</td>
|
|
<td></td>
|
|
<td>horizontalpodautoscaler/v1</td>
|
|
<td>The name of the API generator to use. Currently there is only 1 generator. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h1 id="convert">convert</h1>
|
|
<blockquote class="code-block example">
|
|
<p> Convert 'pod.yaml' to latest version and print to stdout.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell"><span class="hljs-selector-tag">kubectl</span> <span class="hljs-selector-tag">convert</span> <span class="hljs-selector-tag">-f</span> <span class="hljs-selector-tag">pod</span><span class="hljs-selector-class">.yaml</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Convert the live state of the resource specified by 'pod.yaml' to the latest version # and print to stdout in JSON format.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">convert</span> -f pod.yaml <span class="hljs-comment">--local -o json</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Convert all files under current directory to latest version and create them all.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-built_in">convert</span> -f . | kubectl <span class="hljs-built_in">create</span> -f -
|
|
</code></pre>
|
|
<p>Convert config files between different API versions. Both YAML and JSON formats are accepted.</p>
|
|
<p> The command takes filename, directory, or URL as input, and convert it into format of version specified by --output-version flag. If target version is not specified or not supported, convert to latest version.</p>
|
|
<p> The default output will be printed to stdout in YAML format. One can use -o option to change to output destination.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ convert -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>filename</td>
|
|
<td>f</td>
|
|
<td>[]</td>
|
|
<td>Filename, directory, or URL to files to need to get converted. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can't be used together with -f or -R. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>local</td>
|
|
<td></td>
|
|
<td>true</td>
|
|
<td>If true, convert will NOT try to contact api-server but run locally. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td>yaml</td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output-version</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Output the formatted object with the given group version (for ex: 'extensions/v1beta1'). </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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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="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 filename or stdin between the current online configuration, and the configuration as it would be if applied.</p>
|
|
<p> Output is always YAML.</p>
|
|
<p> KUBECTL_EXTERNAL_DIFF environment variable can be used to select your own diff command. By default, the "diff" command available in your path will be run with "-u" (unicode) and "-N" (treat new files as empty) options.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>experimental-field-manager</td>
|
|
<td></td>
|
|
<td>kubectl</td>
|
|
<td>Name of the manager used to track field ownership. This is an alpha feature and flag. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>experimental-force-conflicts</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, server-side apply will force the changes against conflicts. This is an alpha feature and flag. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>experimental-server-side</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, apply runs in the server instead of the client. This is an alpha feature and flag. </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>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h1 id="edit">edit</h1>
|
|
<blockquote class="code-block example">
|
|
<p> Edit the service named 'docker-registry':</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 'myjob' in JSON using the v1 API format:</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl edit job<span class="hljs-selector-class">.v1</span><span class="hljs-selector-class">.batch</span>/myjob -o json
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Edit the deployment 'mydeployment' 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 'vi' for Linux or 'notepad' for Windows. You can edit multiple objects, although changes are applied one at a time. The command accepts filenames as well as command line arguments, although the files you point to must be previously saved versions of resources.</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 "-o json".</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>$ 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>filename</td>
|
|
<td>f</td>
|
|
<td>[]</td>
|
|
<td>Filename, directory, or URL to files to use to edit the resource </td>
|
|
</tr>
|
|
<tr>
|
|
<td>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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="label">label</h1>
|
|
<blockquote class="code-block example">
|
|
<p> Update pod 'foo' with the label 'unhealthy' and the value 'true'.</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 'foo' with the label 'status' and the value 'unhealthy', 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 "pod.json"</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-selector-tag">label</span> -f pod<span class="hljs-selector-class">.json</span> status=unhealthy
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Update pod 'foo' 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 'foo' by removing a label named 'bar' 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 '/', 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>$ 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>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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>field-selector</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. </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>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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. Specify 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. Specify 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 "node.json" 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's image; spec.containers[*].name is required because it'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'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 field(s) 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>$ patch (-f FILENAME | TYPE NAME) -p PATCH</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>type</td>
|
|
<td></td>
|
|
<td>strategic</td>
|
|
<td>The type of patch being provided; one of [json merge strategic] </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'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 filename 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>$ 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>true</td>
|
|
<td>If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true. </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>Only used when grace-period=0. 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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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>$ 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>$ 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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 "kubectl rollout resume" to resume a paused resource. Currently only deployments support being paused.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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>$ 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>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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 'rollout status' will watch the status of the latest rollout until it's done. If you don't want to wait for the rollout to finish then you can use --watch=false. Note that if a new rollout starts in-between, then 'rollout status' will continue watching the latest revision. If you want to pin to a specific revision and abort if it is rolled over by another revision, use --revision=N where N is the revision you need to watch for.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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'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's done. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h2 id="-em-undo-em-"><em>undo</em></h2>
|
|
<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> Rollback 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> Rollback 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">=<span class="hljs-literal">true</span> deployment/abc</span>
|
|
</code></pre>
|
|
<p>Rollback to a previous rollout.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 replicaset named 'foo' 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 "foo.yaml" 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'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 statefulset named 'web' 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, ReplicaSet, Replication Controller, or StatefulSet.</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>$ 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. </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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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'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>$ set SUBCOMMAND</code></p>
|
|
<hr>
|
|
<h2 id="-em-env-em-"><em>env</em></h2>
|
|
<blockquote class="code-block example">
|
|
<p> Update deployment 'registry' 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 'sample-build'</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 'c1' 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 "--env -" 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), job, replicaset (rs)</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h2 id="-em-image-em-"><em>image</em></h2>
|
|
<blockquote class="code-block example">
|
|
<p> Set a deployment's nginx container image to 'nginx:1.9.1', and its busybox container image to 'busybox'.</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' and rc's nginx container's image to 'nginx:1.9.1'</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 'nginx:1.9.1'</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">set</span> image <span class="hljs-comment">daemonset abc *=nginx:1.9.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), replicaset (rs)</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 "200m" and memory to "512Mi"</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 "kubectl api-resources" for a complete list of supported resources..</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ resources (-f FILENAME | TYPE NAME) ([--limits=LIMITS & --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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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, 'cpu=100m,memory=256Mi'. 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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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, 'cpu=100m,memory=256Mi'. 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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 service clusterip my-svc --clusterip=<span class="hljs-string">"None"</span> -o yaml --dry-<span class="hljs-keyword">run</span><span class="bash"> | kubectl <span class="hljs-built_in">set</span> selector --<span class="hljs-built_in">local</span> -f - <span class="hljs-string">'environment=qa'</span> -o yaml | kubectl create -f -
|
|
</span>kubectl create deployment my-dep -o yaml --dry-<span class="hljs-keyword">run</span><span class="bash"> | kubectl label --<span class="hljs-built_in">local</span> -f - environment=qa -o yaml | kubectl create -f -</span>
|
|
</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 'set selector'.</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>$ 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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's ServiceAccount 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 serviceaccount from local file, without hitting apiserver</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 --dry-<span class="hljs-builtin-name">run</span> -o yaml
|
|
</code></pre>
|
|
<p>Update ServiceAccount 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>$ 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h2 id="-em-subject-em-"><em>subject</em></h2>
|
|
<blockquote class="code-block example">
|
|
<p> Update a ClusterRoleBinding 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 RoleBinding 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 --dry-<span class="hljs-builtin-name">run</span> | kubectl <span class="hljs-builtin-name">set</span> subject --local -f - <span class="hljs-attribute">--user</span>=foo -o yaml
|
|
</code></pre>
|
|
<p>Update User, Group or ServiceAccount in a RoleBinding/ClusterRoleBinding.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ subject (-f FILENAME | TYPE NAME) [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run]</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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 '=', '==', and '!='.(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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h1 id="wait">wait</h1>
|
|
<blockquote class="code-block example">
|
|
<p> Wait for the pod "busybox1" to contain the status condition of type "Ready".</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 pod/busybox1
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Wait for the pod "busybox1" to be deleted, with a timeout of 60s, after having issued the "delete" command.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">delete</span> pod/busybox1
|
|
kubectl <span class="hljs-built_in">wait</span> --<span class="hljs-keyword">for</span>=<span class="hljs-keyword">delete</span> pod/busybox1 --timeout=<span class="hljs-number">60</span>s
|
|
</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 "delete" 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. One can use -o option to change to output destination.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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 '=', '==', and '!='.(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: [delete|condition=condition-name]. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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'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 123456-7890, using the first container by default</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-section">attach</span> <span class="hljs-number">123456</span><span class="hljs-number">-7890</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Get output from ruby-container from pod 123456-7890</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-section">attach</span> <span class="hljs-number">123456</span><span class="hljs-number">-7890</span> -c ruby-container
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-7890 # and sends stdout/stderr from 'bash' back to the client</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-section">attach</span> <span class="hljs-number">123456</span><span class="hljs-number">-7890</span> -c ruby-container -i -t
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Get output from the first pod of a ReplicaSet 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>$ 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, 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>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>$ 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-<span class="hljs-selector-tag">i</span> list deployments.extensions
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Check to see if I can do everything in my current namespace ("*" means all)</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl auth can-<span class="hljs-selector-tag">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 "bar" in namespace "foo"</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl auth can-<span class="hljs-selector-tag">i</span> list 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 "foo"</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl auth can-i --<span class="hljs-built_in">list</span> --<span class="hljs-keyword">namespace</span>=foo
|
|
</code></pre>
|
|
<p>Check whether an action is allowed.</p>
|
|
<p> VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL starts with "/". NAME is the name of a particular Kubernetes resource.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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, RoleBinding, ClusterRole, and ClusterRole 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 'apply' for RBAC resources so that semantically-aware merging of rules and subjects is done.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>false</td>
|
|
<td>If true, display results but do not submit changes </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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h1 id="cp">cp</h1>
|
|
<blockquote class="code-block example">
|
|
<p> !!!Important Note!!! # Requires that the 'tar' binary is present in your container # image. If 'tar' is not present, 'kubectl cp' will fail. # Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl cp /tmp/foo_dir <some-pod><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"><some-pod></span>:<span class="hljs-meta-keyword">/tmp/</span>bar -c <span class="hljs-params"><specific-container></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"><some-namespace></span>/<span class="hljs-params"><some-pod></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"><some-namespace></span>/<span class="hljs-params"><some-pod></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>$ cp <file-spec-src> <file-spec-dest></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, 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'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 "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">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 'frontend' 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 "kubectl api-resources" for a complete list of supported resources.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>filename</td>
|
|
<td>f</td>
|
|
<td>[]</td>
|
|
<td>Filename, directory, or URL to files containing the resource to describe </td>
|
|
</tr>
|
|
<tr>
|
|
<td>include-uninitialized</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>kustomize</td>
|
|
<td>k</td>
|
|
<td></td>
|
|
<td>Process the kustomization directory. This flag can'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 '=', '==', and '!='.(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 'date' from pod 123456-7890, 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> <span class="hljs-number">123456</span><span class="hljs-number">-7890</span> <span class="hljs-built_in">date</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Get output from running 'date' in ruby-container from pod 123456-7890</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl <span class="hljs-keyword">exec</span> <span class="hljs-number">123456</span><span class="hljs-number">-7890</span> -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 'bash' in ruby-container from pod 123456-7890 # and sends stdout/stderr from 'bash' back to the client</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl exec <span class="hljs-number">123456</span><span class="hljs-number">-7890</span> -c ruby-container -i -t -- bash -il
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> List contents of /usr from the first container of pod 123456-7890 and sort by modification time. # If the command you want to execute in the pod has any flags in common (e.g. -i), # you must use two dashes (--) to separate your command's flags/arguments. # Also note, do not surround your command and its flags/arguments with quotes # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr").</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl exec <span class="hljs-number">123456</span>-<span class="hljs-number">7890</span> -i -<span class="hljs-built_in">t</span> -- ls -<span class="hljs-built_in">t</span> /usr
|
|
</code></pre>
|
|
<p>Execute a command in a container.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ exec POD [-c CONTAINER] -- 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, the first container in the pod will be chosen </td>
|
|
</tr>
|
|
<tr>
|
|
<td>pod</td>
|
|
<td>p</td>
|
|
<td></td>
|
|
<td>Pod name </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 <span class="hljs-attribute">-lapp</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 -<span class="hljs-selector-tag">p</span> -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 -<span class="hljs-keyword">c</span> 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 <span class="hljs-attribute">-lapp</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> 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 -<span class="hljs-keyword">c</span> 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>$ 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's 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>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>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 ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 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">5000</span> <span class="hljs-number">6000</span>
|
|
</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-<span class="hljs-keyword">forward</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 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.0.0</span> pod/mypod <span class="hljs-number">8888: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.21.23</span> pod/mypod <span class="hljs-number">8888: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-<span class="hljs-keyword">forward</span> pod/mypod :<span class="hljs-number">5000</span>
|
|
</code></pre>
|
|
<p>Forward one or more local ports to a pod. This command requires the node to have 'socat' installed.</p>
|
|
<p> Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' 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 rerun of the command is needed to resume forwarding.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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, use:</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:</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> The above lets you 'curl localhost:8001/api/v1/pods'. # To proxy the entire kubernetes api at a different root, use:</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> The above lets you 'curl localhost:8001/custom/api/v1/pods' # Run a proxy to kubernetes apiserver 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 kubernetes apiserver 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 kubernetes apiserver, 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>$ 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='POST,PUT,PATCH'). </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/Storage) usage.</p>
|
|
<p> The top command allows you to see the resource consumption for nodes or pods.</p>
|
|
<p> This command requires Heapster to be correctly configured and working on the server.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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/Storage) 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>$ 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>heapster-namespace</td>
|
|
<td></td>
|
|
<td>kube-system</td>
|
|
<td>Namespace Heapster service is located in </td>
|
|
</tr>
|
|
<tr>
|
|
<td>heapster-port</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Port name in service to use </td>
|
|
</tr>
|
|
<tr>
|
|
<td>heapster-scheme</td>
|
|
<td></td>
|
|
<td>http</td>
|
|
<td>Scheme (http or https) to connect to Heapster as </td>
|
|
</tr>
|
|
<tr>
|
|
<td>heapster-service</td>
|
|
<td></td>
|
|
<td>heapster</td>
|
|
<td>Name of Heapster service </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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) </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>=NAMESPACE
|
|
</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/Storage) usage of pods.</p>
|
|
<p> The 'top pod' 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>$ 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>heapster-namespace</td>
|
|
<td></td>
|
|
<td>kube-system</td>
|
|
<td>Namespace Heapster service is located in </td>
|
|
</tr>
|
|
<tr>
|
|
<td>heapster-port</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Port name in service to use </td>
|
|
</tr>
|
|
<tr>
|
|
<td>heapster-scheme</td>
|
|
<td></td>
|
|
<td>http</td>
|
|
<td>Scheme (http or https) to connect to Heapster as </td>
|
|
</tr>
|
|
<tr>
|
|
<td>heapster-service</td>
|
|
<td></td>
|
|
<td>heapster</td>
|
|
<td>Name of Heapster service </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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) </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 "group/version"</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ api-versions</code></p>
|
|
<hr>
|
|
<h1 id="certificate">certificate</h1>
|
|
<p>Modify certificate resources.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ certificate SUBCOMMAND</code></p>
|
|
<hr>
|
|
<h2 id="-em-approve-em-"><em>approve</em></h2>
|
|
<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>$ 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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h2 id="-em-deny-em-"><em>deny</em></h2>
|
|
<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>$ 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'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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h1 id="cluster-info">cluster-info</h1>
|
|
<blockquote class="code-block example">
|
|
<p> Print the address of the master 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 master and services with label kubernetes.io/cluster-service=true To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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 cluster-info <span class="hljs-built_in">dump</span> <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>Dumps cluster info 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 'kube-system' 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>$ 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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output-directory</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Where to output the files. If empty or '-' 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>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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr>
|
|
<h1 id="cordon">cordon</h1>
|
|
<blockquote class="code-block example">
|
|
<p> Mark node "foo" 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>$ 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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 "foo", even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet on it.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell"><span class="hljs-meta">$</span><span class="bash"> kubectl drain foo --force</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> As above, but abort if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet, and use a grace period of 15 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. 'drain' evicts the pods if the APIServer supports<a href="http://kubernetes.io/docs/admin/disruptions/">http://kubernetes.io/docs/admin/disruptions/</a> . Otherwise, it will use normal DELETE to delete the pods. The 'drain' evicts or deletes all pods except mirror pods (which cannot be deleted through the API server). If there are DaemonSet-managed pods, drain will not proceed without --ignore-daemonsets, and regardless it will not delete any DaemonSet-managed pods, because those pods would be immediately replaced by the DaemonSet controller, which ignores unschedulable markings. If there are any pods that are neither mirror pods nor managed by ReplicationController, ReplicaSet, DaemonSet, StatefulSet 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> 'drain' 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="http://kubernetes.io/images/docs/kubectl_drain.svg">http://kubernetes.io/images/docs/kubectl_drain.svg</a></p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>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>dry-run</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>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>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 'foo' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule'. # If a taint with that key and effect already exists, its value is replaced as specified.</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 'foo' the taint with key 'dedicated' and effect 'NoSchedule' 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 'foo' all the taints with key 'dedicated'</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 'dedicated' 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>
|
|
<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 '/', like example.com/my-app</li>
|
|
<li>The value 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>$ 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>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|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 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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 "foo" as schedulable.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell"><span class="hljs-meta">$</span><span class="bash"> kubectl uncordon foo</span>
|
|
</code></pre>
|
|
<p>Mark node as schedulable.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </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>$ 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 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 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>$ 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't print headers (default print headers). </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: wide|name. </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"><span class="hljs-keyword">brew </span><span class="hljs-keyword">install </span><span class="hljs-keyword">bash-completion@2</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example#">
|
|
<p> If kubectl is installed via homebrew, this should start working immediately. ## If you'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"><span class="hljs-symbol">kubectl</span> completion <span class="hljs-keyword">bash </span>> $(<span class="hljs-keyword">brew </span>--prefix)/etc/<span class="hljs-keyword">bash_completion.d/kubectl</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Installing bash completion on Linux ## If bash-completion is not installed on Linux, please install the 'bash-completion' package ## via your distribution'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 <(<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 if from .bash_profile</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl completion bash > ~/.kube/completion<span class="hljs-selector-class">.bash</span><span class="hljs-selector-class">.inc</span>
|
|
printf <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">" >> <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 <(<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 > <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: <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion">https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion</a></p>
|
|
<p> Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ completion SHELL</code></p>
|
|
<hr>
|
|
<h1 id="config">config</h1>
|
|
<p>Modify kubeconfig files using subcommands like "kubectl config set current-context my-context"</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>$ 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>Displays the current-context</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>$ 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>$ delete-context NAME</code></p>
|
|
<hr>
|
|
<h2 id="-em-get-clusters-em-"><em>get-clusters</em></h2>
|
|
<blockquote class="code-block example">
|
|
<p> List the clusters 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>$ 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>Displays one or many contexts from the kubeconfig file.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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'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-rename-context-em-"><em>rename-context</em></h2>
|
|
<blockquote class="code-block example">
|
|
<p> Rename the context 'old-name' to 'new-name' 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 wish change.</p>
|
|
<p> NEW_NAME is the new name you wish to set.</p>
|
|
<p> Note: In case the context being renamed is the 'current-context', this field will also be updated.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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 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 config set clusters<span class="hljs-selector-class">.my-cluster</span><span class="hljs-selector-class">.server</span> https:<span class="hljs-comment">//1.2.3.4</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Set 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 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 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>Sets 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 wish to set. Binary fields such as 'certificate-authority-data' expect a base64 encoded string unless the --set-raw-bytes flag is used.</p>
|
|
<p> Specifying a attribute name that already exists will merge new fields on top of existing values.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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 []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 <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>
|
|
<p>Sets 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>$ set-cluster NAME [--server=server] [--certificate-authority=path/to/certificate/authority] [--insecure-skip-tls-verify=true]</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>Sets 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>$ 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 "client-key" field on the "cluster-admin" # 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 "cluster-admin" 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 "cluster-admin" 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 "cluster-admin" 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 "cluster-admin" 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 "client-secret" config value for the OpenID Connect auth provider for the "cluster-admin" 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>
|
|
<p>Sets 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>$ 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]</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>'key=value' 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>
|
|
</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>Unsets 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>$ 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>Sets the current-context in a kubeconfig file</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>$ 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|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>raw</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>Display raw byte data </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </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">kubectl explain pods<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> <type>.<fieldName>[.<fieldName>]</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 "kubectl api-resources" for a complete list of supported resources.</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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 </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="kustomize">kustomize</h1>
|
|
<blockquote class="code-block example">
|
|
<p> Use the current working directory</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl%20kustomize%20.
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Use some shared configuration directory</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl kustomize /<span class="hljs-built_in">home</span>/configuration/production
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Use a URL</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl kustomize github.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>Print a set of API resources generated from instructions in a kustomization.yaml file.</p>
|
|
<p> The argument must be the path to the directory containing the file, or a git repository URL with a path suffix specifying same with respect to the repository root.</p>
|
|
<p> kubectl kustomize somedir</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ kustomize <dir></code></p>
|
|
<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>$ 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>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ plugin [flags]</code></p>
|
|
<hr>
|
|
<h2 id="-em-list-em-"><em>list</em></h2>
|
|
<p>List all available plugin files on a user's PATH.</p>
|
|
<p> Available plugin files are those that are: - executable - anywhere on the user's PATH - begin with "kubectl-"</p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ 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>$ 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>Client version only (no server required). </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>One of 'yaml' or 'json'. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>short</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>Print just the version number. </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<h1 id="-strong-deprecated-commands-strong-"><strong>DEPRECATED COMMANDS</strong></h1>
|
|
<hr>
|
|
<h1 id="rolling-update">rolling-update</h1>
|
|
<blockquote class="code-block example">
|
|
<p> Update pods of frontend-v1 using new replication controller data in frontend-v2.json.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell"><span class="hljs-symbol">kubectl</span> rolling-update frontend-<span class="hljs-built_in">v1</span> -f frontend-<span class="hljs-built_in">v2</span>.json
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Update pods of frontend-v1 using JSON data passed into stdin.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell"><span class="hljs-keyword">cat</span> frontend-v2.json | kubectl <span class="hljs-keyword">rolling</span>-<span class="hljs-keyword">update</span> frontend-v1 -f -
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Update the pods of frontend-v1 to frontend-v2 by just changing the image, and switching the # name of the replication controller.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell"><span class="hljs-symbol">kubectl</span> rolling-update frontend-<span class="hljs-built_in">v1</span> frontend-<span class="hljs-built_in">v2</span> --image<span class="hljs-symbol">=image</span>:<span class="hljs-built_in">v2</span>
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Update the pods of frontend by just changing the image, and keeping the old name.</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell">kubectl rolling-update frontend --<span class="hljs-built_in">image</span>=<span class="hljs-built_in">image</span>:v2
|
|
</code></pre>
|
|
<blockquote class="code-block example">
|
|
<p> Abort and reverse an existing rollout in progress (from frontend-v1 to frontend-v2).</p>
|
|
</blockquote>
|
|
<pre class="code-block example"><code class="lang-shell"><span class="hljs-symbol">kubectl</span> rolling-update frontend-<span class="hljs-built_in">v1</span> frontend-<span class="hljs-built_in">v2</span> --rollback
|
|
</code></pre>
|
|
<p>Perform a rolling update of the given ReplicationController.</p>
|
|
<p> Replaces the specified replication controller with a new replication controller by updating one pod at a time to use the new PodTemplate. The new-controller.json must specify the same namespace as the existing replication controller and overwrite at least one (common) label in its replicaSelector.</p>
|
|
<p> <a href="http://kubernetes.io/images/docs/kubectl_rollingupdate.svg">http://kubernetes.io/images/docs/kubectl_rollingupdate.svg</a></p>
|
|
<h3 id="usage">Usage</h3>
|
|
<p><code>$ rolling-update OLD_CONTROLLER_NAME ([NEW_CONTROLLER_NAME] --image=NEW_CONTAINER_IMAGE | -f NEW_CONTROLLER_SPEC)</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>container</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Container name which will have its image upgraded. Only relevant when --image is specified, ignored otherwise. Required when using --image on a multi-container pod </td>
|
|
</tr>
|
|
<tr>
|
|
<td>deployment-label-key</td>
|
|
<td></td>
|
|
<td>deployment</td>
|
|
<td>The key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise </td>
|
|
</tr>
|
|
<tr>
|
|
<td>dry-run</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, only print the object that would be sent, without sending it. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>filename</td>
|
|
<td>f</td>
|
|
<td>[]</td>
|
|
<td>Filename or URL to file to use to create the new replication controller. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>image</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Image to use for upgrading the replication controller. Must be distinct from the existing image (either new image or new image tag). Can not be used with --filename/-f </td>
|
|
</tr>
|
|
<tr>
|
|
<td>image-pull-policy</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Explicit policy for when to pull container images. Required when --image is same as existing image, ignored otherwise. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>output</td>
|
|
<td>o</td>
|
|
<td></td>
|
|
<td>Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>poll-interval</td>
|
|
<td></td>
|
|
<td>3s</td>
|
|
<td>Time delay between polling for replication controller status after the update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". </td>
|
|
</tr>
|
|
<tr>
|
|
<td>rollback</td>
|
|
<td></td>
|
|
<td>false</td>
|
|
<td>If true, this is a request to abort an existing rollout that is partially rolled out. It effectively reverses current and next and runs a rollout </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 [<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
|
|
</tr>
|
|
<tr>
|
|
<td>timeout</td>
|
|
<td></td>
|
|
<td>5m0s</td>
|
|
<td>Max time to wait for a replication controller to update before giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". </td>
|
|
</tr>
|
|
<tr>
|
|
<td>update-period</td>
|
|
<td></td>
|
|
<td>1m0s</td>
|
|
<td>Time to wait between updating pods. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". </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>
|
|
</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> |