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
ded85695
Commit
ded85695
authored
Sep 04, 2015
by
Quinton Hoole
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12908 from mwielgus/kubectl_get_hpa
HorizontalPodAutoscaler in kubectl get
parents
e5e2bc95
3f210710
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
0 deletions
+54
-0
kubectl
contrib/completions/bash/kubectl
+3
-0
types.go
pkg/expapi/types.go
+1
-0
kubectl.go
pkg/kubectl/kubectl.go
+1
-0
resource_printer.go
pkg/kubectl/resource_printer.go
+49
-0
No files found.
contrib/completions/bash/kubectl
View file @
ded85695
...
@@ -285,6 +285,7 @@ _kubectl_get()
...
@@ -285,6 +285,7 @@ _kubectl_get()
must_have_one_noun+
=(
"deployment"
)
must_have_one_noun+
=(
"deployment"
)
must_have_one_noun+
=(
"endpoints"
)
must_have_one_noun+
=(
"endpoints"
)
must_have_one_noun+
=(
"event"
)
must_have_one_noun+
=(
"event"
)
must_have_one_noun+
=(
"horizontalpodautoscaler"
)
must_have_one_noun+
=(
"limitrange"
)
must_have_one_noun+
=(
"limitrange"
)
must_have_one_noun+
=(
"namespace"
)
must_have_one_noun+
=(
"namespace"
)
must_have_one_noun+
=(
"node"
)
must_have_one_noun+
=(
"node"
)
...
@@ -460,6 +461,7 @@ _kubectl_delete()
...
@@ -460,6 +461,7 @@ _kubectl_delete()
must_have_one_noun+
=(
"deployment"
)
must_have_one_noun+
=(
"deployment"
)
must_have_one_noun+
=(
"endpoints"
)
must_have_one_noun+
=(
"endpoints"
)
must_have_one_noun+
=(
"event"
)
must_have_one_noun+
=(
"event"
)
must_have_one_noun+
=(
"horizontalpodautoscaler"
)
must_have_one_noun+
=(
"limitrange"
)
must_have_one_noun+
=(
"limitrange"
)
must_have_one_noun+
=(
"namespace"
)
must_have_one_noun+
=(
"namespace"
)
must_have_one_noun+
=(
"node"
)
must_have_one_noun+
=(
"node"
)
...
@@ -848,6 +850,7 @@ _kubectl_label()
...
@@ -848,6 +850,7 @@ _kubectl_label()
must_have_one_noun+
=(
"deployment"
)
must_have_one_noun+
=(
"deployment"
)
must_have_one_noun+
=(
"endpoints"
)
must_have_one_noun+
=(
"endpoints"
)
must_have_one_noun+
=(
"event"
)
must_have_one_noun+
=(
"event"
)
must_have_one_noun+
=(
"horizontalpodautoscaler"
)
must_have_one_noun+
=(
"limitrange"
)
must_have_one_noun+
=(
"limitrange"
)
must_have_one_noun+
=(
"namespace"
)
must_have_one_noun+
=(
"namespace"
)
must_have_one_noun+
=(
"node"
)
must_have_one_noun+
=(
"node"
)
...
...
pkg/expapi/types.go
View file @
ded85695
...
@@ -103,6 +103,7 @@ type HorizontalPodAutoscalerSpec struct {
...
@@ -103,6 +103,7 @@ type HorizontalPodAutoscalerSpec struct {
// HorizontalPodAutoscalerStatus contains the current status of a horizontal pod autoscaler
// HorizontalPodAutoscalerStatus contains the current status of a horizontal pod autoscaler
type
HorizontalPodAutoscalerStatus
struct
{
type
HorizontalPodAutoscalerStatus
struct
{
// TODO: Consider if it is needed.
// CurrentReplicas is the number of replicas of pods managed by this autoscaler.
// CurrentReplicas is the number of replicas of pods managed by this autoscaler.
CurrentReplicas
int
`json:"currentReplicas"`
CurrentReplicas
int
`json:"currentReplicas"`
...
...
pkg/kubectl/kubectl.go
View file @
ded85695
...
@@ -96,6 +96,7 @@ func expandResourceShortcut(resource string) string {
...
@@ -96,6 +96,7 @@ func expandResourceShortcut(resource string) string {
"cs"
:
"componentstatuses"
,
"cs"
:
"componentstatuses"
,
"ev"
:
"events"
,
"ev"
:
"events"
,
"ep"
:
"endpoints"
,
"ep"
:
"endpoints"
,
"hpa"
:
"horizontalpodautoscalers"
,
"limits"
:
"limitranges"
,
"limits"
:
"limitranges"
,
"no"
:
"nodes"
,
"no"
:
"nodes"
,
"ns"
:
"namespaces"
,
"ns"
:
"namespaces"
,
...
...
pkg/kubectl/resource_printer.go
View file @
ded85695
...
@@ -366,6 +366,7 @@ var persistentVolumeColumns = []string{"NAME", "LABELS", "CAPACITY", "ACCESSMODE
...
@@ -366,6 +366,7 @@ var persistentVolumeColumns = []string{"NAME", "LABELS", "CAPACITY", "ACCESSMODE
var
persistentVolumeClaimColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"STATUS"
,
"VOLUME"
,
"CAPACITY"
,
"ACCESSMODES"
,
"AGE"
}
var
persistentVolumeClaimColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"STATUS"
,
"VOLUME"
,
"CAPACITY"
,
"ACCESSMODES"
,
"AGE"
}
var
componentStatusColumns
=
[]
string
{
"NAME"
,
"STATUS"
,
"MESSAGE"
,
"ERROR"
}
var
componentStatusColumns
=
[]
string
{
"NAME"
,
"STATUS"
,
"MESSAGE"
,
"ERROR"
}
var
thirdPartyResourceColumns
=
[]
string
{
"NAME"
,
"DESCRIPTION"
,
"VERSION(S)"
}
var
thirdPartyResourceColumns
=
[]
string
{
"NAME"
,
"DESCRIPTION"
,
"VERSION(S)"
}
var
horizontalPodAutoscalerColumns
=
[]
string
{
"NAME"
,
"REFERENCE"
,
"TARGET"
,
"CURRENT"
,
"MINPODS"
,
"MAXPODS"
,
"AGE"
}
var
withNamespacePrefixColumns
=
[]
string
{
"NAMESPACE"
}
// TODO(erictune): print cluster name too.
var
withNamespacePrefixColumns
=
[]
string
{
"NAMESPACE"
}
// TODO(erictune): print cluster name too.
var
deploymentColumns
=
[]
string
{
"NAME"
,
"UPDATEDREPLICAS"
,
"AGE"
}
var
deploymentColumns
=
[]
string
{
"NAME"
,
"UPDATEDREPLICAS"
,
"AGE"
}
...
@@ -405,6 +406,8 @@ func (h *HumanReadablePrinter) addDefaultHandlers() {
...
@@ -405,6 +406,8 @@ func (h *HumanReadablePrinter) addDefaultHandlers() {
h
.
Handler
(
thirdPartyResourceColumns
,
printThirdPartyResourceList
)
h
.
Handler
(
thirdPartyResourceColumns
,
printThirdPartyResourceList
)
h
.
Handler
(
deploymentColumns
,
printDeployment
)
h
.
Handler
(
deploymentColumns
,
printDeployment
)
h
.
Handler
(
deploymentColumns
,
printDeploymentList
)
h
.
Handler
(
deploymentColumns
,
printDeploymentList
)
h
.
Handler
(
horizontalPodAutoscalerColumns
,
printHorizontalPodAutoscaler
)
h
.
Handler
(
horizontalPodAutoscalerColumns
,
printHorizontalPodAutoscalerList
)
}
}
func
(
h
*
HumanReadablePrinter
)
unknown
(
data
[]
byte
,
w
io
.
Writer
)
error
{
func
(
h
*
HumanReadablePrinter
)
unknown
(
data
[]
byte
,
w
io
.
Writer
)
error
{
...
@@ -1150,6 +1153,52 @@ func printDeploymentList(list *expapi.DeploymentList, w io.Writer, withNamespace
...
@@ -1150,6 +1153,52 @@ func printDeploymentList(list *expapi.DeploymentList, w io.Writer, withNamespace
return
nil
return
nil
}
}
func
printHorizontalPodAutoscaler
(
hpa
*
expapi
.
HorizontalPodAutoscaler
,
w
io
.
Writer
,
withNamespace
bool
,
wide
bool
,
showAll
bool
,
columnLabels
[]
string
)
error
{
namespace
:=
hpa
.
Namespace
name
:=
hpa
.
Name
reference
:=
fmt
.
Sprintf
(
"%s/%s/%s/%s"
,
hpa
.
Spec
.
ScaleRef
.
Kind
,
hpa
.
Spec
.
ScaleRef
.
Namespace
,
hpa
.
Spec
.
ScaleRef
.
Name
,
hpa
.
Spec
.
ScaleRef
.
Subresource
)
target
:=
fmt
.
Sprintf
(
"%s %v"
,
hpa
.
Spec
.
Target
.
Quantity
.
String
(),
hpa
.
Spec
.
Target
.
Resource
)
current
:=
"<waiting>"
if
hpa
.
Status
!=
nil
&&
hpa
.
Status
.
CurrentConsumption
!=
nil
{
current
=
fmt
.
Sprintf
(
"%s %v"
,
hpa
.
Status
.
CurrentConsumption
.
Quantity
.
String
(),
hpa
.
Status
.
CurrentConsumption
.
Resource
)
}
minPods
:=
hpa
.
Spec
.
MinCount
maxPods
:=
hpa
.
Spec
.
MaxCount
if
withNamespace
{
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
"
,
namespace
);
err
!=
nil
{
return
err
}
}
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%d
\t
%d
\t
%s"
,
name
,
reference
,
target
,
current
,
minPods
,
maxPods
,
translateTimestamp
(
hpa
.
CreationTimestamp
),
);
err
!=
nil
{
return
err
}
_
,
err
:=
fmt
.
Fprint
(
w
,
appendLabels
(
hpa
.
Labels
,
columnLabels
))
return
err
}
func
printHorizontalPodAutoscalerList
(
list
*
expapi
.
HorizontalPodAutoscalerList
,
w
io
.
Writer
,
withNamespace
bool
,
wide
bool
,
showAll
bool
,
columnLabels
[]
string
)
error
{
for
i
:=
range
list
.
Items
{
if
err
:=
printHorizontalPodAutoscaler
(
&
list
.
Items
[
i
],
w
,
withNamespace
,
wide
,
showAll
,
columnLabels
);
err
!=
nil
{
return
err
}
}
return
nil
}
func
appendLabels
(
itemLabels
map
[
string
]
string
,
columnLabels
[]
string
)
string
{
func
appendLabels
(
itemLabels
map
[
string
]
string
,
columnLabels
[]
string
)
string
{
var
buffer
bytes
.
Buffer
var
buffer
bytes
.
Buffer
...
...
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