mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 21:12:07 +00:00
Change all cobra commands to use the example section
This will output the examples in their own section, rather than as part of the 'long' synposis.
This commit is contained in:
parent
781ca91a59
commit
d508395828
@ -46,8 +46,7 @@ func NewCmdConfigSetContext(out io.Writer, pathOptions *pathOptions) *cobra.Comm
|
||||
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.
|
||||
`,
|
||||
only sets the user field on the gce context entry without touching other values.`,
|
||||
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if !options.complete(cmd) {
|
||||
|
@ -41,13 +41,12 @@ func NewCmdConfigView(out io.Writer, pathOptions *pathOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "view",
|
||||
Short: "displays merged .kubeconfig settings or a specified .kubeconfig file.",
|
||||
Long: `displays merged .kubeconfig settings or a specified .kubeconfig file.
|
||||
Examples:
|
||||
// Show merged .kubeconfig settings.
|
||||
$ kubectl config view
|
||||
Long: "displays merged .kubeconfig settings or a specified .kubeconfig file.",
|
||||
Example: `// Show merged .kubeconfig settings.
|
||||
$ kubectl config view
|
||||
|
||||
// Show only local ./.kubeconfig settings
|
||||
$ kubectl config view --local`,
|
||||
// Show only local ./.kubeconfig settings
|
||||
$ kubectl config view --local`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
options.complete()
|
||||
|
||||
|
@ -26,24 +26,26 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
create_long = `Create a resource by filename or stdin.
|
||||
|
||||
JSON and YAML formats are accepted.`
|
||||
create_example = `// Create a pod using the data in pod.json.
|
||||
$ kubectl create -f pod.json
|
||||
|
||||
// Create a pod based on the JSON passed into stdin.
|
||||
$ cat pod.json | kubectl create -f -`
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdCreate(out io.Writer) *cobra.Command {
|
||||
flags := &struct {
|
||||
Filenames util.StringList
|
||||
}{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "create -f filename",
|
||||
Short: "Create a resource by filename or stdin",
|
||||
Long: `Create a resource by filename or stdin.
|
||||
|
||||
JSON and YAML formats are accepted.
|
||||
|
||||
Examples:
|
||||
|
||||
// Create a pod using the data in pod.json.
|
||||
$ kubectl create -f pod.json
|
||||
|
||||
// Create a pod based on the JSON passed into stdin.
|
||||
$ cat pod.json | kubectl create -f -`,
|
||||
Use: "create -f filename",
|
||||
Short: "Create a resource by filename or stdin",
|
||||
Long: create_long,
|
||||
Example: create_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
schema, err := f.Validator(cmd)
|
||||
checkErr(err)
|
||||
|
@ -28,14 +28,8 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdDelete(out io.Writer) *cobra.Command {
|
||||
flags := &struct {
|
||||
Filenames util.StringList
|
||||
}{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "delete ([-f filename] | (<resource> [(<id> | -l <label> | --all)]",
|
||||
Short: "Delete a resource by filename, stdin, or resource and ID.",
|
||||
Long: `Delete a resource by filename, stdin, resource and ID, or by resources and label selector.
|
||||
const (
|
||||
delete_long = `Delete a resource by filename, stdin, resource and ID, or by resources and label selector.
|
||||
|
||||
JSON and YAML formats are accepted.
|
||||
|
||||
@ -44,25 +38,32 @@ arguments are used and the filename is ignored.
|
||||
|
||||
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.
|
||||
will be lost along with the rest of the resource.`
|
||||
delete_example = `// Delete a pod using the type and ID specified in pod.json.
|
||||
$ kubectl delete -f pod.json
|
||||
|
||||
Examples:
|
||||
// Delete a pod based on the type and ID in the JSON passed into stdin.
|
||||
$ cat pod.json | kubectl delete -f -
|
||||
|
||||
// Delete a pod using the type and ID specified in pod.json.
|
||||
$ kubectl delete -f pod.json
|
||||
// Delete pods and services with label name=myLabel.
|
||||
$ kubectl delete pods,services -l name=myLabel
|
||||
|
||||
// Delete a pod based on the type and ID in the JSON passed into stdin.
|
||||
$ cat pod.json | kubectl delete -f -
|
||||
// Delete a pod with ID 1234-56-7890-234234-456456.
|
||||
$ kubectl delete pod 1234-56-7890-234234-456456
|
||||
|
||||
// Delete pods and services with label name=myLabel.
|
||||
$ kubectl delete pods,services -l name=myLabel
|
||||
|
||||
// Delete a pod with ID 1234-56-7890-234234-456456.
|
||||
$ kubectl delete pod 1234-56-7890-234234-456456
|
||||
|
||||
// Delete all pods
|
||||
$ kubectl delete pods --all`,
|
||||
// Delete all pods
|
||||
$ kubectl delete pods --all`
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdDelete(out io.Writer) *cobra.Command {
|
||||
flags := &struct {
|
||||
Filenames util.StringList
|
||||
}{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "delete ([-f filename] | (<resource> [(<id> | -l <label> | --all)]",
|
||||
Short: "Delete a resource by filename, stdin, or resource and ID.",
|
||||
Long: delete_long,
|
||||
Example: delete_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cmdNamespace, err := f.DefaultNamespace(cmd)
|
||||
checkErr(err)
|
||||
|
@ -30,6 +30,14 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
exec_example = `// get output from running 'date' in ruby-container from pod 123456-7890
|
||||
$ kubectl exec -p 123456-7890 -c ruby-container date
|
||||
|
||||
//switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-780 and sends stdout/stderr from 'bash' back to the client
|
||||
$ 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 {
|
||||
flags := &struct {
|
||||
pod string
|
||||
@ -39,16 +47,10 @@ func (f *Factory) NewCmdExec(cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.C
|
||||
}{}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "exec -p <pod> -c <container> -- <command> [<args...>]",
|
||||
Short: "Execute a command in a container.",
|
||||
Long: `Execute a command in a container.
|
||||
Examples:
|
||||
$ kubectl exec -p 123456-7890 -c ruby-container date
|
||||
<returns output from running 'date' in ruby-container from pod 123456-7890>
|
||||
|
||||
$ kubectl exec -p 123456-7890 -c ruby-container -i -t -- bash -il
|
||||
<switches to raw terminal mode, sends stdin to 'bash' in ruby-container from
|
||||
pod 123456-780 and sends stdout/stderr from 'bash' back to the client`,
|
||||
Use: "exec -p <pod> -c <container> -- <command> [<args...>]",
|
||||
Short: "Execute a command in a container.",
|
||||
Long: "Execute a command in a container.",
|
||||
Example: exec_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(flags.pod) == 0 {
|
||||
usageError(cmd, "<pod> is required for exec")
|
||||
|
@ -26,22 +26,25 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdExposeService(out io.Writer) *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]",
|
||||
Short: "Take a replicated application and expose it as Kubernetes Service",
|
||||
Long: `Take a replicated application and expose it as Kubernetes Service.
|
||||
const (
|
||||
expose_long = `Take a replicated application and expose it as Kubernetes Service.
|
||||
|
||||
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.`
|
||||
|
||||
Examples:
|
||||
expose_example = `// Creates a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
|
||||
$ kubectl expose nginx --port=80 --container-port=8000
|
||||
|
||||
// Creates a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
|
||||
$ kubectl expose nginx --port=80 --container-port=8000
|
||||
// Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.
|
||||
$ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream`
|
||||
)
|
||||
|
||||
// Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.
|
||||
$ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream`,
|
||||
func (f *Factory) NewCmdExposeService(out io.Writer) *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]",
|
||||
Short: "Take a replicated application and expose it as Kubernetes Service",
|
||||
Long: expose_long,
|
||||
Example: expose_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(args) != 1 {
|
||||
usageError(cmd, "<name> is required for expose")
|
||||
|
@ -30,36 +30,38 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// NewCmdGet creates a command object for the generic "get" action, which
|
||||
// retrieves one or more resources from a server.
|
||||
func (f *Factory) NewCmdGet(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "get [(-o|--output=)json|yaml|template|...] <resource> [<id>]",
|
||||
Short: "Display one or many resources",
|
||||
Long: `Display one or many resources.
|
||||
const (
|
||||
get_long = `Display one or many resources.
|
||||
|
||||
Possible resources include pods (po), replication controllers (rc), services
|
||||
(se), minions (mi), or events (ev).
|
||||
|
||||
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).`
|
||||
get_example = `// List all pods in ps output format.
|
||||
$ kubectl get pods
|
||||
|
||||
Examples:
|
||||
// List a single replication controller with specified ID in ps output format.
|
||||
$ kubectl get replicationController 1234-56-7890-234234-456456
|
||||
|
||||
// List all pods in ps output format.
|
||||
$ kubectl get pods
|
||||
// List a single pod in JSON output format.
|
||||
$ kubectl get -o json pod 1234-56-7890-234234-456456
|
||||
|
||||
// List a single replication controller with specified ID in ps output format.
|
||||
$ kubectl get replicationController 1234-56-7890-234234-456456
|
||||
// Return only the status value of the specified pod.
|
||||
$ kubectl get -o template pod 1234-56-7890-234234-456456 --template={{.currentState.status}}
|
||||
|
||||
// List a single pod in JSON output format.
|
||||
$ kubectl get -o json pod 1234-56-7890-234234-456456
|
||||
// List all replication controllers and services together in ps output format.
|
||||
$ kubectl get rc,services`
|
||||
)
|
||||
|
||||
// Return only the status value of the specified pod.
|
||||
$ kubectl get -o template pod 1234-56-7890-234234-456456 --template={{.currentState.status}}
|
||||
|
||||
// List all replication controllers and services together in ps output format.
|
||||
$ kubectl get rc,services`,
|
||||
// NewCmdGet creates a command object for the generic "get" action, which
|
||||
// retrieves one or more resources from a server.
|
||||
func (f *Factory) NewCmdGet(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "get [(-o|--output=)json|yaml|template|...] <resource> [<id>]",
|
||||
Short: "Display one or many resources",
|
||||
Long: get_long,
|
||||
Example: get_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
RunGet(f, out, cmd, args)
|
||||
},
|
||||
|
@ -29,28 +29,31 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdLabel(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "label [--overwrite] <resource> <name> <key-1>=<val-1> ... <key-n>=<val-n> [--resource-version=<version>]",
|
||||
Short: "Update the labels on a resource",
|
||||
Long: `Update the labels on a resource.
|
||||
const (
|
||||
label_long = `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 --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.`
|
||||
label_example = `// Update pod 'foo' with the label 'unhealthy' and the value 'true'.
|
||||
$ kubectl label pods foo unhealthy=true
|
||||
|
||||
Examples:
|
||||
// Update pod 'foo' with the label 'unhealthy' and the value 'true'.
|
||||
$ kubectl label pods foo unhealthy=true
|
||||
// Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value.
|
||||
$ kubectl label --overwrite pods foo status=unhealthy
|
||||
|
||||
// Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value.
|
||||
$ kubectl label --overwrite pods foo status=unhealthy
|
||||
|
||||
// Update pod 'foo' only if the resource is unchanged from version 1.
|
||||
$ kubectl label pods foo status=unhealthy --resource-version=1
|
||||
|
||||
// Update pod 'foo' by removing a label named 'bar' if it exists.
|
||||
// Does not require the --overwrite flag.
|
||||
$ kubectl label pods foo bar-`,
|
||||
// Update pod 'foo' only if the resource is unchanged from version 1.
|
||||
$ kubectl label pods foo status=unhealthy --resource-version=1
|
||||
|
||||
// Update pod 'foo' by removing a label named 'bar' if it exists.
|
||||
// Does not require the --overwrite flag.
|
||||
$ kubectl label pods foo bar-`
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdLabel(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "label [--overwrite] <resource> <name> <key-1>=<val-1> ... <key-n>=<val-n> [--resource-version=<version>]",
|
||||
Short: "Update the labels on a resource",
|
||||
Long: label_long,
|
||||
Example: label_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(args) < 2 {
|
||||
usageError(cmd, "<resource> <name> is required")
|
||||
|
@ -24,19 +24,20 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
log_example = `// Returns snapshot of ruby-container logs from pod 123456-7890.
|
||||
$ kubectl log 123456-7890 ruby-container
|
||||
|
||||
// Starts streaming of ruby-container logs from pod 123456-7890.
|
||||
$ kubectl log -f 123456-7890 ruby-container`
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "log [-f] <pod> [<container>]",
|
||||
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.
|
||||
|
||||
Examples:
|
||||
|
||||
// Returns snapshot of ruby-container logs from pod 123456-7890.
|
||||
$ kubectl log 123456-7890 ruby-container
|
||||
|
||||
// Starts streaming of ruby-container logs from pod 123456-7890.
|
||||
$ kubectl log -f 123456-7890 ruby-container`,
|
||||
Use: "log [-f] <pod> [<container>]",
|
||||
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.",
|
||||
Example: log_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(args) == 0 {
|
||||
usageError(cmd, "<pod> is required for log")
|
||||
|
@ -26,6 +26,20 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
portforward_example = `$ 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>
|
||||
|
||||
$ kubectl port-forward -p mypod 8888:5000
|
||||
<listens on port 8888 locally, forwarding to 5000 in the pod>
|
||||
|
||||
$ 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> `
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdPortForward() *cobra.Command {
|
||||
flags := &struct {
|
||||
pod string
|
||||
@ -33,23 +47,10 @@ func (f *Factory) NewCmdPortForward() *cobra.Command {
|
||||
}{}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "port-forward -p <pod> [<local port>:]<remote port> [<port>...]",
|
||||
Short: "Forward 1 or more local ports to a pod.",
|
||||
Long: `Forward 1 or more local ports to a pod.
|
||||
Examples:
|
||||
$ 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>
|
||||
|
||||
$ kubectl port-forward -p mypod 8888:5000
|
||||
<listens on port 8888 locally, forwarding to 5000 in the pod>
|
||||
|
||||
$ 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>
|
||||
`,
|
||||
Use: "port-forward -p <pod> [<local port>:]<remote port> [<port>...]",
|
||||
Short: "Forward 1 or more local ports to a pod.",
|
||||
Long: "Forward 1 or more local ports to a pod.",
|
||||
Example: portforward_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(flags.pod) == 0 {
|
||||
usageError(cmd, "<pod> is required for exec")
|
||||
|
@ -25,24 +25,26 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdResize(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "resize [--resource-version=<version>] [--current-replicas=<count>] --replicas=<count> <resource> <id>",
|
||||
Short: "Set a new size for a Replication Controller.",
|
||||
Long: `Set a new size for a Replication Controller.
|
||||
const (
|
||||
resize_long = `Set a new size for a Replication Controller.
|
||||
|
||||
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
|
||||
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.`
|
||||
resize_example = `// Resize replication controller named 'foo' to 3.
|
||||
$ kubectl resize --replicas=3 replicationcontrollers foo
|
||||
|
||||
Examples:
|
||||
// If the replication controller named foo's current size is 2, resize foo to 3.
|
||||
$ kubectl resize --current-replicas=2 --replicas=3 replicationcontrollers foo`
|
||||
)
|
||||
|
||||
// Resize replication controller named 'foo' to 3.
|
||||
$ kubectl resize --replicas=3 replicationcontrollers foo
|
||||
|
||||
// If the replication controller named foo's current size is 2, resize foo to 3.
|
||||
$ kubectl resize --current-replicas=2 --replicas=3 replicationcontrollers foo`,
|
||||
func (f *Factory) NewCmdResize(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "resize [--resource-version=<version>] [--current-replicas=<count>] --replicas=<count> <resource> <id>",
|
||||
Short: "Set a new size for a Replication Controller.",
|
||||
Long: resize_long,
|
||||
Example: resize_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
count := util.GetFlagInt(cmd, "replicas")
|
||||
if len(args) != 2 || count < 0 {
|
||||
|
@ -27,28 +27,27 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
updatePeriod = "1m0s"
|
||||
timeout = "5m0s"
|
||||
pollInterval = "3s"
|
||||
updatePeriod = "1m0s"
|
||||
timeout = "5m0s"
|
||||
pollInterval = "3s"
|
||||
rollingupdate_long = `Perform a rolling update of the given ReplicationController.
|
||||
|
||||
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
|
||||
existing controller and overwrite at least one (common) label in its replicaSelector.`
|
||||
rollingupdate_example = `// Update pods of frontend-v1 using new controller data in frontend-v2.json.
|
||||
$ kubectl rollingupdate frontend-v1 -f frontend-v2.json
|
||||
|
||||
// Update pods of frontend-v1 using JSON data passed into stdin.
|
||||
$ cat frontend-v2.json | kubectl rollingupdate frontend-v1 -f -`
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdRollingUpdate(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "rollingupdate <old-controller-name> -f <new-controller.json>",
|
||||
Short: "Perform a rolling update of the given ReplicationController.",
|
||||
Long: `Perform a rolling update of the given ReplicationController.
|
||||
|
||||
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
|
||||
existing controller and overwrite at least one (common) label in its replicaSelector.
|
||||
|
||||
Examples:
|
||||
|
||||
// Update pods of frontend-v1 using new controller data in frontend-v2.json.
|
||||
$ kubectl rollingupdate frontend-v1 -f frontend-v2.json
|
||||
|
||||
// Update pods of frontend-v1 using JSON data passed into stdin.
|
||||
$ cat frontend-v2.json | kubectl rollingupdate frontend-v1 -f -`,
|
||||
Use: "rollingupdate <old-controller-name> -f <new-controller.json>",
|
||||
Short: "Perform a rolling update of the given ReplicationController.",
|
||||
Long: rollingupdate_long,
|
||||
Example: rollingupdate_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
filename := util.GetFlagString(cmd, "filename")
|
||||
if len(filename) == 0 {
|
||||
|
@ -26,26 +26,28 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
run_long = `Create and run a particular image, possibly replicated.
|
||||
Creates a replication controller to manage the created container(s).`
|
||||
run_example = `// Starts a single instance of nginx.
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx
|
||||
|
||||
// Starts a replicated instance of nginx.
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx --replicas=5
|
||||
|
||||
// Dry run. Print the corresponding API objects without creating them.
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx --dry-run
|
||||
|
||||
// Start a single instance of nginx, but overload the desired state with a partial set of values parsed from JSON.
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx --overrides='{ "apiVersion": "v1beta1", "desiredState": { ... } }'`
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdRunContainer(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "run-container <name> --image=<image> [--port=<port>] [--replicas=replicas] [--dry-run=<bool>] [--overrides=<inline-json>]",
|
||||
Short: "Run a particular image on the cluster.",
|
||||
Long: `Create and run a particular image, possibly replicated.
|
||||
Creates a replication controller to manage the created container(s).
|
||||
|
||||
Examples:
|
||||
|
||||
// Starts a single instance of nginx.
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx
|
||||
|
||||
// Starts a replicated instance of nginx.
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx --replicas=5
|
||||
|
||||
// Dry run. Print the corresponding API objects without creating them.
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx --dry-run
|
||||
|
||||
// Start a single instance of nginx, but overload the desired state with a partial set of values parsed from JSON.
|
||||
$ kubectl run-container nginx --image=dockerfile/nginx --overrides='{ "apiVersion": "v1beta1", "desiredState": { ... } }'`,
|
||||
Use: "run-container <name> --image=<image> [--port=<port>] [--replicas=replicas] [--dry-run=<bool>] [--overrides=<inline-json>]",
|
||||
Short: "Run a particular image on the cluster.",
|
||||
Long: run_long,
|
||||
Example: run_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(args) != 1 {
|
||||
usageError(cmd, "<name> is required for run-container")
|
||||
|
@ -25,28 +25,30 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
stop_long = `Gracefully shut down a resource by id or filename.
|
||||
|
||||
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.`
|
||||
stop_example = `// Shut down foo.
|
||||
$ kubectl stop replicationcontroller foo
|
||||
|
||||
// Shut down the service defined in service.json
|
||||
$ kubectl stop -f service.json
|
||||
|
||||
// Shut down all resources in the path/to/resources directory
|
||||
$ kubectl stop -f path/to/resources`
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdStop(out io.Writer) *cobra.Command {
|
||||
flags := &struct {
|
||||
Filenames util.StringList
|
||||
}{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "stop (<resource> <id>|-f filename)",
|
||||
Short: "Gracefully shut down a resource by id or filename.",
|
||||
Long: `Gracefully shut down a resource by id or filename.
|
||||
|
||||
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.
|
||||
|
||||
Examples:
|
||||
|
||||
// Shut down foo.
|
||||
$ kubectl stop replicationcontroller foo
|
||||
|
||||
// Shut down the service defined in service.json
|
||||
$ kubectl stop -f service.json
|
||||
|
||||
// Shut down all resources in the path/to/resources directory
|
||||
$ kubectl stop -f path/to/resources`,
|
||||
Use: "stop (<resource> <id>|-f filename)",
|
||||
Short: "Gracefully shut down a resource by id or filename.",
|
||||
Long: stop_long,
|
||||
Example: stop_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cmdNamespace, err := f.DefaultNamespace(cmd)
|
||||
checkErr(err)
|
||||
|
@ -26,27 +26,29 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
update_long = `Update a resource by filename or stdin.
|
||||
|
||||
JSON and YAML formats are accepted.`
|
||||
update_example = `// Update a pod using the data in pod.json.
|
||||
$ kubectl update -f pod.json
|
||||
|
||||
// Update a pod based on the JSON passed into stdin.
|
||||
$ cat pod.json | kubectl update -f -
|
||||
|
||||
// Update a pod by downloading it, applying the patch, then updating. Requires apiVersion be specified.
|
||||
$ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState": { "manifest": [{ "cpu": 100 }]}}'`
|
||||
)
|
||||
|
||||
func (f *Factory) NewCmdUpdate(out io.Writer) *cobra.Command {
|
||||
flags := &struct {
|
||||
Filenames util.StringList
|
||||
}{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "update -f filename",
|
||||
Short: "Update a resource by filename or stdin.",
|
||||
Long: `Update a resource by filename or stdin.
|
||||
|
||||
JSON and YAML formats are accepted.
|
||||
|
||||
Examples:
|
||||
|
||||
// Update a pod using the data in pod.json.
|
||||
$ kubectl update -f pod.json
|
||||
|
||||
// Update a pod based on the JSON passed into stdin.
|
||||
$ cat pod.json | kubectl update -f -
|
||||
|
||||
// Update a pod by downloading it, applying the patch, then updating. Requires apiVersion be specified.
|
||||
$ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState": { "manifest": [{ "cpu": 100 }]}}'`,
|
||||
Use: "update -f filename",
|
||||
Short: "Update a resource by filename or stdin.",
|
||||
Long: update_long,
|
||||
Example: update_example,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
schema, err := f.Validator(cmd)
|
||||
checkErr(err)
|
||||
|
Loading…
Reference in New Issue
Block a user