Commit a5746c9a authored by Jeff Lowdermilk's avatar Jeff Lowdermilk

Fix md generation for kubectl docs

Display usage string, not long help, as code, remove angle brackets from output (.md interprets as tags and hides).
parent 7d53425b
...@@ -65,10 +65,10 @@ func genMarkdown(command *cobra.Command, parent, docsDir string) { ...@@ -65,10 +65,10 @@ func genMarkdown(command *cobra.Command, parent, docsDir string) {
fmt.Fprintf(out, "## %s\n\n", name) fmt.Fprintf(out, "## %s\n\n", name)
fmt.Fprintf(out, "%s\n\n", short) fmt.Fprintf(out, "%s\n\n", short)
fmt.Fprintf(out, "### Synopsis\n\n") fmt.Fprintf(out, "### Synopsis\n\n")
fmt.Fprintf(out, "```\n%s\n```\n\n", long) fmt.Fprintf(out, "\n%s\n\n", long)
if command.Runnable() { if command.Runnable() {
fmt.Fprintf(out, "%s\n\n", command.UseLine()) fmt.Fprintf(out, "```\n%s\n```\n\n", command.UseLine())
} }
if len(command.Example) > 0 { if len(command.Example) > 0 {
......
...@@ -4,11 +4,12 @@ Display cluster info ...@@ -4,11 +4,12 @@ Display cluster info
### Synopsis ### Synopsis
```
Display addresses of the master and services with label kubernetes.io/cluster-service=true Display addresses of the master and services with label kubernetes.io/cluster-service=true
```
```
kubectl clusterinfo kubectl clusterinfo
```
### Options inherrited from parent commands ### Options inherrited from parent commands
......
...@@ -4,16 +4,26 @@ Sets a cluster entry in .kubeconfig ...@@ -4,16 +4,26 @@ Sets a cluster entry in .kubeconfig
### Synopsis ### Synopsis
Sets a cluster entry in .kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
```
kubectl config set-cluster NAME [--server=server] [--certificate-authority=path/to/certficate/authority] [--api-version=apiversion] [--insecure-skip-tls-verify=true]
``` ```
Sets a cluster entry in .kubeconfig
Specifying a name that already exists will merge new fields on top of existing values for those fields. ### Examples
e.g.
kubectl config set-cluster e2e --certificate-authority=~/.kube/e2e/.kubernetes.ca.cert
only sets the certificate-authority field on the e2e cluster entry without touching other values.
``` ```
// Set only the server field on the e2e cluster entry without touching other values.
$ kubectl config set-cluster e2e --server=https://1.2.3.4
// Embed certificate authority data for the e2e cluster entry
$ kubectl config set-cluster e2e --certificate-authority=~/.kube/e2e/kubernetes.ca.crt
kubectl config set-cluster name [--server=server] [--certificate-authority=path/to/certficate/authority] [--api-version=apiversion] [--insecure-skip-tls-verify=true] // Disable cert checking for the dev cluster entry
$ kubectl config set-cluster e2e --insecure-skip-tls-verify=true
```
### Options ### Options
......
...@@ -4,15 +4,20 @@ Sets a context entry in .kubeconfig ...@@ -4,15 +4,20 @@ Sets a context entry in .kubeconfig
### Synopsis ### Synopsis
```
Sets a context entry in .kubeconfig Sets a context entry in .kubeconfig
Specifying a name that already exists will merge new fields on top of existing values for those fields. Specifying a name that already exists will merge new fields on top of existing values for those fields.
e.g.
kubectl config set-context gce --user=cluster-admin ```
only sets the user field on the gce context entry without touching other values. kubectl config set-context NAME [--cluster=cluster_nickname] [--user=user_nickname] [--namespace=namespace]
``` ```
kubectl config set-context name [--cluster=cluster-nickname] [--user=user-nickname] [--namespace=namespace] ### Examples
```
// Set the user field on the gce context entry without touching other values
$ kubectl config set-context gce --user=cluster-admin
```
### Options inherrited from parent commands ### Options inherrited from parent commands
......
...@@ -4,14 +4,9 @@ Sets a user entry in .kubeconfig ...@@ -4,14 +4,9 @@ Sets a user entry in .kubeconfig
### Synopsis ### Synopsis
```
Sets a user entry in .kubeconfig
Specifying a name that already exists will merge new fields on top of existing
values. For example, the following only sets the "client-key" field on the
"cluster-admin" entry, without touching other values:
set-credentials cluster-admin --client-key=~/.kube/admin.key Sets a user entry in .kubeconfig
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags: Client-certificate flags:
--client-certificate=certfile --client-key=keyfile --client-certificate=certfile --client-key=keyfile
...@@ -24,9 +19,24 @@ Sets a user entry in .kubeconfig ...@@ -24,9 +19,24 @@ Sets a user entry in .kubeconfig
Bearer token and basic auth are mutually exclusive. Bearer token and basic auth are mutually exclusive.
```
kubectl config set-credentials NAME [--auth-path=/path/to/authfile] [--client-certificate=path/to/certfile] [--client-key=path/to/keyfile] [--token=bearer_token] [--username=basic_user] [--password=basic_password]
``` ```
kubectl config set-credentials name [--auth-path=authfile] [--client-certificate=certfile] [--client-key=keyfile] [--token=bearer_token] [--username=basic_user] [--password=basic_password] ### Examples
```
// Set only the "client-key" field on the "cluster-admin"
// entry, without touching other values:
$ kubectl set-credentials cluster-admin --client-key=~/.kube/admin.key
// Set basic auth for the "cluster-admin" entry
$ kubectl set-credentials cluster-admin --username=admin --password=uXFGweU9l35qcif
// Embed client certificate data in the "cluster-admin" entry
$ kubectl set-credentials cluster-admin --client-certificate=~/.kube/admin.crt --embed-certs=true
```
### Options ### Options
......
...@@ -4,16 +4,14 @@ Sets an individual value in a .kubeconfig file ...@@ -4,16 +4,14 @@ Sets an individual value in a .kubeconfig file
### Synopsis ### Synopsis
```
Sets an individual value in a .kubeconfig file
property-name is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
property-value is the new value you wish to set.
Sets an individual value in a .kubeconfig file
PROPERTY_NAME is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you wish to set.
``` ```
kubectl config set PROPERTY_NAME PROPERTY_VALUE
kubectl config set property-name property-value ```
### Options inherrited from parent commands ### Options inherrited from parent commands
......
...@@ -4,14 +4,13 @@ Unsets an individual value in a .kubeconfig file ...@@ -4,14 +4,13 @@ Unsets an individual value in a .kubeconfig file
### Synopsis ### Synopsis
```
Unsets an individual value in a .kubeconfig file
property-name is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots. Unsets an individual value in a .kubeconfig file
PROPERTY_NAME is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
``` ```
kubectl config unset PROPERTY_NAME
kubectl config unset property-name ```
### Options inherrited from parent commands ### Options inherrited from parent commands
......
...@@ -4,11 +4,12 @@ Sets the current-context in a .kubeconfig file ...@@ -4,11 +4,12 @@ Sets the current-context in a .kubeconfig file
### Synopsis ### Synopsis
```
Sets the current-context in a .kubeconfig file Sets the current-context in a .kubeconfig file
```
kubectl config use-context context-name ```
kubectl config use-context CONTEXT_NAME
```
### Options inherrited from parent commands ### Options inherrited from parent commands
......
...@@ -4,11 +4,14 @@ displays merged .kubeconfig settings or a specified .kubeconfig file. ...@@ -4,11 +4,14 @@ displays merged .kubeconfig settings or a specified .kubeconfig file.
### Synopsis ### Synopsis
```
displays merged .kubeconfig settings or a specified .kubeconfig file. displays merged .kubeconfig settings or a specified .kubeconfig file.
```
You can use --output=template --template=TEMPLATE to extract specific values.
```
kubectl config view kubectl config view
```
### Examples ### Examples
...@@ -18,6 +21,9 @@ $ kubectl config view ...@@ -18,6 +21,9 @@ $ kubectl config view
// Show only local ./.kubeconfig settings // Show only local ./.kubeconfig settings
$ kubectl config view --local $ kubectl config view --local
// Get the password for the e2e user
$ kubectl config view -o template --template='{{ index . "users" "e2e" "password" }}'
``` ```
### Options ### Options
......
...@@ -4,11 +4,12 @@ config modifies .kubeconfig files ...@@ -4,11 +4,12 @@ config modifies .kubeconfig files
### Synopsis ### Synopsis
```
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context" config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config <subcommand> ```
kubectl config SUBCOMMAND
```
### Options ### Options
......
...@@ -4,13 +4,14 @@ Create a resource by filename or stdin ...@@ -4,13 +4,14 @@ Create a resource by filename or stdin
### Synopsis ### Synopsis
```
Create a resource by filename or stdin. Create a resource by filename or stdin.
JSON and YAML formats are accepted. JSON and YAML formats are accepted.
```
kubectl create -f filename ```
kubectl create -f FILENAME
```
### Examples ### Examples
......
...@@ -4,7 +4,7 @@ Delete a resource by filename, stdin, or resource and ID. ...@@ -4,7 +4,7 @@ Delete a resource by filename, stdin, or resource and ID.
### Synopsis ### Synopsis
```
Delete a resource by filename, stdin, resource and ID, or by resources and label selector. Delete a resource by filename, stdin, resource and ID, or by resources and label selector.
JSON and YAML formats are accepted. JSON and YAML formats are accepted.
...@@ -15,9 +15,10 @@ arguments are used and the filename is ignored. ...@@ -15,9 +15,10 @@ arguments are used and the filename is ignored.
Note that the delete command does NOT do resource version checks, so if someone 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 submits an update to a resource right when you submit a delete, their update
will be lost along with the rest of the resource. will be lost along with the rest of the resource.
```
kubectl delete (-f filename | <resource> (<id> | -l <label> | --all)) ```
kubectl delete ([-f FILENAME] | (RESOURCE [(ID | -l label | --all)]
```
### Examples ### Examples
......
...@@ -4,14 +4,15 @@ Show details of a specific resource ...@@ -4,14 +4,15 @@ Show details of a specific resource
### Synopsis ### Synopsis
```
Show details of a specific resource. Show details of a specific resource.
This command joins many API calls together to form a detailed description of a This command joins many API calls together to form a detailed description of a
given resource. given resource.
```
kubectl describe <resource> <id> ```
kubectl describe RESOURCE ID
```
### Options inherrited from parent commands ### Options inherrited from parent commands
......
...@@ -4,11 +4,12 @@ Execute a command in a container. ...@@ -4,11 +4,12 @@ Execute a command in a container.
### Synopsis ### Synopsis
```
Execute a command in a container. Execute a command in a container.
```
kubectl exec -p <pod> -c <container> -- <command> [<args...>] ```
kubectl exec -p POD -c CONTAINER -- COMMAND [args...]
```
### Examples ### Examples
......
...@@ -4,14 +4,15 @@ Take a replicated application and expose it as Kubernetes Service ...@@ -4,14 +4,15 @@ Take a replicated application and expose it as Kubernetes Service
### Synopsis ### Synopsis
```
Take a replicated application and expose it as Kubernetes Service. Take a replicated application and expose it as Kubernetes Service.
Looks up a ReplicationController by name, and uses the selector for that replication controller Looks up a ReplicationController by name, and uses the selector for that replication controller
as the selector for a new Service on the specified port. as the selector for a new Service on the specified port.
```
kubectl expose <name> --port=<port> [--protocol=TCP|UDP] [--container-port=<number-or-name>] [--service-name=<name>] [--public-ip=<ip>] [--create-external-load-balancer] ```
kubectl expose NAME --port=port [--protocol=TCP|UDP] [--container-port=number-or-name] [--service-name=name] [--public-ip=ip] [--create-external-load-balancer=bool]
```
### Examples ### Examples
......
...@@ -4,7 +4,7 @@ Display one or many resources ...@@ -4,7 +4,7 @@ Display one or many resources
### Synopsis ### Synopsis
```
Display one or many resources. Display one or many resources.
Possible resources include pods (po), replication controllers (rc), services Possible resources include pods (po), replication controllers (rc), services
...@@ -12,9 +12,10 @@ Possible resources include pods (po), replication controllers (rc), services ...@@ -12,9 +12,10 @@ Possible resources include pods (po), replication controllers (rc), services
By specifying the output as 'template' and providing a Go template as the value By specifying the output as 'template' and providing a Go template as the value
of the --template flag, you can filter the attributes of the fetched resource(s). of the --template flag, you can filter the attributes of the fetched resource(s).
```
kubectl get [(-o|--output=)json|yaml|template|...] <resource> [<id>] ```
kubectl get [(-o|--output=)json|yaml|template|...] RESOURCE [ID]
```
### Examples ### Examples
......
...@@ -4,14 +4,15 @@ Update the labels on a resource ...@@ -4,14 +4,15 @@ Update the labels on a resource
### Synopsis ### Synopsis
```
Update the labels on a resource. Update the labels on a resource.
If --overwrite is true, then existing labels can be overwritten, otherwise attempting to overwrite a label will result in an error. If --overwrite is true, then existing labels can be overwritten, otherwise attempting to overwrite a label will result in an error.
If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used. If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used.
```
kubectl label [--overwrite] <resource> <name> <key-1>=<val-1> ... <key-n>=<val-n> [--resource-version=<version>] ```
kubectl label [--overwrite] RESOURCE NAME KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]
```
### Examples ### Examples
......
...@@ -4,11 +4,12 @@ Print the logs for a container in a pod. ...@@ -4,11 +4,12 @@ Print the logs for a container in a pod.
### Synopsis ### Synopsis
```
Print the logs for a container in a pod. If the pod has only one container, the container name is optional. Print the logs for a container in a pod. If the pod has only one container, the container name is optional.
```
kubectl log [-f] <pod> [<container>] ```
kubectl log [-f] POD [CONTAINER]
```
### Examples ### Examples
......
...@@ -4,14 +4,15 @@ SUPERCEDED: Set and view the current Kubernetes namespace ...@@ -4,14 +4,15 @@ SUPERCEDED: Set and view the current Kubernetes namespace
### Synopsis ### Synopsis
```
SUPERCEDED: Set and view the current Kubernetes namespace scope for command line requests. SUPERCEDED: Set and view the current Kubernetes namespace scope for command line requests.
namespace has been superceded by the context.namespace field of .kubeconfig files. See 'kubectl config set-context --help' for more details. namespace has been superceded by the context.namespace field of .kubeconfig files. See 'kubectl config set-context --help' for more details.
```
kubectl namespace [<namespace>] ```
kubectl namespace [namespace]
```
### Options inherrited from parent commands ### Options inherrited from parent commands
......
...@@ -4,26 +4,28 @@ Forward 1 or more local ports to a pod. ...@@ -4,26 +4,28 @@ Forward 1 or more local ports to a pod.
### Synopsis ### Synopsis
```
Forward 1 or more local ports to a pod. Forward 1 or more local ports to a pod.
```
kubectl port-forward -p <pod> [<local port>:]<remote port> [<port>...] ```
kubectl port-forward -p POD [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N]
```
### Examples ### Examples
``` ```
// listens on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
$ kubectl port-forward -p mypod 5000 6000 $ kubectl port-forward -p mypod 5000 6000
<listens on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod>
// listens on port 8888 locally, forwarding to 5000 in the pod
$ kubectl port-forward -p mypod 8888:5000 $ kubectl port-forward -p mypod 8888:5000
<listens on port 8888 locally, forwarding to 5000 in the pod>
// listens on a random port locally, forwarding to 5000 in the pod
$ kubectl port-forward -p mypod :5000 $ kubectl port-forward -p mypod :5000
<listens on a random port locally, forwarding to 5000 in the pod>
// listens on a random port locally, forwarding to 5000 in the pod
$ kubectl port-forward -p mypod 0:5000 $ kubectl port-forward -p mypod 0:5000
<listens on a random port locally, forwarding to 5000 in the pod>
``` ```
### Options ### Options
......
...@@ -4,11 +4,23 @@ Run a proxy to the Kubernetes API server ...@@ -4,11 +4,23 @@ Run a proxy to the Kubernetes API server
### Synopsis ### Synopsis
```
Run a proxy to the Kubernetes API server. Run a proxy to the Kubernetes API server.
```
kubectl proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix]
``` ```
kubectl proxy ### Examples
```
// Run a proxy to kubernetes apiserver on port 8011, serving static content from ./local/www/
$ kubectl proxy --port=8011 --www=./local/www/
// Run a proxy to kubernetes apiserver, changing the api prefix to k8s-api
// This makes e.g. the pods api available at localhost:8011/k8s-api/v1beta1/pods/
$ kubectl proxy --api-prefix=k8s-api
```
### Options ### Options
......
...@@ -4,16 +4,17 @@ Set a new size for a Replication Controller. ...@@ -4,16 +4,17 @@ Set a new size for a Replication Controller.
### Synopsis ### Synopsis
```
Set a new size for a Replication Controller. Set a new size for a Replication Controller.
Resize also allows users to specify one or more preconditions for the resize action. Resize also allows users to specify one or more preconditions for the resize action.
If --current-replicas or --resource-version is specified, it is validated before the If --current-replicas or --resource-version is specified, it is validated before the
resize is attempted, and it is guaranteed that the precondition holds true when the resize is attempted, and it is guaranteed that the precondition holds true when the
resize is sent to the server. resize is sent to the server.
```
kubectl resize [--resource-version=<version>] [--current-replicas=<count>] --replicas=<count> <resource> <id> ```
kubectl resize [--resource-version=version] [--current-replicas=count] --replicas=COUNT RESOURCE ID
```
### Examples ### Examples
......
...@@ -4,15 +4,16 @@ Perform a rolling update of the given ReplicationController. ...@@ -4,15 +4,16 @@ Perform a rolling update of the given ReplicationController.
### Synopsis ### Synopsis
```
Perform a rolling update of the given ReplicationController. Perform a rolling update of the given ReplicationController.
Replaces the specified controller with new controller, updating one pod at a time to use the Replaces the specified controller with new controller, updating one pod at a time to use the
new PodTemplate. The new-controller.json must specify the same namespace as the new PodTemplate. The new-controller.json must specify the same namespace as the
existing controller and overwrite at least one (common) label in its replicaSelector. existing controller and overwrite at least one (common) label in its replicaSelector.
```
kubectl rollingupdate <old-controller-name> -f <new-controller.json> ```
kubectl rollingupdate OLD_CONTROLLER_NAME -f NEW_CONTROLLER_SPEC
```
### Examples ### Examples
......
...@@ -4,12 +4,13 @@ Run a particular image on the cluster. ...@@ -4,12 +4,13 @@ Run a particular image on the cluster.
### Synopsis ### Synopsis
```
Create and run a particular image, possibly replicated. Create and run a particular image, possibly replicated.
Creates a replication controller to manage the created container(s). Creates a replication controller to manage the created container(s).
```
kubectl run-container <name> --image=<image> [--port=<port>] [--replicas=replicas] [--dry-run=<bool>] [--overrides=<inline-json>] ```
kubectl run-container NAME --image=image [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json]
```
### Examples ### Examples
......
...@@ -4,14 +4,15 @@ Gracefully shut down a resource by id or filename. ...@@ -4,14 +4,15 @@ Gracefully shut down a resource by id or filename.
### Synopsis ### Synopsis
```
Gracefully shut down a resource by id or filename. Gracefully shut down a resource by id or filename.
Attempts to shut down and delete a resource that supports graceful termination. Attempts to shut down and delete a resource that supports graceful termination.
If the resource is resizable it will be resized to 0 before deletion. If the resource is resizable it will be resized to 0 before deletion.
```
kubectl stop (-f filename | <resource> (<id> | -l <label> | --all)) ```
kubectl stop (-f FILENAME | RESOURCE (ID | -l label | --all))
```
### Examples ### Examples
......
...@@ -4,13 +4,14 @@ Update a resource by filename or stdin. ...@@ -4,13 +4,14 @@ Update a resource by filename or stdin.
### Synopsis ### Synopsis
```
Update a resource by filename or stdin. Update a resource by filename or stdin.
JSON and YAML formats are accepted. JSON and YAML formats are accepted.
```
kubectl update -f filename ```
kubectl update -f FILENAME
```
### Examples ### Examples
......
...@@ -4,11 +4,12 @@ Print the client and server version information. ...@@ -4,11 +4,12 @@ Print the client and server version information.
### Synopsis ### Synopsis
```
Print the client and server version information. Print the client and server version information.
```
```
kubectl version kubectl version
```
### Options ### Options
......
...@@ -4,13 +4,14 @@ kubectl controls the Kubernetes cluster manager ...@@ -4,13 +4,14 @@ kubectl controls the Kubernetes cluster manager
### Synopsis ### Synopsis
```
kubectl controls the Kubernetes cluster manager. kubectl controls the Kubernetes cluster manager.
Find more information at https://github.com/GoogleCloudPlatform/kubernetes. Find more information at https://github.com/GoogleCloudPlatform/kubernetes.
```
```
kubectl kubectl
```
### Options ### Options
......
...@@ -13,11 +13,8 @@ kubectl config set\-cluster \- Sets a cluster entry in .kubeconfig ...@@ -13,11 +13,8 @@ kubectl config set\-cluster \- Sets a cluster entry in .kubeconfig
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
Sets a cluster entry in .kubeconfig Sets a cluster entry in .kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields. Specifying a name that already exists will merge new fields on top of existing values for those fields.
e.g.
kubectl config set\-cluster e2e \-\-certificate\-authority=\~/.kube/e2e/.kubernetes.ca.cert
only sets the certificate\-authority field on the e2e cluster entry without touching other values.
.SH OPTIONS .SH OPTIONS
...@@ -144,6 +141,24 @@ Sets a cluster entry in .kubeconfig ...@@ -144,6 +141,24 @@ Sets a cluster entry in .kubeconfig
comma\-separated list of pattern=N settings for file\-filtered logging comma\-separated list of pattern=N settings for file\-filtered logging
.SH EXAMPLE
.PP
.RS
.nf
// Set only the server field on the e2e cluster entry without touching other values.
$ kubectl config set\-cluster e2e \-\-server=https://1.2.3.4
// Embed certificate authority data for the e2e cluster entry
$ kubectl config set\-cluster e2e \-\-certificate\-authority=\~/.kube/e2e/kubernetes.ca.crt
// Disable cert checking for the dev cluster entry
$ kubectl config set\-cluster e2e \-\-insecure\-skip\-tls\-verify=true
.fi
.RE
.SH SEE ALSO .SH SEE ALSO
.PP .PP
\fBkubectl\-config(1)\fP, \fBkubectl\-config(1)\fP,
......
...@@ -14,10 +14,7 @@ kubectl config set\-context \- Sets a context entry in .kubeconfig ...@@ -14,10 +14,7 @@ kubectl config set\-context \- Sets a context entry in .kubeconfig
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
Sets a context entry in .kubeconfig Sets a context entry in .kubeconfig
Specifying a name that already exists will merge new fields on top of existing values for those fields. Specifying a name that already exists will merge new fields on top of existing values for those fields.
e.g.
kubectl config set\-context gce \-\-user=cluster\-admin
only sets the user field on the gce context entry without touching other values.
.SH OPTIONS INHERITED FROM PARENT COMMANDS .SH OPTIONS INHERITED FROM PARENT COMMANDS
...@@ -138,6 +135,18 @@ Sets a context entry in .kubeconfig ...@@ -138,6 +135,18 @@ Sets a context entry in .kubeconfig
comma\-separated list of pattern=N settings for file\-filtered logging comma\-separated list of pattern=N settings for file\-filtered logging
.SH EXAMPLE
.PP
.RS
.nf
// Set the user field on the gce context entry without touching other values
$ kubectl config set\-context gce \-\-user=cluster\-admin
.fi
.RE
.SH SEE ALSO .SH SEE ALSO
.PP .PP
\fBkubectl\-config(1)\fP, \fBkubectl\-config(1)\fP,
......
...@@ -14,20 +14,7 @@ kubectl config set\-credentials \- Sets a user entry in .kubeconfig ...@@ -14,20 +14,7 @@ kubectl config set\-credentials \- Sets a user entry in .kubeconfig
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
Sets a user entry in .kubeconfig Sets a user entry in .kubeconfig
Specifying a name that already exists will merge new fields on top of existing values.
.PP
Specifying a name that already exists will merge new fields on top of existing
values. For example, the following only sets the "client\-key" field on the
"cluster\-admin" entry, without touching other values:
.PP
.RS
.nf
set\-credentials cluster\-admin \-\-client\-key=\~/.kube/admin.key
.fi
.RE
.PP .PP
Client\-certificate flags: Client\-certificate flags:
...@@ -169,6 +156,25 @@ Bearer token and basic auth are mutually exclusive. ...@@ -169,6 +156,25 @@ Bearer token and basic auth are mutually exclusive.
comma\-separated list of pattern=N settings for file\-filtered logging comma\-separated list of pattern=N settings for file\-filtered logging
.SH EXAMPLE
.PP
.RS
.nf
// Set only the "client\-key" field on the "cluster\-admin"
// entry, without touching other values:
$ kubectl set\-credentials cluster\-admin \-\-client\-key=\~/.kube/admin.key
// Set basic auth for the "cluster\-admin" entry
$ kubectl set\-credentials cluster\-admin \-\-username=admin \-\-password=uXFGweU9l35qcif
// Embed client certificate data in the "cluster\-admin" entry
$ kubectl set\-credentials cluster\-admin \-\-client\-certificate=\~/.kube/admin.crt \-\-embed\-certs=true
.fi
.RE
.SH SEE ALSO .SH SEE ALSO
.PP .PP
\fBkubectl\-config(1)\fP, \fBkubectl\-config(1)\fP,
......
...@@ -14,16 +14,8 @@ kubectl config set \- Sets an individual value in a .kubeconfig file ...@@ -14,16 +14,8 @@ kubectl config set \- Sets an individual value in a .kubeconfig file
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
Sets an individual value in a .kubeconfig file Sets an individual value in a .kubeconfig file
PROPERTY\_NAME is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
.PP PROPERTY\_VALUE is the new value you wish to set.
.RS
.nf
property\-name is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
property\-value is the new value you wish to set.
.fi
.RE
.SH OPTIONS INHERITED FROM PARENT COMMANDS .SH OPTIONS INHERITED FROM PARENT COMMANDS
......
...@@ -14,15 +14,7 @@ kubectl config unset \- Unsets an individual value in a .kubeconfig file ...@@ -14,15 +14,7 @@ kubectl config unset \- Unsets an individual value in a .kubeconfig file
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
Unsets an individual value in a .kubeconfig file Unsets an individual value in a .kubeconfig file
PROPERTY\_NAME is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
.PP
.RS
.nf
property\-name is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
.fi
.RE
.SH OPTIONS INHERITED FROM PARENT COMMANDS .SH OPTIONS INHERITED FROM PARENT COMMANDS
......
...@@ -15,6 +15,9 @@ kubectl config view \- displays merged .kubeconfig settings or a specified .kube ...@@ -15,6 +15,9 @@ kubectl config view \- displays merged .kubeconfig settings or a specified .kube
.PP .PP
displays merged .kubeconfig settings or a specified .kubeconfig file. displays merged .kubeconfig settings or a specified .kubeconfig file.
.PP
You can use \-\-output=template \-\-template=TEMPLATE to extract specific values.
.SH OPTIONS .SH OPTIONS
.PP .PP
...@@ -168,6 +171,9 @@ $ kubectl config view ...@@ -168,6 +171,9 @@ $ kubectl config view
// Show only local ./.kubeconfig settings // Show only local ./.kubeconfig settings
$ kubectl config view \-\-local $ kubectl config view \-\-local
// Get the password for the e2e user
$ kubectl config view \-o template \-\-template='\{\{ index . "users" "e2e" "password" \}\}'
.fi .fi
.RE .RE
......
...@@ -133,17 +133,18 @@ Forward 1 or more local ports to a pod. ...@@ -133,17 +133,18 @@ Forward 1 or more local ports to a pod.
.RS .RS
.nf .nf
// listens on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
$ kubectl port\-forward \-p mypod 5000 6000 $ kubectl port\-forward \-p mypod 5000 6000
<listens on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod>
// listens on port 8888 locally, forwarding to 5000 in the pod
$ kubectl port\-forward \-p mypod 8888:5000 $ kubectl port\-forward \-p mypod 8888:5000
<listens on port 8888 locally, forwarding to 5000 in the pod>
// listens on a random port locally, forwarding to 5000 in the pod
$ kubectl port\-forward \-p mypod :5000 $ kubectl port\-forward \-p mypod :5000
<listens on a random port locally, forwarding to 5000 in the pod>
// listens on a random port locally, forwarding to 5000 in the pod
$ kubectl port\-forward \-p mypod 0:5000 $ kubectl port\-forward \-p mypod 0:5000
<listens on a random port locally, forwarding to 5000 in the pod>
.fi .fi
.RE .RE
......
...@@ -140,6 +140,22 @@ Run a proxy to the Kubernetes API server. ...@@ -140,6 +140,22 @@ Run a proxy to the Kubernetes API server.
comma\-separated list of pattern=N settings for file\-filtered logging comma\-separated list of pattern=N settings for file\-filtered logging
.SH EXAMPLE
.PP
.RS
.nf
// Run a proxy to kubernetes apiserver on port 8011, serving static content from ./local/www/
$ kubectl proxy \-\-port=8011 \-\-www=./local/www/
// Run a proxy to kubernetes apiserver, changing the api prefix to k8s\-api
// This makes e.g. the pods api available at localhost:8011/k8s\-api/v1beta1/pods/
$ kubectl proxy \-\-api\-prefix=k8s\-api
.fi
.RE
.SH SEE ALSO .SH SEE ALSO
.PP .PP
\fBkubectl(1)\fP, \fBkubectl(1)\fP,
......
...@@ -40,7 +40,7 @@ func NewCmdConfig(out io.Writer) *cobra.Command { ...@@ -40,7 +40,7 @@ func NewCmdConfig(out io.Writer) *cobra.Command {
pathOptions := &pathOptions{} pathOptions := &pathOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "config <subcommand>", Use: "config SUBCOMMAND",
Short: "config modifies .kubeconfig files", Short: "config modifies .kubeconfig files",
Long: `config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"`, Long: `config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
......
...@@ -42,19 +42,8 @@ type createAuthInfoOptions struct { ...@@ -42,19 +42,8 @@ type createAuthInfoOptions struct {
embedCertData util.BoolFlag embedCertData util.BoolFlag
} }
func NewCmdConfigSetAuthInfo(out io.Writer, pathOptions *pathOptions) *cobra.Command { var create_authinfo_long = fmt.Sprintf(`Sets a user entry in .kubeconfig
options := &createAuthInfoOptions{pathOptions: pathOptions} Specifying a name that already exists will merge new fields on top of existing values.
cmd := &cobra.Command{
Use: fmt.Sprintf("set-credentials name [--%v=authfile] [--%v=certfile] [--%v=keyfile] [--%v=bearer_token] [--%v=basic_user] [--%v=basic_password]", clientcmd.FlagAuthPath, clientcmd.FlagCertFile, clientcmd.FlagKeyFile, clientcmd.FlagBearerToken, clientcmd.FlagUsername, clientcmd.FlagPassword),
Short: "Sets a user entry in .kubeconfig",
Long: fmt.Sprintf(`Sets a user entry in .kubeconfig
Specifying a name that already exists will merge new fields on top of existing
values. For example, the following only sets the "client-key" field on the
"cluster-admin" entry, without touching other values:
set-credentials cluster-admin --client-key=~/.kube/admin.key
Client-certificate flags: Client-certificate flags:
--%v=certfile --%v=keyfile --%v=certfile --%v=keyfile
...@@ -66,7 +55,26 @@ func NewCmdConfigSetAuthInfo(out io.Writer, pathOptions *pathOptions) *cobra.Com ...@@ -66,7 +55,26 @@ func NewCmdConfigSetAuthInfo(out io.Writer, pathOptions *pathOptions) *cobra.Com
--%v=basic_user --%v=basic_password --%v=basic_user --%v=basic_password
Bearer token and basic auth are mutually exclusive. Bearer token and basic auth are mutually exclusive.
`, clientcmd.FlagCertFile, clientcmd.FlagKeyFile, clientcmd.FlagBearerToken, clientcmd.FlagUsername, clientcmd.FlagPassword), `, clientcmd.FlagCertFile, clientcmd.FlagKeyFile, clientcmd.FlagBearerToken, clientcmd.FlagUsername, clientcmd.FlagPassword)
const create_authinfo_example = `// Set only the "client-key" field on the "cluster-admin"
// entry, without touching other values:
$ kubectl set-credentials cluster-admin --client-key=~/.kube/admin.key
// Set basic auth for the "cluster-admin" entry
$ kubectl set-credentials cluster-admin --username=admin --password=uXFGweU9l35qcif
// Embed client certificate data in the "cluster-admin" entry
$ kubectl set-credentials cluster-admin --client-certificate=~/.kube/admin.crt --embed-certs=true`
func NewCmdConfigSetAuthInfo(out io.Writer, pathOptions *pathOptions) *cobra.Command {
options := &createAuthInfoOptions{pathOptions: pathOptions}
cmd := &cobra.Command{
Use: fmt.Sprintf("set-credentials NAME [--%v=/path/to/authfile] [--%v=path/to/certfile] [--%v=path/to/keyfile] [--%v=bearer_token] [--%v=basic_user] [--%v=basic_password]", clientcmd.FlagAuthPath, clientcmd.FlagCertFile, clientcmd.FlagKeyFile, clientcmd.FlagBearerToken, clientcmd.FlagUsername, clientcmd.FlagPassword),
Short: "Sets a user entry in .kubeconfig",
Long: create_authinfo_long,
Example: create_authinfo_example,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if !options.complete(cmd) { if !options.complete(cmd) {
return return
......
...@@ -39,18 +39,27 @@ type createClusterOptions struct { ...@@ -39,18 +39,27 @@ type createClusterOptions struct {
embedCAData util.BoolFlag embedCAData util.BoolFlag
} }
const (
create_cluster_long = `Sets a cluster entry in .kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.`
create_cluster_example = `// Set only the server field on the e2e cluster entry without touching other values.
$ kubectl config set-cluster e2e --server=https://1.2.3.4
// Embed certificate authority data for the e2e cluster entry
$ kubectl config set-cluster e2e --certificate-authority=~/.kube/e2e/kubernetes.ca.crt
// Disable cert checking for the dev cluster entry
$ kubectl config set-cluster e2e --insecure-skip-tls-verify=true`
)
func NewCmdConfigSetCluster(out io.Writer, pathOptions *pathOptions) *cobra.Command { func NewCmdConfigSetCluster(out io.Writer, pathOptions *pathOptions) *cobra.Command {
options := &createClusterOptions{pathOptions: pathOptions} options := &createClusterOptions{pathOptions: pathOptions}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: fmt.Sprintf("set-cluster name [--%v=server] [--%v=path/to/certficate/authority] [--%v=apiversion] [--%v=true]", clientcmd.FlagAPIServer, clientcmd.FlagCAFile, clientcmd.FlagAPIVersion, clientcmd.FlagInsecure), Use: fmt.Sprintf("set-cluster NAME [--%v=server] [--%v=path/to/certficate/authority] [--%v=apiversion] [--%v=true]", clientcmd.FlagAPIServer, clientcmd.FlagCAFile, clientcmd.FlagAPIVersion, clientcmd.FlagInsecure),
Short: "Sets a cluster entry in .kubeconfig", Short: "Sets a cluster entry in .kubeconfig",
Long: `Sets a cluster entry in .kubeconfig Long: create_cluster_long,
Specifying a name that already exists will merge new fields on top of existing values for those fields. Example: create_cluster_example,
e.g.
kubectl config set-cluster e2e --certificate-authority=~/.kube/e2e/.kubernetes.ca.cert
only sets the certificate-authority field on the e2e cluster entry without touching other values.
`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if !options.complete(cmd) { if !options.complete(cmd) {
return return
......
...@@ -36,18 +36,21 @@ type createContextOptions struct { ...@@ -36,18 +36,21 @@ type createContextOptions struct {
namespace util.StringFlag namespace util.StringFlag
} }
const (
create_context_long = `Sets a context entry in .kubeconfig
Specifying a name that already exists will merge new fields on top of existing values for those fields.`
create_context_example = `// Set the user field on the gce context entry without touching other values
$ kubectl config set-context gce --user=cluster-admin`
)
func NewCmdConfigSetContext(out io.Writer, pathOptions *pathOptions) *cobra.Command { func NewCmdConfigSetContext(out io.Writer, pathOptions *pathOptions) *cobra.Command {
options := &createContextOptions{pathOptions: pathOptions} options := &createContextOptions{pathOptions: pathOptions}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: fmt.Sprintf("set-context name [--%v=cluster-nickname] [--%v=user-nickname] [--%v=namespace]", clientcmd.FlagClusterName, clientcmd.FlagAuthInfoName, clientcmd.FlagNamespace), Use: fmt.Sprintf("set-context NAME [--%v=cluster_nickname] [--%v=user_nickname] [--%v=namespace]", clientcmd.FlagClusterName, clientcmd.FlagAuthInfoName, clientcmd.FlagNamespace),
Short: "Sets a context entry in .kubeconfig", Short: "Sets a context entry in .kubeconfig",
Long: `Sets a context entry in .kubeconfig Long: create_context_long,
Specifying a name that already exists will merge new fields on top of existing values for those fields. Example: create_context_example,
e.g.
kubectl config set-context gce --user=cluster-admin
only sets the user field on the gce context entry without touching other values.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if !options.complete(cmd) { if !options.complete(cmd) {
return return
......
...@@ -39,18 +39,17 @@ type setOptions struct { ...@@ -39,18 +39,17 @@ type setOptions struct {
propertyValue string propertyValue string
} }
const set_long = `Sets an individual value in a .kubeconfig file
PROPERTY_NAME is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you wish to set.`
func NewCmdConfigSet(out io.Writer, pathOptions *pathOptions) *cobra.Command { func NewCmdConfigSet(out io.Writer, pathOptions *pathOptions) *cobra.Command {
options := &setOptions{pathOptions: pathOptions} options := &setOptions{pathOptions: pathOptions}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "set property-name property-value", Use: "set PROPERTY_NAME PROPERTY_VALUE",
Short: "Sets an individual value in a .kubeconfig file", Short: "Sets an individual value in a .kubeconfig file",
Long: `Sets an individual value in a .kubeconfig file Long: set_long,
property-name is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
property-value is the new value you wish to set.
`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if !options.complete(cmd) { if !options.complete(cmd) {
return return
......
...@@ -32,16 +32,16 @@ type unsetOptions struct { ...@@ -32,16 +32,16 @@ type unsetOptions struct {
propertyName string propertyName string
} }
const unset_long = `Unsets an individual value in a .kubeconfig file
PROPERTY_NAME is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.`
func NewCmdConfigUnset(out io.Writer, pathOptions *pathOptions) *cobra.Command { func NewCmdConfigUnset(out io.Writer, pathOptions *pathOptions) *cobra.Command {
options := &unsetOptions{pathOptions: pathOptions} options := &unsetOptions{pathOptions: pathOptions}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "unset property-name", Use: "unset PROPERTY_NAME",
Short: "Unsets an individual value in a .kubeconfig file", Short: "Unsets an individual value in a .kubeconfig file",
Long: `Unsets an individual value in a .kubeconfig file Long: unset_long,
property-name is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if !options.complete(cmd) { if !options.complete(cmd) {
return return
......
...@@ -35,7 +35,7 @@ func NewCmdConfigUseContext(out io.Writer, pathOptions *pathOptions) *cobra.Comm ...@@ -35,7 +35,7 @@ func NewCmdConfigUseContext(out io.Writer, pathOptions *pathOptions) *cobra.Comm
options := &useContextOptions{pathOptions: pathOptions} options := &useContextOptions{pathOptions: pathOptions}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "use-context context-name", Use: "use-context CONTEXT_NAME",
Short: "Sets the current-context in a .kubeconfig file", Short: "Sets the current-context in a .kubeconfig file",
Long: `Sets the current-context in a .kubeconfig file`, Long: `Sets the current-context in a .kubeconfig file`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
......
...@@ -35,18 +35,28 @@ type viewOptions struct { ...@@ -35,18 +35,28 @@ type viewOptions struct {
merge util.BoolFlag merge util.BoolFlag
} }
const (
view_long = `displays merged .kubeconfig settings or a specified .kubeconfig file.
You can use --output=template --template=TEMPLATE to extract specific values.`
view_example = `// Show merged .kubeconfig settings.
$ kubectl config view
// Show only local ./.kubeconfig settings
$ kubectl config view --local
// Get the password for the e2e user
$ kubectl config view -o template --template='{{ index . "users" "e2e" "password" }}'`
)
func NewCmdConfigView(out io.Writer, pathOptions *pathOptions) *cobra.Command { func NewCmdConfigView(out io.Writer, pathOptions *pathOptions) *cobra.Command {
options := &viewOptions{pathOptions: pathOptions} options := &viewOptions{pathOptions: pathOptions}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "view", Use: "view",
Short: "displays merged .kubeconfig settings or a specified .kubeconfig file.", Short: "displays merged .kubeconfig settings or a specified .kubeconfig file.",
Long: "displays merged .kubeconfig settings or a specified .kubeconfig file.", Long: view_long,
Example: `// Show merged .kubeconfig settings. Example: view_example,
$ kubectl config view
// Show only local ./.kubeconfig settings
$ kubectl config view --local`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
options.complete() options.complete()
......
...@@ -41,7 +41,7 @@ $ cat pod.json | kubectl create -f -` ...@@ -41,7 +41,7 @@ $ cat pod.json | kubectl create -f -`
func (f *Factory) NewCmdCreate(out io.Writer) *cobra.Command { func (f *Factory) NewCmdCreate(out io.Writer) *cobra.Command {
var filenames util.StringList var filenames util.StringList
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "create -f filename", Use: "create -f FILENAME",
Short: "Create a resource by filename or stdin", Short: "Create a resource by filename or stdin",
Long: create_long, Long: create_long,
Example: create_example, Example: create_example,
......
...@@ -58,7 +58,7 @@ $ kubectl delete pods --all` ...@@ -58,7 +58,7 @@ $ kubectl delete pods --all`
func (f *Factory) NewCmdDelete(out io.Writer) *cobra.Command { func (f *Factory) NewCmdDelete(out io.Writer) *cobra.Command {
var filenames util.StringList var filenames util.StringList
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "delete (-f filename | <resource> (<id> | -l <label> | --all))", Use: "delete ([-f FILENAME] | (RESOURCE [(ID | -l label | --all)]",
Short: "Delete a resource by filename, stdin, or resource and ID.", Short: "Delete a resource by filename, stdin, or resource and ID.",
Long: delete_long, Long: delete_long,
Example: delete_example, Example: delete_example,
......
...@@ -26,7 +26,7 @@ import ( ...@@ -26,7 +26,7 @@ import (
func (f *Factory) NewCmdDescribe(out io.Writer) *cobra.Command { func (f *Factory) NewCmdDescribe(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "describe <resource> <id>", Use: "describe RESOURCE ID",
Short: "Show details of a specific resource", Short: "Show details of a specific resource",
Long: `Show details of a specific resource. Long: `Show details of a specific resource.
......
...@@ -40,7 +40,7 @@ $ kubectl exec -p 123456-7890 -c ruby-container -i -t -- bash -il` ...@@ -40,7 +40,7 @@ $ kubectl exec -p 123456-7890 -c ruby-container -i -t -- bash -il`
func (f *Factory) NewCmdExec(cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command { func (f *Factory) NewCmdExec(cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "exec -p <pod> -c <container> -- <command> [<args...>]", Use: "exec -p POD -c CONTAINER -- COMMAND [args...]",
Short: "Execute a command in a container.", Short: "Execute a command in a container.",
Long: "Execute a command in a container.", Long: "Execute a command in a container.",
Example: exec_example, Example: exec_example,
...@@ -60,11 +60,11 @@ func (f *Factory) NewCmdExec(cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.C ...@@ -60,11 +60,11 @@ func (f *Factory) NewCmdExec(cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.C
func RunExec(f *Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cobra.Command, args []string) error { func RunExec(f *Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cobra.Command, args []string) error {
podName := util.GetFlagString(cmd, "pod") podName := util.GetFlagString(cmd, "pod")
if len(podName) == 0 { if len(podName) == 0 {
return util.UsageError(cmd, "<pod> is required for exec") return util.UsageError(cmd, "POD is required for exec")
} }
if len(args) < 1 { if len(args) < 1 {
return util.UsageError(cmd, "<command> is required for exec") return util.UsageError(cmd, "COMMAND is required for exec")
} }
namespace, err := f.DefaultNamespace(cmd) namespace, err := f.DefaultNamespace(cmd)
......
...@@ -41,7 +41,7 @@ $ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream ...@@ -41,7 +41,7 @@ $ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream
func (f *Factory) NewCmdExposeService(out io.Writer) *cobra.Command { func (f *Factory) NewCmdExposeService(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "expose <name> --port=<port> [--protocol=TCP|UDP] [--container-port=<number-or-name>] [--service-name=<name>] [--public-ip=<ip>] [--create-external-load-balancer]", Use: "expose NAME --port=port [--protocol=TCP|UDP] [--container-port=number-or-name] [--service-name=name] [--public-ip=ip] [--create-external-load-balancer=bool]",
Short: "Take a replicated application and expose it as Kubernetes Service", Short: "Take a replicated application and expose it as Kubernetes Service",
Long: expose_long, Long: expose_long,
Example: expose_example, Example: expose_example,
......
...@@ -58,7 +58,7 @@ $ kubectl get rc,services` ...@@ -58,7 +58,7 @@ $ kubectl get rc,services`
// retrieves one or more resources from a server. // retrieves one or more resources from a server.
func (f *Factory) NewCmdGet(out io.Writer) *cobra.Command { func (f *Factory) NewCmdGet(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "get [(-o|--output=)json|yaml|template|...] <resource> [<id>]", Use: "get [(-o|--output=)json|yaml|template|...] RESOURCE [ID]",
Short: "Display one or many resources", Short: "Display one or many resources",
Long: get_long, Long: get_long,
Example: get_example, Example: get_example,
......
...@@ -50,7 +50,7 @@ $ kubectl label pods foo bar-` ...@@ -50,7 +50,7 @@ $ kubectl label pods foo bar-`
func (f *Factory) NewCmdLabel(out io.Writer) *cobra.Command { func (f *Factory) NewCmdLabel(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "label [--overwrite] <resource> <name> <key-1>=<val-1> ... <key-n>=<val-n> [--resource-version=<version>]", Use: "label [--overwrite] RESOURCE NAME KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]",
Short: "Update the labels on a resource", Short: "Update the labels on a resource",
Long: label_long, Long: label_long,
Example: label_example, Example: label_example,
......
...@@ -59,7 +59,7 @@ func selectContainer(pod *api.Pod, in io.Reader, out io.Writer) string { ...@@ -59,7 +59,7 @@ func selectContainer(pod *api.Pod, in io.Reader, out io.Writer) string {
func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command { func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "log [-f] <pod> [<container>]", Use: "log [-f] POD [CONTAINER]",
Short: "Print the logs for a container in a pod.", Short: "Print the logs for a container in a pod.",
Long: "Print the logs for a container in a pod. If the pod has only one container, the container name is optional.", Long: "Print the logs for a container in a pod. If the pod has only one container, the container name is optional.",
Example: log_example, Example: log_example,
...@@ -75,11 +75,11 @@ func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command { ...@@ -75,11 +75,11 @@ func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command {
func RunLog(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error { func RunLog(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error {
if len(args) == 0 { if len(args) == 0 {
return util.UsageError(cmd, "<pod> is required for log") return util.UsageError(cmd, "POD is required for log")
} }
if len(args) > 2 { if len(args) > 2 {
return util.UsageError(cmd, "log <pod> [<container>]") return util.UsageError(cmd, "log POD [CONTAINER]")
} }
namespace, err := f.DefaultNamespace(cmd) namespace, err := f.DefaultNamespace(cmd)
......
...@@ -27,7 +27,7 @@ import ( ...@@ -27,7 +27,7 @@ import (
// TODO remove once people have been given enough time to notice // TODO remove once people have been given enough time to notice
func NewCmdNamespace(out io.Writer) *cobra.Command { func NewCmdNamespace(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "namespace [<namespace>]", Use: "namespace [namespace]",
Short: "SUPERCEDED: Set and view the current Kubernetes namespace", Short: "SUPERCEDED: Set and view the current Kubernetes namespace",
Long: `SUPERCEDED: Set and view the current Kubernetes namespace scope for command line requests. Long: `SUPERCEDED: Set and view the current Kubernetes namespace scope for command line requests.
......
...@@ -28,22 +28,23 @@ import ( ...@@ -28,22 +28,23 @@ import (
) )
const ( const (
portforward_example = `$ kubectl port-forward -p mypod 5000 6000 portforward_example = `
<listens on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod> // listens on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
$ kubectl port-forward -p mypod 5000 6000
// listens on port 8888 locally, forwarding to 5000 in the pod
$ kubectl port-forward -p mypod 8888:5000 $ kubectl port-forward -p mypod 8888:5000
<listens on port 8888 locally, forwarding to 5000 in the pod>
// listens on a random port locally, forwarding to 5000 in the pod
$ kubectl port-forward -p mypod :5000 $ kubectl port-forward -p mypod :5000
<listens on a random port locally, forwarding to 5000 in the pod>
$ kubectl port-forward -p mypod 0:5000 // listens on a random port locally, forwarding to 5000 in the pod
<listens on a random port locally, forwarding to 5000 in the pod> ` $ kubectl port-forward -p mypod 0:5000`
) )
func (f *Factory) NewCmdPortForward() *cobra.Command { func (f *Factory) NewCmdPortForward() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "port-forward -p <pod> [<local port>:]<remote port> [<port>...]", Use: "port-forward -p POD [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N]",
Short: "Forward 1 or more local ports to a pod.", Short: "Forward 1 or more local ports to a pod.",
Long: "Forward 1 or more local ports to a pod.", Long: "Forward 1 or more local ports to a pod.",
Example: portforward_example, Example: portforward_example,
...@@ -60,11 +61,11 @@ func (f *Factory) NewCmdPortForward() *cobra.Command { ...@@ -60,11 +61,11 @@ func (f *Factory) NewCmdPortForward() *cobra.Command {
func RunPortForward(f *Factory, cmd *cobra.Command, args []string) error { func RunPortForward(f *Factory, cmd *cobra.Command, args []string) error {
podName := util.GetFlagString(cmd, "pod") podName := util.GetFlagString(cmd, "pod")
if len(podName) == 0 { if len(podName) == 0 {
return util.UsageError(cmd, "<pod> is required for exec") return util.UsageError(cmd, "POD is required for exec")
} }
if len(args) < 1 { if len(args) < 1 {
return util.UsageError(cmd, "at least 1 <port> is required for port-forward") return util.UsageError(cmd, "at least 1 PORT is required for port-forward")
} }
namespace, err := f.DefaultNamespace(cmd) namespace, err := f.DefaultNamespace(cmd)
......
...@@ -27,11 +27,21 @@ import ( ...@@ -27,11 +27,21 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
const (
proxy_example = `// Run a proxy to kubernetes apiserver on port 8011, serving static content from ./local/www/
$ kubectl proxy --port=8011 --www=./local/www/
// Run a proxy to kubernetes apiserver, changing the api prefix to k8s-api
// This makes e.g. the pods api available at localhost:8011/k8s-api/v1beta1/pods/
$ kubectl proxy --api-prefix=k8s-api`
)
func (f *Factory) NewCmdProxy(out io.Writer) *cobra.Command { func (f *Factory) NewCmdProxy(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "proxy", Use: "proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix]",
Short: "Run a proxy to the Kubernetes API server", Short: "Run a proxy to the Kubernetes API server",
Long: `Run a proxy to the Kubernetes API server.`, Long: `Run a proxy to the Kubernetes API server. `,
Example: proxy_example,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
err := RunProxy(f, out, cmd) err := RunProxy(f, out, cmd)
util.CheckErr(err) util.CheckErr(err)
......
...@@ -47,7 +47,7 @@ $ kubectl resize --current-replicas=2 --replicas=3 replicationcontrollers foo` ...@@ -47,7 +47,7 @@ $ kubectl resize --current-replicas=2 --replicas=3 replicationcontrollers foo`
func (f *Factory) NewCmdResize(out io.Writer) *cobra.Command { func (f *Factory) NewCmdResize(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "resize [--resource-version=<version>] [--current-replicas=<count>] --replicas=<count> <resource> <id>", Use: "resize [--resource-version=version] [--current-replicas=count] --replicas=COUNT RESOURCE ID",
Short: "Set a new size for a Replication Controller.", Short: "Set a new size for a Replication Controller.",
Long: resize_long, Long: resize_long,
Example: resize_example, Example: resize_example,
...@@ -65,7 +65,7 @@ func (f *Factory) NewCmdResize(out io.Writer) *cobra.Command { ...@@ -65,7 +65,7 @@ func (f *Factory) NewCmdResize(out io.Writer) *cobra.Command {
func RunResize(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error { func RunResize(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error {
count := util.GetFlagInt(cmd, "replicas") count := util.GetFlagInt(cmd, "replicas")
if len(args) != 2 || count < 0 { if len(args) != 2 || count < 0 {
return util.UsageError(cmd, "--replicas=<count> <resource> <id>") return util.UsageError(cmd, "--replicas=COUNT RESOURCE ID")
} }
cmdNamespace, err := f.DefaultNamespace(cmd) cmdNamespace, err := f.DefaultNamespace(cmd)
......
...@@ -44,7 +44,7 @@ $ cat frontend-v2.json | kubectl rollingupdate frontend-v1 -f -` ...@@ -44,7 +44,7 @@ $ cat frontend-v2.json | kubectl rollingupdate frontend-v1 -f -`
func (f *Factory) NewCmdRollingUpdate(out io.Writer) *cobra.Command { func (f *Factory) NewCmdRollingUpdate(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "rollingupdate <old-controller-name> -f <new-controller.json>", Use: "rollingupdate OLD_CONTROLLER_NAME -f NEW_CONTROLLER_SPEC",
Short: "Perform a rolling update of the given ReplicationController.", Short: "Perform a rolling update of the given ReplicationController.",
Long: rollingupdate_long, Long: rollingupdate_long,
Example: rollingupdate_example, Example: rollingupdate_example,
......
...@@ -44,7 +44,7 @@ $ kubectl run-container nginx --image=dockerfile/nginx --overrides='{ "apiVersio ...@@ -44,7 +44,7 @@ $ kubectl run-container nginx --image=dockerfile/nginx --overrides='{ "apiVersio
func (f *Factory) NewCmdRunContainer(out io.Writer) *cobra.Command { func (f *Factory) NewCmdRunContainer(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "run-container <name> --image=<image> [--port=<port>] [--replicas=replicas] [--dry-run=<bool>] [--overrides=<inline-json>]", Use: "run-container NAME --image=image [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json]",
Short: "Run a particular image on the cluster.", Short: "Run a particular image on the cluster.",
Long: run_long, Long: run_long,
Example: run_example, Example: run_example,
...@@ -66,7 +66,7 @@ func (f *Factory) NewCmdRunContainer(out io.Writer) *cobra.Command { ...@@ -66,7 +66,7 @@ func (f *Factory) NewCmdRunContainer(out io.Writer) *cobra.Command {
func RunRunContainer(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error { func RunRunContainer(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error {
if len(args) != 1 { if len(args) != 1 {
return util.UsageError(cmd, "<name> is required for run-container") return util.UsageError(cmd, "NAME is required for run-container")
} }
namespace, err := f.DefaultNamespace(cmd) namespace, err := f.DefaultNamespace(cmd)
......
...@@ -49,7 +49,7 @@ func (f *Factory) NewCmdStop(out io.Writer) *cobra.Command { ...@@ -49,7 +49,7 @@ func (f *Factory) NewCmdStop(out io.Writer) *cobra.Command {
Filenames util.StringList Filenames util.StringList
}{} }{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "stop (-f filename | <resource> (<id> | -l <label> | --all))", Use: "stop (-f FILENAME | RESOURCE (ID | -l label | --all))",
Short: "Gracefully shut down a resource by id or filename.", Short: "Gracefully shut down a resource by id or filename.",
Long: stop_long, Long: stop_long,
Example: stop_example, Example: stop_example,
......
...@@ -43,7 +43,7 @@ $ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState": ...@@ -43,7 +43,7 @@ $ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState":
func (f *Factory) NewCmdUpdate(out io.Writer) *cobra.Command { func (f *Factory) NewCmdUpdate(out io.Writer) *cobra.Command {
var filenames util.StringList var filenames util.StringList
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "update -f filename", Use: "update -f FILENAME",
Short: "Update a resource by filename or stdin.", Short: "Update a resource by filename or stdin.",
Long: update_long, Long: update_long,
Example: update_example, Example: update_example,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment