Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
1e10a7cc
Commit
1e10a7cc
authored
Aug 11, 2015
by
feihujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kubectl scale command accepts a filename param
parent
a6148e79
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
11 deletions
+40
-11
kubectl
contrib/completions/bash/kubectl
+6
-0
kubectl-scale.1
docs/man/man1/kubectl-scale.1
+7
-0
kubectl_scale.md
docs/user-guide/kubectl/kubectl_scale.md
+6
-2
test-cmd.sh
hack/test-cmd.sh
+10
-2
scale.go
pkg/kubectl/cmd/scale.go
+11
-7
No files found.
contrib/completions/bash/kubectl
View file @
1e10a7cc
...
@@ -508,6 +508,12 @@ _kubectl_scale()
...
@@ -508,6 +508,12 @@ _kubectl_scale()
flags_completion
=()
flags_completion
=()
flags+
=(
"--current-replicas="
)
flags+
=(
"--current-replicas="
)
flags+
=(
"--filename="
)
flags_with_completion+
=(
"--filename"
)
flags_completion+
=(
"__handle_filename_extension_flag json|yaml|yml"
)
two_word_flags+
=(
"-f"
)
flags_with_completion+
=(
"-f"
)
flags_completion+
=(
"__handle_filename_extension_flag json|yaml|yml"
)
flags+
=(
"--help"
)
flags+
=(
"--help"
)
flags+
=(
"-h"
)
flags+
=(
"-h"
)
flags+
=(
"--output="
)
flags+
=(
"--output="
)
...
...
docs/man/man1/kubectl-scale.1
View file @
1e10a7cc
...
@@ -28,6 +28,10 @@ scale is sent to the server.
...
@@ -28,6 +28,10 @@ scale is sent to the server.
Precondition for current size. Requires that the current size of the replication controller match this value in order to scale.
Precondition for current size. Requires that the current size of the replication controller match this value in order to scale.
.PP
.PP
\fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory, or URL to a file identifying the replication controller to set a new size
.PP
\fB\-h\fP, \fB\-\-help\fP=false
\fB\-h\fP, \fB\-\-help\fP=false
help for scale
help for scale
...
@@ -154,6 +158,9 @@ scale is sent to the server.
...
@@ -154,6 +158,9 @@ scale is sent to the server.
# Scale replication controller named 'foo' to 3.
# Scale replication controller named 'foo' to 3.
$ kubectl scale \-\-replicas=3 replicationcontrollers foo
$ kubectl scale \-\-replicas=3 replicationcontrollers foo
# Scale a replication controller identified by type and name specified in "foo\-controller.yaml" to 3.
$ kubectl scale \-\-replicas=3 \-f foo\-controller.yaml
# If the replication controller named foo's current size is 2, scale foo to 3.
# If the replication controller named foo's current size is 2, scale foo to 3.
$ kubectl scale \-\-current\-replicas=2 \-\-replicas=3 replicationcontrollers foo
$ kubectl scale \-\-current\-replicas=2 \-\-replicas=3 replicationcontrollers foo
...
...
docs/user-guide/kubectl/kubectl_scale.md
View file @
1e10a7cc
...
@@ -46,7 +46,7 @@ scale is attempted, and it is guaranteed that the precondition holds true when t
...
@@ -46,7 +46,7 @@ scale is attempted, and it is guaranteed that the precondition holds true when t
scale is sent to the server.
scale is sent to the server.
```
```
kubectl scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT
TYPE NAME
kubectl scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT
(-f FILENAME | TYPE NAME)
```
```
### Examples
### Examples
...
@@ -55,6 +55,9 @@ kubectl scale [--resource-version=version] [--current-replicas=count] --replicas
...
@@ -55,6 +55,9 @@ kubectl scale [--resource-version=version] [--current-replicas=count] --replicas
# Scale replication controller named 'foo' to 3.
# Scale replication controller named 'foo' to 3.
$ kubectl scale --replicas=3 replicationcontrollers foo
$ kubectl scale --replicas=3 replicationcontrollers foo
# Scale a replication controller identified by type and name specified in "foo-controller.yaml" to 3.
$ kubectl scale --replicas=3 -f foo-controller.yaml
# If the replication controller named foo's current size is 2, scale foo to 3.
# If the replication controller named foo's current size is 2, scale foo to 3.
$ kubectl scale --current-replicas=2 --replicas=3 replicationcontrollers foo
$ kubectl scale --current-replicas=2 --replicas=3 replicationcontrollers foo
...
@@ -66,6 +69,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar
...
@@ -66,6 +69,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar
```
```
--current-replicas=-1: Precondition for current size. Requires that the current size of the replication controller match this value in order to scale.
--current-replicas=-1: Precondition for current size. Requires that the current size of the replication controller match this value in order to scale.
-f, --filename=[]: Filename, directory, or URL to a file identifying the replication controller to set a new size
-h, --help[=false]: help for scale
-h, --help[=false]: help for scale
-o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
-o, --output="": Output mode. Use "-o name" for shorter output (resource/name).
--replicas=-1: The new desired number of replicas. Required.
--replicas=-1: The new desired number of replicas. Required.
...
@@ -106,7 +110,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar
...
@@ -106,7 +110,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar
*
[
kubectl
](
kubectl.md
)
- kubectl controls the Kubernetes cluster manager
*
[
kubectl
](
kubectl.md
)
- kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-08-1
2 16:38:35.551986915
+0000 UTC
###### Auto generated by spf13/cobra at 2015-08-1
3 06:25:21.82766402
+0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[

]()
[

]()
...
...
hack/test-cmd.sh
View file @
1e10a7cc
...
@@ -623,6 +623,14 @@ __EOF__
...
@@ -623,6 +623,14 @@ __EOF__
# Post-condition: 3 replicas
# Post-condition: 3 replicas
kube::test::get_object_assert
'rc frontend'
"{{
$rc_replicas_field
}}"
'3'
kube::test::get_object_assert
'rc frontend'
"{{
$rc_replicas_field
}}"
'3'
### Scale replication controller from JSON with replicas only
# Pre-condition: 3 replicas
kube::test::get_object_assert
'rc frontend'
"{{
$rc_replicas_field
}}"
'3'
# Command
kubectl scale
--replicas
=
2
-f
examples/guestbook/frontend-controller.yaml
"
${
kube_flags
[@]
}
"
# Post-condition: 2 replicas
kube::test::get_object_assert
'rc frontend'
"{{
$rc_replicas_field
}}"
'2'
### Scale multiple replication controllers
### Scale multiple replication controllers
kubectl create
-f
examples/guestbook/redis-master-controller.yaml
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/redis-master-controller.yaml
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/redis-slave-controller.yaml
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/redis-slave-controller.yaml
"
${
kube_flags
[@]
}
"
...
@@ -635,8 +643,8 @@ __EOF__
...
@@ -635,8 +643,8 @@ __EOF__
kubectl delete rc redis-
{
master,slave
}
"
${
kube_flags
[@]
}
"
kubectl delete rc redis-
{
master,slave
}
"
${
kube_flags
[@]
}
"
### Expose replication controller as service
### Expose replication controller as service
# Pre-condition:
3
replicas
# Pre-condition:
2
replicas
kube::test::get_object_assert
'rc frontend'
"{{
$rc_replicas_field
}}"
'
3
'
kube::test::get_object_assert
'rc frontend'
"{{
$rc_replicas_field
}}"
'
2
'
# Command
# Command
kubectl expose rc frontend
--port
=
80
"
${
kube_flags
[@]
}
"
kubectl expose rc frontend
--port
=
80
"
${
kube_flags
[@]
}
"
# Post-condition: service exists and the port is unnamed
# Post-condition: service exists and the port is unnamed
...
...
pkg/kubectl/cmd/scale.go
View file @
1e10a7cc
...
@@ -39,6 +39,9 @@ scale is sent to the server.`
...
@@ -39,6 +39,9 @@ scale is sent to the server.`
scale_example
=
`# Scale replication controller named 'foo' to 3.
scale_example
=
`# Scale replication controller named 'foo' to 3.
$ kubectl scale --replicas=3 replicationcontrollers foo
$ kubectl scale --replicas=3 replicationcontrollers foo
# Scale a replication controller identified by type and name specified in "foo-controller.yaml" to 3.
$ kubectl scale --replicas=3 -f foo-controller.yaml
# If the replication controller named foo's current size is 2, scale foo to 3.
# If the replication controller named foo's current size is 2, scale foo to 3.
$ kubectl scale --current-replicas=2 --replicas=3 replicationcontrollers foo
$ kubectl scale --current-replicas=2 --replicas=3 replicationcontrollers foo
...
@@ -49,7 +52,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar`
...
@@ -49,7 +52,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar`
// NewCmdScale returns a cobra command with the appropriate configuration and flags to run scale
// NewCmdScale returns a cobra command with the appropriate configuration and flags to run scale
func
NewCmdScale
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdScale
(
f
*
cmdutil
.
Factory
,
out
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT
TYPE NAME
"
,
Use
:
"scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT
(-f FILENAME | TYPE NAME)
"
,
// resize is deprecated
// resize is deprecated
Aliases
:
[]
string
{
"resize"
},
Aliases
:
[]
string
{
"resize"
},
Short
:
"Set a new size for a Replication Controller."
,
Short
:
"Set a new size for a Replication Controller."
,
...
@@ -68,6 +71,9 @@ func NewCmdScale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
...
@@ -68,6 +71,9 @@ func NewCmdScale(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd
.
Flags
()
.
Duration
(
"timeout"
,
0
,
"The length of time to wait before giving up on a scale operation, zero means don't wait."
)
cmd
.
Flags
()
.
Duration
(
"timeout"
,
0
,
"The length of time to wait before giving up on a scale operation, zero means don't wait."
)
cmd
.
MarkFlagRequired
(
"replicas"
)
cmd
.
MarkFlagRequired
(
"replicas"
)
cmdutil
.
AddOutputFlagsForMutation
(
cmd
)
cmdutil
.
AddOutputFlagsForMutation
(
cmd
)
usage
:=
"Filename, directory, or URL to a file identifying the replication controller to set a new size"
kubectl
.
AddJsonFilenameFlag
(
cmd
,
usage
)
return
cmd
return
cmd
}
}
...
@@ -82,7 +88,7 @@ func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
...
@@ -82,7 +88,7 @@ func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
return
cmdutil
.
UsageError
(
cmd
,
"--replicas=COUNT TYPE NAME"
)
return
cmdutil
.
UsageError
(
cmd
,
"--replicas=COUNT TYPE NAME"
)
}
}
cmdNamespace
,
_
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -91,6 +97,7 @@ func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
...
@@ -91,6 +97,7 @@ func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
r
:=
resource
.
NewBuilder
(
mapper
,
typer
,
f
.
ClientMapperForCommand
())
.
r
:=
resource
.
NewBuilder
(
mapper
,
typer
,
f
.
ClientMapperForCommand
())
.
ContinueOnError
()
.
ContinueOnError
()
.
NamespaceParam
(
cmdNamespace
)
.
DefaultNamespace
()
.
NamespaceParam
(
cmdNamespace
)
.
DefaultNamespace
()
.
FilenameParam
(
enforceNamespace
,
cmdutil
.
GetFlagStringSlice
(
cmd
,
"filename"
)
...
)
.
ResourceTypeOrNameArgs
(
false
,
args
...
)
.
ResourceTypeOrNameArgs
(
false
,
args
...
)
.
Flatten
()
.
Flatten
()
.
Do
()
Do
()
...
@@ -98,16 +105,13 @@ func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
...
@@ -98,16 +105,13 @@ func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
mapping
,
err
:=
r
.
ResourceMapping
()
if
err
!=
nil
{
return
err
}
infos
,
err
:=
r
.
Infos
()
infos
,
err
:=
r
.
Infos
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
info
:=
infos
[
0
]
mapping
:=
info
.
ResourceMapping
()
scaler
,
err
:=
f
.
Scaler
(
mapping
)
scaler
,
err
:=
f
.
Scaler
(
mapping
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment