Make naming of kubectl subcommands consistent

pull/6/head
Sam Ghods 2015-03-27 16:24:59 -07:00
parent 620af16892
commit ca18e86877
22 changed files with 235 additions and 48 deletions

View File

@ -40,7 +40,7 @@ echo "... calling validate-cluster" >&2
"${KUBE_ROOT}/cluster/validate-cluster.sh" "${KUBE_ROOT}/cluster/validate-cluster.sh"
echo -e "Done, listing cluster services:\n" >&2 echo -e "Done, listing cluster services:\n" >&2
"${KUBE_ROOT}/cluster/kubectl.sh" clusterinfo "${KUBE_ROOT}/cluster/kubectl.sh" cluster-info
echo echo
exit 0 exit 0

View File

@ -2,4 +2,4 @@
Solutions to interesting problems and unique implementations that showcase the extensibility of Kubernetes Solutions to interesting problems and unique implementations that showcase the extensibility of Kubernetes
- [Automated APIServer load balancing using Hipache and Fleet](docs/apiserver_hipache_registration.md) - [Automated APIServer load balancing using Hipache and Fleet](docs/apiserver_hipache_registration.md)
- [Jenkins-triggered rolling updates on sucessful "builds"](docs/rollingupdates_from_jenkins.md) - [Jenkins-triggered rolling updates on sucessful "builds"](docs/rolling_updates_from_jenkins.md)

View File

@ -0,0 +1,57 @@
###How To
For our example, Jenkins is set up to have one build step in bash:
`Jenkins "Bash" build step`
```
#!/bin/bash
cd $WORKSPACE
source bin/jenkins.sh
source bin/kube-rolling.sh
```
Our project's build script (`bin/jenkins.sh`), is followed by our new kube-rolling script. Jenkins already has `$BUILD_NUMBER` set, but we need a few other variables that are set in `jenkins.sh` that we reference in `kube-rolling.sh`:
```
DOCKER_IMAGE="path_webteam/public"
REGISTRY_LOCATION="dockerreg.web.local/"
```
Jenkins builds our container, tags it with the build number, and runs a couple rudimentary tests on it. On success, it pushes it to our private docker registry. Once the container is pushed, it then executes our rolling update script.
`kube-rolling.sh`
```
#!/bin/bash
# KUBERNETES_MASTER: Your Kubernetes API Server endpoint
# BINARY_LOCATION: Location of pre-compiled Binaries (We build our own, there are others available)
# CONTROLLER_NAME: Name of the replicationController you're looking to update
# RESET_INTERVAL: Interval between pod updates
export KUBERNETES_MASTER="http://10.1.10.1:8080"
BINARY_LOCATION="https://build.web.local/kubernetes/"
CONTROLLER_NAME="public-frontend-controller"
RESET_INTERVAL="10s"
echo "*** Time to push to Kubernetes!";
#Delete then graba kubecfg binary from a static location
rm kubecfg
wget $BINARY_LOCATION/kubecfg
echo "*** Downloaded binary from $BINARY_LOCATION/kubecfg"
chmod +x kubecfg
# Update the controller with your new image!
echo "*** ./kubecfg -image \"$REGISTRY_LOCATION$DOCKER_IMAGE:$BUILD_NUMBER\" -u $RESET_INTERVAL rollingupdate $CONTROLLER_NAME"
./kubecfg -image "$REGISTRY_LOCATION$DOCKER_IMAGE:$BUILD_NUMBER" -u $RESET_INTERVAL rollingupdate $CONTROLLER_NAME
```
Though basic, this implementation allows our Jenkins instance to push container updates to our Kubernetes cluster without much trouble.
### Notes
When using a private docker registry as we are, the Jenkins slaves as well as the Kubernetes minions require the [.dockercfg](https://coreos.com/docs/launching-containers/building/customizing-docker/#using-a-dockercfg-file-for-authentication) file in order to function properly.
### Questions
twitter @jeefy
irc.freenode.net #kubernetes jeefy

View File

@ -42,8 +42,8 @@ Jenkins builds our container, tags it with the build number, and runs a couple r
chmod +x kubecfg chmod +x kubecfg
# Update the controller with your new image! # Update the controller with your new image!
echo "*** ./kubecfg -image \"$REGISTRY_LOCATION$DOCKER_IMAGE:$BUILD_NUMBER\" -u $RESET_INTERVAL rollingupdate $CONTROLLER_NAME" echo "*** ./kubecfg -image \"$REGISTRY_LOCATION$DOCKER_IMAGE:$BUILD_NUMBER\" -u $RESET_INTERVAL rolling-update $CONTROLLER_NAME"
./kubecfg -image "$REGISTRY_LOCATION$DOCKER_IMAGE:$BUILD_NUMBER" -u $RESET_INTERVAL rollingupdate $CONTROLLER_NAME ./kubecfg -image "$REGISTRY_LOCATION$DOCKER_IMAGE:$BUILD_NUMBER" -u $RESET_INTERVAL rolling-update $CONTROLLER_NAME
``` ```
Though basic, this implementation allows our Jenkins instance to push container updates to our Kubernetes cluster without much trouble. Though basic, this implementation allows our Jenkins instance to push container updates to our Kubernetes cluster without much trouble.

View File

@ -11,7 +11,7 @@ See also issues with the following labels:
1. Service address/port lookup command(s) 1. Service address/port lookup command(s)
1. Finish rolling update [#1353](https://github.com/GoogleCloudPlatform/kubernetes/issues/1353) 1. Finish rolling update [#1353](https://github.com/GoogleCloudPlatform/kubernetes/issues/1353)
1. Friendly to auto-scaling [#2863](https://github.com/GoogleCloudPlatform/kubernetes/pull/2863#issuecomment-69701562) 1. Friendly to auto-scaling [#2863](https://github.com/GoogleCloudPlatform/kubernetes/pull/2863#issuecomment-69701562)
1. Rollback (make rollingupdate reversible, and complete an in-progress rolling update by taking 2 replication controller names rather than always taking a file) 1. Rollback (make rolling-update reversible, and complete an in-progress rolling update by taking 2 replication controller names rather than always taking a file)
1. Rollover (replace multiple replication controllers with one, such as to clean up an aborted partial rollout) 1. Rollover (replace multiple replication controllers with one, such as to clean up an aborted partial rollout)
1. Write a ReplicationController generator to derive the new ReplicationController from an old one (e.g., `--image-version=newversion`, which would apply a name suffix, update a label value, and apply an image tag) 1. Write a ReplicationController generator to derive the new ReplicationController from an old one (e.g., `--image-version=newversion`, which would apply a name suffix, update a label value, and apply an image tag)
1. Use readiness [#620](https://github.com/GoogleCloudPlatform/kubernetes/issues/620) 1. Use readiness [#620](https://github.com/GoogleCloudPlatform/kubernetes/issues/620)

View File

@ -0,0 +1,52 @@
## kubectl api-versions
Print available API versions.
### Synopsis
Print available API versions.
```
kubectl api-versions
```
### Options
```
-h, --help=false: help for api-versions
```
### Options inherrited from parent commands
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--kubeconfig="": Path to the kubeconfig file to use for CLI requests.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
### SEE ALSO
* [kubectl](kubectl.md)

View File

@ -1,4 +1,4 @@
## kubectl apiversions ## kubectl api-versions
Print available API versions. Print available API versions.
@ -8,13 +8,13 @@ Print available API versions.
Print available API versions. Print available API versions.
``` ```
kubectl apiversions kubectl api-versions
``` ```
### Options ### Options
``` ```
-h, --help=false: help for apiversions -h, --help=false: help for api-versions
``` ```
### Options inherrited from parent commands ### Options inherrited from parent commands

View File

@ -0,0 +1,52 @@
## kubectl cluster-info
Display cluster info
### Synopsis
Display addresses of the master and services with label kubernetes.io/cluster-service=true
```
kubectl cluster-info
```
### Options
```
-h, --help=false: help for cluster-info
```
### Options inherrited from parent commands
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--kubeconfig="": Path to the kubeconfig file to use for CLI requests.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
### SEE ALSO
* [kubectl](kubectl.md)

View File

@ -1,4 +1,4 @@
## kubectl clusterinfo ## kubectl cluster-info
Display cluster info Display cluster info
@ -8,13 +8,13 @@ Display cluster info
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 cluster-info
``` ```
### Options ### Options
``` ```
-h, --help=false: help for clusterinfo -h, --help=false: help for cluster-info
``` ```
### Options inherrited from parent commands ### Options inherrited from parent commands

View File

@ -1,4 +1,4 @@
## kubectl rollingupdate ## kubectl rolling-update
Perform a rolling update of the given ReplicationController. Perform a rolling update of the given ReplicationController.
@ -12,24 +12,24 @@ 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_SPEC kubectl rolling-update OLD_CONTROLLER_NAME -f NEW_CONTROLLER_SPEC
``` ```
### Examples ### Examples
``` ```
// Update pods of frontend-v1 using new controller data in frontend-v2.json. // Update pods of frontend-v1 using new controller data in frontend-v2.json.
$ kubectl rollingupdate frontend-v1 -f frontend-v2.json $ kubectl rolling-update frontend-v1 -f frontend-v2.json
// Update pods of frontend-v1 using JSON data passed into stdin. // Update pods of frontend-v1 using JSON data passed into stdin.
$ cat frontend-v2.json | kubectl rollingupdate frontend-v1 -f - $ cat frontend-v2.json | kubectl rolling-update frontend-v1 -f -
``` ```
### Options ### Options
``` ```
-f, --filename="": Filename or URL to file to use to create the new controller. -f, --filename="": Filename or URL to file to use to create the new controller.
-h, --help=false: help for rollingupdate -h, --help=false: help for rolling-update
--poll-interval="3s": Time delay between polling controller status after update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". --poll-interval="3s": Time delay between polling controller status after update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
--timeout="5m0s": Max time to wait for a controller to update before giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". --timeout="5m0s": Max time to wait for a controller to update before giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
--update-period="1m0s": Time to wait between updating pods. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". --update-period="1m0s": Time to wait between updating pods. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

View File

@ -52,7 +52,7 @@ kubectl
* [kubectl-delete](kubectl-delete.md) * [kubectl-delete](kubectl-delete.md)
* [kubectl-namespace](kubectl-namespace.md) * [kubectl-namespace](kubectl-namespace.md)
* [kubectl-log](kubectl-log.md) * [kubectl-log](kubectl-log.md)
* [kubectl-rollingupdate](kubectl-rollingupdate.md) * [kubectl-rolling-update](kubectl-rolling-update.md)
* [kubectl-resize](kubectl-resize.md) * [kubectl-resize](kubectl-resize.md)
* [kubectl-exec](kubectl-exec.md) * [kubectl-exec](kubectl-exec.md)
* [kubectl-port-forward](kubectl-port-forward.md) * [kubectl-port-forward](kubectl-port-forward.md)
@ -62,7 +62,7 @@ kubectl
* [kubectl-expose](kubectl-expose.md) * [kubectl-expose](kubectl-expose.md)
* [kubectl-label](kubectl-label.md) * [kubectl-label](kubectl-label.md)
* [kubectl-config](kubectl-config.md) * [kubectl-config](kubectl-config.md)
* [kubectl-clusterinfo](kubectl-clusterinfo.md) * [kubectl-cluster-info](kubectl-cluster-info.md)
* [kubectl-apiversions](kubectl-apiversions.md) * [kubectl-api-versions](kubectl-api-versions.md)
* [kubectl-version](kubectl-version.md) * [kubectl-version](kubectl-version.md)

View File

@ -3,12 +3,12 @@
.SH NAME .SH NAME
.PP .PP
kubectl apiversions \- Print available API versions. kubectl api\-versions \- Print available API versions.
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\fBkubectl apiversions\fP [OPTIONS] \fBkubectl api\-versions\fP [OPTIONS]
.SH DESCRIPTION .SH DESCRIPTION
@ -19,7 +19,7 @@ Print available API versions.
.SH OPTIONS .SH OPTIONS
.PP .PP
\fB\-h\fP, \fB\-\-help\fP=false \fB\-h\fP, \fB\-\-help\fP=false
help for apiversions help for api\-versions
.SH OPTIONS INHERITED FROM PARENT COMMANDS .SH OPTIONS INHERITED FROM PARENT COMMANDS

View File

@ -3,12 +3,12 @@
.SH NAME .SH NAME
.PP .PP
kubectl clusterinfo \- Display cluster info kubectl cluster\-info \- Display cluster info
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\fBkubectl clusterinfo\fP [OPTIONS] \fBkubectl cluster\-info\fP [OPTIONS]
.SH DESCRIPTION .SH DESCRIPTION
@ -19,7 +19,7 @@ Display addresses of the master and services with label kubernetes.io/cluster\-s
.SH OPTIONS .SH OPTIONS
.PP .PP
\fB\-h\fP, \fB\-\-help\fP=false \fB\-h\fP, \fB\-\-help\fP=false
help for clusterinfo help for cluster\-info
.SH OPTIONS INHERITED FROM PARENT COMMANDS .SH OPTIONS INHERITED FROM PARENT COMMANDS

View File

@ -3,12 +3,12 @@
.SH NAME .SH NAME
.PP .PP
kubectl rollingupdate \- Perform a rolling update of the given ReplicationController. kubectl rolling\-update \- Perform a rolling update of the given ReplicationController.
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\fBkubectl rollingupdate\fP [OPTIONS] \fBkubectl rolling\-update\fP [OPTIONS]
.SH DESCRIPTION .SH DESCRIPTION
@ -28,7 +28,7 @@ existing controller and overwrite at least one (common) label in its replicaSele
.PP .PP
\fB\-h\fP, \fB\-\-help\fP=false \fB\-h\fP, \fB\-\-help\fP=false
help for rollingupdate help for rolling\-update
.PP .PP
\fB\-\-poll\-interval\fP="3s" \fB\-\-poll\-interval\fP="3s"
@ -151,10 +151,10 @@ existing controller and overwrite at least one (common) label in its replicaSele
.nf .nf
// Update pods of frontend\-v1 using new controller data in frontend\-v2.json. // Update pods of frontend\-v1 using new controller data in frontend\-v2.json.
$ kubectl rollingupdate frontend\-v1 \-f frontend\-v2.json $ kubectl rolling\-update frontend\-v1 \-f frontend\-v2.json
// Update pods of frontend\-v1 using JSON data passed into stdin. // Update pods of frontend\-v1 using JSON data passed into stdin.
$ cat frontend\-v2.json | kubectl rollingupdate frontend\-v1 \-f \- $ cat frontend\-v2.json | kubectl rolling\-update frontend\-v1 \-f \-
.fi .fi
.RE .RE

View File

@ -128,7 +128,7 @@ Find more information at
.SH SEE ALSO .SH SEE ALSO
.PP .PP
\fBkubectl\-get(1)\fP, \fBkubectl\-describe(1)\fP, \fBkubectl\-create(1)\fP, \fBkubectl\-update(1)\fP, \fBkubectl\-delete(1)\fP, \fBkubectl\-namespace(1)\fP, \fBkubectl\-log(1)\fP, \fBkubectl\-rollingupdate(1)\fP, \fBkubectl\-resize(1)\fP, \fBkubectl\-exec(1)\fP, \fBkubectl\-port\-forward(1)\fP, \fBkubectl\-proxy(1)\fP, \fBkubectl\-run\-container(1)\fP, \fBkubectl\-stop(1)\fP, \fBkubectl\-expose(1)\fP, \fBkubectl\-label(1)\fP, \fBkubectl\-config(1)\fP, \fBkubectl\-clusterinfo(1)\fP, \fBkubectl\-apiversions(1)\fP, \fBkubectl\-version(1)\fP, \fBkubectl\-get(1)\fP, \fBkubectl\-describe(1)\fP, \fBkubectl\-create(1)\fP, \fBkubectl\-update(1)\fP, \fBkubectl\-delete(1)\fP, \fBkubectl\-namespace(1)\fP, \fBkubectl\-log(1)\fP, \fBkubectl\-rolling\-update(1)\fP, \fBkubectl\-resize(1)\fP, \fBkubectl\-exec(1)\fP, \fBkubectl\-port\-forward(1)\fP, \fBkubectl\-proxy(1)\fP, \fBkubectl\-run\-container(1)\fP, \fBkubectl\-stop(1)\fP, \fBkubectl\-expose(1)\fP, \fBkubectl\-label(1)\fP, \fBkubectl\-config(1)\fP, \fBkubectl\-cluster\-info(1)\fP, \fBkubectl\-api\-versions(1)\fP, \fBkubectl\-version(1)\fP,
.SH HISTORY .SH HISTORY

View File

@ -36,7 +36,7 @@ The replication controller simply ensures that the desired number of pods matche
The replication controller is forever constrained to this narrow responsibility. It itself will not perform readiness nor liveness probes. Rather than performing auto-scaling, it is intended to be controlled by an external auto-scaler (as discussed in [#492](https://github.com/GoogleCloudPlatform/kubernetes/issues/492)), which would change its `replicas` field. We will not add scheduling policies (e.g., [spreading](https://github.com/GoogleCloudPlatform/kubernetes/issues/367#issuecomment-48428019)) to replication controller. Nor should it verify that the pods controlled match the currently specified template, as that would obstruct auto-sizing and other automated processes. Similarly, completion deadlines, ordering dependencies, configuration expansion, and other features belong elsewhere. We even plan to factor out the mechanism for bulk pod creation ([#170](https://github.com/GoogleCloudPlatform/kubernetes/issues/170)). The replication controller is forever constrained to this narrow responsibility. It itself will not perform readiness nor liveness probes. Rather than performing auto-scaling, it is intended to be controlled by an external auto-scaler (as discussed in [#492](https://github.com/GoogleCloudPlatform/kubernetes/issues/492)), which would change its `replicas` field. We will not add scheduling policies (e.g., [spreading](https://github.com/GoogleCloudPlatform/kubernetes/issues/367#issuecomment-48428019)) to replication controller. Nor should it verify that the pods controlled match the currently specified template, as that would obstruct auto-sizing and other automated processes. Similarly, completion deadlines, ordering dependencies, configuration expansion, and other features belong elsewhere. We even plan to factor out the mechanism for bulk pod creation ([#170](https://github.com/GoogleCloudPlatform/kubernetes/issues/170)).
The replication controller is intended to be a composable building-block primitive. We expect higher-level APIs and/or tools to be built on top of it and other complementary primitives for user convenience in the future. The "macro" operations currently supported by kubectl (run-container, stop, resize, rollingupdate) are proof-of-concept examples of this. For instance, we could imagine something like [Asgard](http://techblog.netflix.com/2012/06/asgard-web-based-cloud-management-and.html) managing replication controllers, auto-scalers, services, scheduling policies, canaries, etc. The replication controller is intended to be a composable building-block primitive. We expect higher-level APIs and/or tools to be built on top of it and other complementary primitives for user convenience in the future. The "macro" operations currently supported by kubectl (run-container, stop, resize, rolling-update) are proof-of-concept examples of this. For instance, we could imagine something like [Asgard](http://techblog.netflix.com/2012/06/asgard-web-based-cloud-management-and.html) managing replication controllers, auto-scalers, services, scheduling policies, canaries, etc.
## Common usage patterns ## Common usage patterns

View File

@ -61,9 +61,9 @@ If you go back to the [demo website](http://localhost:8001/static/index.html) yo
We will now update the docker image to serve a different image by doing a rolling update to a new Docker image. We will now update the docker image to serve a different image by doing a rolling update to a new Docker image.
```bash ```bash
$ ./cluster/kubectl.sh rollingupdate update-demo-nautilus --update-period=10s -f examples/update-demo/v1beta1/kitten-rc.yaml $ ./cluster/kubectl.sh rolling-update update-demo-nautilus --update-period=10s -f examples/update-demo/v1beta1/kitten-rc.yaml
``` ```
The rollingupdate command in kubectl will do 2 things: The rolling-update command in kubectl will do 2 things:
1. Create a new replication controller with a pod template that uses the new image (`gcr.io/google_containers/update-demo:kitten`) 1. Create a new replication controller with a pod template that uses the new image (`gcr.io/google_containers/update-demo:kitten`)
2. Resize the old and new replication controllers until the new controller replaces the old. This will kill the current pods one at a time, spinnning up new ones to replace them. 2. Resize the old and new replication controllers until the new controller replaces the old. This will kill the current pods one at a time, spinnning up new ones to replace them.

View File

@ -18,6 +18,7 @@ package cmd
import ( import (
"io" "io"
"os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -27,8 +28,10 @@ import (
func (f *Factory) NewCmdApiVersions(out io.Writer) *cobra.Command { func (f *Factory) NewCmdApiVersions(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "apiversions", Use: "api-versions",
Short: "Print available API versions.", // apiversions is deprecated.
Aliases: []string{"apiversions"},
Short: "Print available API versions.",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
err := RunApiVersions(f, out) err := RunApiVersions(f, out)
util.CheckErr(err) util.CheckErr(err)
@ -38,6 +41,10 @@ func (f *Factory) NewCmdApiVersions(out io.Writer) *cobra.Command {
} }
func RunApiVersions(f *Factory, out io.Writer) error { func RunApiVersions(f *Factory, out io.Writer) error {
if os.Args[1] == "apiversions" {
printDeprecationWarning("api-versions", "apiversions")
}
client, err := f.Client() client, err := f.Client()
if err != nil { if err != nil {
return err return err

View File

@ -19,6 +19,7 @@ package cmd
import ( import (
"fmt" "fmt"
"io" "io"
"os"
"strings" "strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
@ -31,9 +32,11 @@ import (
func (f *Factory) NewCmdClusterInfo(out io.Writer) *cobra.Command { func (f *Factory) NewCmdClusterInfo(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "clusterinfo", Use: "cluster-info",
Short: "Display cluster info", // clusterinfo is deprecated.
Long: "Display addresses of the master and services with label kubernetes.io/cluster-service=true", Aliases: []string{"clusterinfo"},
Short: "Display cluster info",
Long: "Display addresses of the master and services with label kubernetes.io/cluster-service=true",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
err := RunClusterInfo(f, out, cmd) err := RunClusterInfo(f, out, cmd)
util.CheckErr(err) util.CheckErr(err)
@ -43,6 +46,10 @@ func (f *Factory) NewCmdClusterInfo(out io.Writer) *cobra.Command {
} }
func RunClusterInfo(factory *Factory, out io.Writer, cmd *cobra.Command) error { func RunClusterInfo(factory *Factory, out io.Writer, cmd *cobra.Command) error {
if os.Args[1] == "clusterinfo" {
printDeprecationWarning("cluster-info", "clusterinfo")
}
client, err := factory.ClientConfig() client, err := factory.ClientConfig()
if err != nil { if err != nil {
return err return err

View File

@ -34,6 +34,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/resource" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
@ -492,3 +493,7 @@ func (c *clientCache) ClientForVersion(version string) (*client.Client, error) {
c.clients[config.Version] = client c.clients[config.Version] = client
return client, nil return client, nil
} }
func printDeprecationWarning(command, alias string) {
glog.Warningf("%s is DEPRECATED and will be removed in a future version. Use %s instead.", alias, command)
}

View File

@ -19,6 +19,7 @@ package cmd
import ( import (
"fmt" "fmt"
"io" "io"
"os"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
@ -31,24 +32,26 @@ const (
updatePeriod = "1m0s" updatePeriod = "1m0s"
timeout = "5m0s" timeout = "5m0s"
pollInterval = "3s" pollInterval = "3s"
rollingupdate_long = `Perform a rolling update of the given ReplicationController. 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 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.`
rollingupdate_example = `// Update pods of frontend-v1 using new controller data in frontend-v2.json. rollingUpdate_example = `// Update pods of frontend-v1 using new controller data in frontend-v2.json.
$ kubectl rollingupdate frontend-v1 -f frontend-v2.json $ kubectl rolling-update frontend-v1 -f frontend-v2.json
// Update pods of frontend-v1 using JSON data passed into stdin. // Update pods of frontend-v1 using JSON data passed into stdin.
$ cat frontend-v2.json | kubectl rollingupdate frontend-v1 -f -` $ cat frontend-v2.json | kubectl rolling-update 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_SPEC", Use: "rolling-update OLD_CONTROLLER_NAME -f NEW_CONTROLLER_SPEC",
// rollingupdate is deprecated.
Aliases: []string{"rollingupdate"},
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,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
err := RunRollingUpdate(f, out, cmd, args) err := RunRollingUpdate(f, out, cmd, args)
util.CheckErr(err) util.CheckErr(err)
@ -62,6 +65,10 @@ func (f *Factory) NewCmdRollingUpdate(out io.Writer) *cobra.Command {
} }
func RunRollingUpdate(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error { func RunRollingUpdate(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error {
if os.Args[1] == "rollingupdate" {
printDeprecationWarning("rolling-update", "rollingupdate")
}
filename := util.GetFlagString(cmd, "filename") filename := util.GetFlagString(cmd, "filename")
if len(filename) == 0 { if len(filename) == 0 {
return util.UsageError(cmd, "Must specify filename for new controller") return util.UsageError(cmd, "Must specify filename for new controller")

View File

@ -87,8 +87,8 @@ var _ = Describe("kubectl", func() {
By("creating the initial replication controller") By("creating the initial replication controller")
runKubectl("create", "-f", nautilusPath) runKubectl("create", "-f", nautilusPath)
validateController(c, nautilusImage, 2, "update-demo", updateDemoSelector, getUDData("nautilus.jpg")) validateController(c, nautilusImage, 2, "update-demo", updateDemoSelector, getUDData("nautilus.jpg"))
By("rollingupdate to new replication controller") By("rolling-update to new replication controller")
runKubectl("rollingupdate", "update-demo-nautilus", "--update-period=1s", "-f", kittenPath) runKubectl("rolling-update", "update-demo-nautilus", "--update-period=1s", "-f", kittenPath)
validateController(c, kittenImage, 2, "update-demo", updateDemoSelector, getUDData("kitten.jpg")) validateController(c, kittenImage, 2, "update-demo", updateDemoSelector, getUDData("kitten.jpg"))
}) })
}) })