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
58776da6
Commit
58776da6
authored
Mar 06, 2015
by
Deyuan Deng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more information to node describe
parent
fb0f23d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
13 deletions
+57
-13
test.sh
hack/lib/test.sh
+29
-0
test-cmd.sh
hack/test-cmd.sh
+6
-2
describe.go
pkg/kubectl/describe.go
+22
-11
No files found.
hack/lib/test.sh
View file @
58776da6
...
...
@@ -50,3 +50,32 @@ kube::test::get_object_assert() {
return
1
fi
}
kube::test::describe_object_assert
()
{
local
resource
=
$1
local
object
=
$2
local
matches
=
${
@
:3
}
result
=
$(
eval
kubectl describe
"
${
kube_flags
[@]
}
"
$resource
$object
)
for
match
in
${
matches
}
;
do
if
[[
!
$(
echo
"
$result
"
|
grep
${
match
})
]]
;
then
echo
${
bold
}${
red
}
echo
"FAIL!"
echo
"Describe
$resource
$object
"
echo
" Expected Match:
$match
"
echo
" Not found in:"
echo
"
$result
"
echo
${
reset
}${
red
}
caller
echo
${
reset
}
return
1
fi
done
echo
-n
${
green
}
echo
"Successful describe
$resource
$object
:"
echo
"
$result
"
echo
-n
${
reset
}
return
0
}
hack/test-cmd.sh
View file @
58776da6
...
...
@@ -104,7 +104,7 @@ CTLRMGR_PID=$!
kube::util::wait_for_url
"http://127.0.0.1:
${
CTLRMGR_PORT
}
/healthz"
"controller-manager: "
kube::util::wait_for_url
"http://127.0.0.1:
${
API_PORT
}
/api/v1beta1/minions/127.0.0.1"
"apiserver(minions): "
0.2 25
#
e
xpose kubectl directly for readability
#
E
xpose kubectl directly for readability
PATH
=
"
${
KUBE_OUTPUT_HOSTBIN
}
"
:
$PATH
kube_api_versions
=(
...
...
@@ -139,7 +139,7 @@ for version in "${kube_api_versions[@]}"; do
rc_replicas_field
=
"spec.replicas"
fi
#
p
assing no arguments to create is an error
#
P
assing no arguments to create is an error
!
kubectl create
###########################
...
...
@@ -502,6 +502,8 @@ __EOF__
kube::test::get_object_assert nodes
"{{range.items}}{{.
$id_field
}}:{{end}}"
'127.0.0.1:'
kube::test::describe_object_assert nodes
"127.0.0.1"
"Name:"
"Conditions:"
"Addresses:"
"Capacity:"
"Pods:"
###########
# Minions #
###########
...
...
@@ -513,6 +515,8 @@ __EOF__
# TODO: I should be a MinionList instead of List
kube::test::get_object_assert minions
'{{.kind}}'
'List'
kube::test::describe_object_assert minions
"127.0.0.1"
"Name:"
"Conditions:"
"Addresses:"
"Capacity:"
"Pods:"
fi
kube::test::clear_all
...
...
pkg/kubectl/describe.go
View file @
58776da6
...
...
@@ -46,7 +46,7 @@ func DescriberFor(kind string, c *client.Client) (Describer, bool) {
case
"Service"
:
return
&
ServiceDescriber
{
c
},
true
case
"Minion"
,
"Node"
:
return
&
Minion
Describer
{
c
},
true
return
&
Node
Describer
{
c
},
true
case
"LimitRange"
:
return
&
LimitRangeDescriber
{
c
},
true
case
"ResourceQuota"
:
...
...
@@ -283,14 +283,14 @@ func (d *ServiceDescriber) Describe(namespace, name string) (string, error) {
})
}
//
MinionDescriber generates information about a minion
.
type
Minion
Describer
struct
{
//
NodeDescriber generates information about a node
.
type
Node
Describer
struct
{
client
.
Interface
}
func
(
d
*
Minion
Describer
)
Describe
(
namespace
,
name
string
)
(
string
,
error
)
{
func
(
d
*
Node
Describer
)
Describe
(
namespace
,
name
string
)
(
string
,
error
)
{
mc
:=
d
.
Nodes
()
minion
,
err
:=
mc
.
Get
(
name
)
node
,
err
:=
mc
.
Get
(
name
)
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -307,13 +307,13 @@ func (d *MinionDescriber) Describe(namespace, name string) (string, error) {
pods
=
append
(
pods
,
pod
)
}
events
,
_
:=
d
.
Events
(
namespace
)
.
Search
(
minion
)
events
,
_
:=
d
.
Events
(
namespace
)
.
Search
(
node
)
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
minion
.
Name
)
if
len
(
minion
.
Status
.
Conditions
)
>
0
{
fmt
.
Fprintf
(
out
,
"Name:
\t
%s
\n
"
,
node
.
Name
)
if
len
(
node
.
Status
.
Conditions
)
>
0
{
fmt
.
Fprint
(
out
,
"Conditions:
\n
Type
\t
Status
\t
LastProbeTime
\t
LastTransitionTime
\t
Reason
\t
Message
\n
"
)
for
_
,
c
:=
range
minion
.
Status
.
Conditions
{
for
_
,
c
:=
range
node
.
Status
.
Conditions
{
fmt
.
Fprintf
(
out
,
" %v
\t
%v
\t
%s
\t
%s
\t
%v
\t
%v
\n
"
,
c
.
Type
,
c
.
Status
,
...
...
@@ -323,12 +323,23 @@ func (d *MinionDescriber) Describe(namespace, name string) (string, error) {
c
.
Message
)
}
}
if
len
(
minion
.
Spec
.
Capacity
)
>
0
{
var
addresses
[]
string
for
_
,
address
:=
range
node
.
Status
.
Addresses
{
addresses
=
append
(
addresses
,
address
.
Address
)
}
fmt
.
Fprintf
(
out
,
"Addresses:
\t
%s
\n
"
,
strings
.
Join
(
addresses
,
","
))
if
len
(
node
.
Spec
.
Capacity
)
>
0
{
fmt
.
Fprintf
(
out
,
"Capacity:
\n
"
)
for
resource
,
value
:=
range
minion
.
Spec
.
Capacity
{
for
resource
,
value
:=
range
node
.
Spec
.
Capacity
{
fmt
.
Fprintf
(
out
,
" %s:
\t
%s
\n
"
,
resource
,
value
.
String
())
}
}
if
len
(
node
.
Spec
.
PodCIDR
)
>
0
{
fmt
.
Fprintf
(
out
,
"PodCIDR:
\t
%s
\n
"
,
node
.
Spec
.
PodCIDR
)
}
if
len
(
node
.
Spec
.
ExternalID
)
>
0
{
fmt
.
Fprintf
(
out
,
"ExternalID:
\t
%s
\n
"
,
node
.
Spec
.
ExternalID
)
}
fmt
.
Fprintf
(
out
,
"Pods:
\t
(%d in total)
\n
"
,
len
(
pods
))
for
_
,
pod
:=
range
pods
{
if
pod
.
Status
.
Host
!=
name
{
...
...
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