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
6e76f1ae
Commit
6e76f1ae
authored
Aug 13, 2015
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show more information in describe node/pod
parent
ae7b13d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
41 deletions
+70
-41
describe.go
pkg/kubectl/describe.go
+70
-41
No files found.
pkg/kubectl/describe.go
View file @
6e76f1ae
...
@@ -460,6 +460,9 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
...
@@ -460,6 +460,9 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
pod
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
pod
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
makeImageList
(
&
pod
.
Spec
))
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
makeImageList
(
&
pod
.
Spec
))
fmt
.
Fprintf
(
out
,
"Node:
\t
%s
\n
"
,
pod
.
Spec
.
NodeName
+
"/"
+
pod
.
Status
.
HostIP
)
fmt
.
Fprintf
(
out
,
"Node:
\t
%s
\n
"
,
pod
.
Spec
.
NodeName
+
"/"
+
pod
.
Status
.
HostIP
)
if
pod
.
Status
.
StartTime
!=
nil
{
fmt
.
Fprintf
(
out
,
"Start Time:
\t
%s
\n
"
,
pod
.
Status
.
StartTime
.
Time
.
Format
(
time
.
RFC1123Z
))
}
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
FormatLabels
(
pod
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
FormatLabels
(
pod
.
Labels
))
if
pod
.
DeletionTimestamp
!=
nil
{
if
pod
.
DeletionTimestamp
!=
nil
{
fmt
.
Fprintf
(
out
,
"Status:
\t
Terminating (expires %s)
\n
"
,
pod
.
DeletionTimestamp
.
Time
.
Format
(
time
.
RFC1123Z
))
fmt
.
Fprintf
(
out
,
"Status:
\t
Terminating (expires %s)
\n
"
,
pod
.
DeletionTimestamp
.
Time
.
Format
(
time
.
RFC1123Z
))
...
@@ -707,7 +710,9 @@ func describeContainers(pod *api.Pod, out io.Writer) {
...
@@ -707,7 +710,9 @@ func describeContainers(pod *api.Pod, out io.Writer) {
state
:=
status
.
State
state
:=
status
.
State
fmt
.
Fprintf
(
out
,
" %v:
\n
"
,
container
.
Name
)
fmt
.
Fprintf
(
out
,
" %v:
\n
"
,
container
.
Name
)
fmt
.
Fprintf
(
out
,
" Container ID:
\t
%s
\n
"
,
status
.
ContainerID
)
fmt
.
Fprintf
(
out
,
" Image:
\t
%s
\n
"
,
container
.
Image
)
fmt
.
Fprintf
(
out
,
" Image:
\t
%s
\n
"
,
container
.
Image
)
fmt
.
Fprintf
(
out
,
" Image ID:
\t
%s
\n
"
,
status
.
ImageID
)
if
len
(
container
.
Resources
.
Limits
)
>
0
{
if
len
(
container
.
Resources
.
Limits
)
>
0
{
fmt
.
Fprintf
(
out
,
" Limits:
\n
"
)
fmt
.
Fprintf
(
out
,
" Limits:
\n
"
)
...
@@ -716,6 +721,13 @@ func describeContainers(pod *api.Pod, out io.Writer) {
...
@@ -716,6 +721,13 @@ func describeContainers(pod *api.Pod, out io.Writer) {
fmt
.
Fprintf
(
out
,
" %s:
\t
%s
\n
"
,
name
,
quantity
.
String
())
fmt
.
Fprintf
(
out
,
" %s:
\t
%s
\n
"
,
name
,
quantity
.
String
())
}
}
if
len
(
container
.
Resources
.
Requests
)
>
0
{
fmt
.
Fprintf
(
out
,
" Requests:
\n
"
)
}
for
name
,
quantity
:=
range
container
.
Resources
.
Requests
{
fmt
.
Fprintf
(
out
,
" %s:
\t
%s
\n
"
,
name
,
quantity
.
String
())
}
describeStatus
(
"State"
,
state
,
out
)
describeStatus
(
"State"
,
state
,
out
)
if
status
.
LastTerminationState
.
Terminated
!=
nil
{
if
status
.
LastTerminationState
.
Terminated
!=
nil
{
describeStatus
(
"Last Termination State"
,
status
.
LastTerminationState
,
out
)
describeStatus
(
"Last Termination State"
,
status
.
LastTerminationState
,
out
)
...
@@ -1065,8 +1077,10 @@ func describeNode(node *api.Node, pods []*api.Pod, events *api.EventList) (strin
...
@@ -1065,8 +1077,10 @@ func describeNode(node *api.Node, pods []*api.Pod, events *api.EventList) (strin
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
node
.
Name
)
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
node
.
Name
)
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
FormatLabels
(
node
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
labels
.
FormatLabels
(
node
.
Labels
))
fmt
.
Fprintf
(
out
,
"CreationTimestamp:
\t
%s
\n
"
,
node
.
CreationTimestamp
.
Time
.
Format
(
time
.
RFC1123Z
))
fmt
.
Fprintf
(
out
,
"CreationTimestamp:
\t
%s
\n
"
,
node
.
CreationTimestamp
.
Time
.
Format
(
time
.
RFC1123Z
))
fmt
.
Fprintf
(
out
,
"Phase:
\t
%v
\n
"
,
node
.
Status
.
Phase
)
if
len
(
node
.
Status
.
Conditions
)
>
0
{
if
len
(
node
.
Status
.
Conditions
)
>
0
{
fmt
.
Fprint
(
out
,
"Conditions:
\n
Type
\t
Status
\t
LastHeartbeatTime
\t
LastTransitionTime
\t
Reason
\t
Message
\n
"
)
fmt
.
Fprint
(
out
,
"Conditions:
\n
Type
\t
Status
\t
LastHeartbeatTime
\t
LastTransitionTime
\t
Reason
\t
Message
\n
"
)
fmt
.
Fprint
(
out
,
" ────
\t
──────
\t
─────────────────
\t
──────────────────
\t
──────
\t
───────
\n
"
)
for
_
,
c
:=
range
node
.
Status
.
Conditions
{
for
_
,
c
:=
range
node
.
Status
.
Conditions
{
fmt
.
Fprintf
(
out
,
" %v
\t
%v
\t
%s
\t
%s
\t
%v
\t
%v
\n
"
,
fmt
.
Fprintf
(
out
,
" %v
\t
%v
\t
%s
\t
%s
\t
%v
\t
%v
\n
"
,
c
.
Type
,
c
.
Type
,
...
@@ -1089,18 +1103,10 @@ func describeNode(node *api.Node, pods []*api.Pod, events *api.EventList) (strin
...
@@ -1089,18 +1103,10 @@ func describeNode(node *api.Node, pods []*api.Pod, events *api.EventList) (strin
}
}
}
}
runningPods
:=
filterNonRunningPods
(
pods
)
fmt
.
Fprintf
(
out
,
"System Info:
\n
"
)
reqs
,
err
:=
getPodsTotalRequests
(
runningPods
)
fmt
.
Fprintf
(
out
,
" Machine ID:
\t
%s
\n
"
,
node
.
Status
.
NodeInfo
.
MachineID
)
if
err
!=
nil
{
fmt
.
Fprintf
(
out
,
" System UUID:
\t
%s
\n
"
,
node
.
Status
.
NodeInfo
.
SystemUUID
)
return
err
fmt
.
Fprintf
(
out
,
" Boot ID:
\t
%s
\n
"
,
node
.
Status
.
NodeInfo
.
BootID
)
}
fmt
.
Fprintf
(
out
,
"Allocated resources (total requests):
\n
"
)
for
reqResource
,
reqValue
:=
range
reqs
{
fmt
.
Fprintf
(
out
,
" %s:
\t
%s
\n
"
,
reqResource
,
reqValue
.
String
())
}
fmt
.
Fprintf
(
out
,
" pods:
\t
%d
\n
"
,
len
(
runningPods
))
fmt
.
Fprintf
(
out
,
"Version:
\n
"
)
fmt
.
Fprintf
(
out
,
" Kernel Version:
\t
%s
\n
"
,
node
.
Status
.
NodeInfo
.
KernelVersion
)
fmt
.
Fprintf
(
out
,
" Kernel Version:
\t
%s
\n
"
,
node
.
Status
.
NodeInfo
.
KernelVersion
)
fmt
.
Fprintf
(
out
,
" OS Image:
\t
%s
\n
"
,
node
.
Status
.
NodeInfo
.
OsImage
)
fmt
.
Fprintf
(
out
,
" OS Image:
\t
%s
\n
"
,
node
.
Status
.
NodeInfo
.
OsImage
)
fmt
.
Fprintf
(
out
,
" Container Runtime Version:
\t
%s
\n
"
,
node
.
Status
.
NodeInfo
.
ContainerRuntimeVersion
)
fmt
.
Fprintf
(
out
,
" Container Runtime Version:
\t
%s
\n
"
,
node
.
Status
.
NodeInfo
.
ContainerRuntimeVersion
)
...
@@ -1113,34 +1119,8 @@ func describeNode(node *api.Node, pods []*api.Pod, events *api.EventList) (strin
...
@@ -1113,34 +1119,8 @@ func describeNode(node *api.Node, pods []*api.Pod, events *api.EventList) (strin
if
len
(
node
.
Spec
.
ExternalID
)
>
0
{
if
len
(
node
.
Spec
.
ExternalID
)
>
0
{
fmt
.
Fprintf
(
out
,
"ExternalID:
\t
%s
\n
"
,
node
.
Spec
.
ExternalID
)
fmt
.
Fprintf
(
out
,
"ExternalID:
\t
%s
\n
"
,
node
.
Spec
.
ExternalID
)
}
}
fmt
.
Fprintf
(
out
,
"Pods:
\t
(%d in total)
\n
"
,
len
(
pods
))
describeNodeResource
(
pods
,
node
,
out
)
fmt
.
Fprint
(
out
,
" Namespace
\t
Name
\t\t
CPU(milliCPU)
\t\t
Memory(bytes)
\n
"
)
totalMilliCPU
:=
int64
(
0
)
totalMemory
:=
int64
(
0
)
fractionPodCPU
:=
float64
(
0
)
fractionPodMemory
:=
float64
(
0
)
fractionTotalCPU
:=
float64
(
0
)
fractionTotalMemory
:=
float64
(
0
)
for
_
,
pod
:=
range
pods
{
podTotalMilliCPU
:=
int64
(
0
)
podTotalMemory
:=
int64
(
0
)
for
ix
:=
range
pod
.
Spec
.
Containers
{
limits
:=
pod
.
Spec
.
Containers
[
ix
]
.
Resources
.
Limits
podTotalMilliCPU
+=
limits
.
Cpu
()
.
MilliValue
()
podTotalMemory
+=
limits
.
Memory
()
.
Value
()
}
totalMilliCPU
+=
podTotalMilliCPU
totalMemory
+=
podTotalMemory
fractionPodCPU
=
float64
(
podTotalMilliCPU
)
/
float64
(
node
.
Status
.
Capacity
.
Cpu
()
.
MilliValue
())
*
100
fractionPodMemory
=
float64
(
podTotalMemory
)
/
float64
(
node
.
Status
.
Capacity
.
Memory
()
.
Value
())
*
100
fmt
.
Fprintf
(
out
,
" %s
\t
%s
\t\t
%d (%d%% of total)
\t\t
%d (%d%% of total)
\n
"
,
pod
.
Namespace
,
pod
.
Name
,
podTotalMilliCPU
,
int64
(
fractionPodCPU
),
podTotalMemory
,
int64
(
fractionPodMemory
))
}
fmt
.
Fprint
(
out
,
"TotalResourceLimits:
\n
"
)
fractionTotalCPU
=
float64
(
totalMilliCPU
)
/
float64
(
node
.
Status
.
Capacity
.
Cpu
()
.
MilliValue
())
*
100
fractionTotalMemory
=
float64
(
totalMemory
)
/
float64
(
node
.
Status
.
Capacity
.
Memory
()
.
Value
())
*
100
fmt
.
Fprintf
(
out
,
" CPU(milliCPU):
\t\t
%d (%d%% of total)
\n
"
,
totalMilliCPU
,
int64
(
fractionTotalCPU
))
fmt
.
Fprintf
(
out
,
" Memory(bytes):
\t\t
%d (%d%% of total)
\n
"
,
totalMemory
,
int64
(
fractionTotalMemory
))
if
events
!=
nil
{
if
events
!=
nil
{
DescribeEvents
(
events
,
out
)
DescribeEvents
(
events
,
out
)
}
}
...
@@ -1197,7 +1177,55 @@ func (d *HorizontalPodAutoscalerDescriber) Describe(namespace, name string) (str
...
@@ -1197,7 +1177,55 @@ func (d *HorizontalPodAutoscalerDescriber) Describe(namespace, name string) (str
})
})
}
}
func
filterNonRunningPods
(
pods
[]
*
api
.
Pod
)
[]
*
api
.
Pod
{
func
describeNodeResource
(
pods
[]
*
api
.
Pod
,
node
*
api
.
Node
,
out
io
.
Writer
)
{
nonTerminatedPods
:=
filterTerminatedPods
(
pods
)
fmt
.
Fprintf
(
out
,
"Non-terminated Pods:
\t
(%d in total)
\n
"
,
len
(
nonTerminatedPods
))
fmt
.
Fprint
(
out
,
" Namespace
\t
Name
\t\t
CPU Requests
\t
Memory Requests
\t
CPU Limits
\t
Memory Limits
\n
"
)
fmt
.
Fprint
(
out
,
" ─────────
\t
────
\t\t
────────────
\t
───────────────
\t
──────────
\t
─────────────
\n
"
)
totalMilliCPUReq
:=
int64
(
0
)
totalMemoryReq
:=
int64
(
0
)
fractionPodCPUReq
:=
float64
(
0
)
fractionPodMemoryReq
:=
float64
(
0
)
fractionTotalCPUReq
:=
float64
(
0
)
fractionTotalMemoryReq
:=
float64
(
0
)
totalMilliCPULimit
:=
int64
(
0
)
totalMemoryLimit
:=
int64
(
0
)
fractionPodCPULimit
:=
float64
(
0
)
fractionPodMemoryLimit
:=
float64
(
0
)
for
_
,
pod
:=
range
pods
{
podTotalMilliCPUReq
:=
int64
(
0
)
podTotalMemoryReq
:=
int64
(
0
)
podTotalMilliCPULimit
:=
int64
(
0
)
podTotalMemoryLimit
:=
int64
(
0
)
for
ix
:=
range
pod
.
Spec
.
Containers
{
requests
:=
pod
.
Spec
.
Containers
[
ix
]
.
Resources
.
Requests
podTotalMilliCPUReq
+=
requests
.
Cpu
()
.
MilliValue
()
podTotalMemoryReq
+=
requests
.
Memory
()
.
Value
()
limits
:=
pod
.
Spec
.
Containers
[
ix
]
.
Resources
.
Limits
podTotalMilliCPULimit
+=
limits
.
Cpu
()
.
MilliValue
()
podTotalMemoryLimit
+=
limits
.
Memory
()
.
Value
()
}
totalMilliCPUReq
+=
podTotalMilliCPUReq
totalMemoryReq
+=
podTotalMemoryReq
totalMilliCPULimit
+=
podTotalMilliCPULimit
totalMemoryLimit
+=
podTotalMemoryLimit
fractionPodCPUReq
=
float64
(
podTotalMilliCPUReq
)
/
float64
(
node
.
Status
.
Capacity
.
Cpu
()
.
MilliValue
())
*
100
fractionPodMemoryReq
=
float64
(
podTotalMemoryReq
)
/
float64
(
node
.
Status
.
Capacity
.
Memory
()
.
Value
())
*
100
fractionPodCPULimit
=
float64
(
podTotalMilliCPULimit
)
/
float64
(
node
.
Status
.
Capacity
.
Cpu
()
.
MilliValue
())
*
100
fractionPodMemoryLimit
=
float64
(
podTotalMemoryLimit
)
/
float64
(
node
.
Status
.
Capacity
.
Memory
()
.
Value
())
*
100
fmt
.
Fprintf
(
out
,
" %s
\t
%s
\t\t
%dm (%d%%)
\t
%dKi (%d%%)
\t
%dm (%d%%)
\t
%dKi (%d%%)
\n
"
,
pod
.
Namespace
,
pod
.
Name
,
podTotalMilliCPUReq
,
int64
(
fractionPodCPUReq
),
podTotalMemoryReq
/
1000
,
int64
(
fractionPodMemoryReq
),
podTotalMilliCPULimit
,
int64
(
fractionPodCPULimit
),
podTotalMemoryLimit
/
1000
,
int64
(
fractionPodMemoryLimit
))
}
fmt
.
Fprint
(
out
,
"Allocated resources:
\n
CPU Requests
\t
Memory Requests
\t
CPU Limits
\t
Memory Limits
\n
"
)
fmt
.
Fprint
(
out
,
" ────────────
\t
───────────────
\t
──────────
\t
─────────────
\n
"
)
fractionTotalCPUReq
=
float64
(
totalMilliCPUReq
)
/
float64
(
node
.
Status
.
Capacity
.
Cpu
()
.
MilliValue
())
*
100
fractionTotalMemoryReq
=
float64
(
totalMemoryReq
)
/
float64
(
node
.
Status
.
Capacity
.
Memory
()
.
Value
())
*
100
fmt
.
Fprintf
(
out
,
" %dm (%d%%)
\t
%dKi (%d%%)
\t
%dm
\t
%dKi
\n
"
,
totalMilliCPUReq
,
int64
(
fractionTotalCPUReq
),
totalMemoryReq
/
1000
,
int64
(
fractionTotalMemoryReq
),
totalMilliCPULimit
,
totalMemoryLimit
/
1000
)
}
func
filterTerminatedPods
(
pods
[]
*
api
.
Pod
)
[]
*
api
.
Pod
{
if
len
(
pods
)
==
0
{
if
len
(
pods
)
==
0
{
return
pods
return
pods
}
}
...
@@ -1250,6 +1278,7 @@ func DescribeEvents(el *api.EventList, w io.Writer) {
...
@@ -1250,6 +1278,7 @@ func DescribeEvents(el *api.EventList, w io.Writer) {
}
}
sort
.
Sort
(
SortableEvents
(
el
.
Items
))
sort
.
Sort
(
SortableEvents
(
el
.
Items
))
fmt
.
Fprint
(
w
,
"Events:
\n
FirstSeen
\t
LastSeen
\t
Count
\t
From
\t
SubobjectPath
\t
Reason
\t
Message
\n
"
)
fmt
.
Fprint
(
w
,
"Events:
\n
FirstSeen
\t
LastSeen
\t
Count
\t
From
\t
SubobjectPath
\t
Reason
\t
Message
\n
"
)
fmt
.
Fprint
(
w
,
" ─────────
\t
────────
\t
─────
\t
────
\t
─────────────
\t
──────
\t
───────
\n
"
)
for
_
,
e
:=
range
el
.
Items
{
for
_
,
e
:=
range
el
.
Items
{
fmt
.
Fprintf
(
w
,
" %s
\t
%s
\t
%d
\t
%v
\t
%v
\t
%v
\t
%v
\n
"
,
fmt
.
Fprintf
(
w
,
" %s
\t
%s
\t
%d
\t
%v
\t
%v
\t
%v
\t
%v
\n
"
,
translateTimestamp
(
e
.
FirstTimestamp
),
translateTimestamp
(
e
.
FirstTimestamp
),
...
...
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