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
462fed62
Commit
462fed62
authored
Aug 10, 2015
by
Alex Robinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12189 from feihujiang/describeKindNoArguments
kubectl describe <kind> work with no arguments
parents
f80decbf
73b694e6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
2 deletions
+66
-2
kubectl-describe.1
docs/man/man1/kubectl-describe.1
+3
-0
kubectl_describe.md
docs/user-guide/kubectl/kubectl_describe.md
+4
-1
test.sh
hack/lib/test.sh
+28
-0
test-cmd.sh
hack/test-cmd.sh
+8
-0
describe.go
pkg/kubectl/cmd/describe.go
+4
-1
describe_test.go
pkg/kubectl/cmd/describe_test.go
+19
-0
No files found.
docs/man/man1/kubectl-describe.1
View file @
462fed62
...
...
@@ -159,6 +159,9 @@ $ kubectl describe pods/nginx
// Describe a pod using the data in pod.json.
$ kubectl describe \-f pod.json
// Describe all pods
$ kubectl describe pods
// Describe pods by label name=myLabel
$ kubectl describe po \-l name=myLabel
...
...
docs/user-guide/kubectl/kubectl_describe.md
View file @
462fed62
...
...
@@ -69,6 +69,9 @@ $ kubectl describe pods/nginx
// Describe a pod using the data in pod.json.
$ kubectl describe -f pod.json
// Describe all pods
$ kubectl describe pods
// Describe pods by label name=myLabel
$ kubectl describe po -l name=myLabel
...
...
@@ -118,7 +121,7 @@ $ kubectl describe pods frontend
*
[
kubectl
](
kubectl.md
)
- kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra at 2015-08-
07 07:32:08.128980687
+0000 UTC
###### Auto generated by spf13/cobra at 2015-08-
10 06:08:06.262721462
+0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[

]()
...
...
hack/lib/test.sh
View file @
462fed62
...
...
@@ -79,3 +79,31 @@ kube::test::describe_object_assert() {
echo
-n
${
reset
}
return
0
}
kube::test::describe_resource_assert
()
{
local
resource
=
$1
local
matches
=
${
@
:2
}
result
=
$(
eval
kubectl describe
"
${
kube_flags
[@]
}
"
$resource
)
for
match
in
${
matches
}
;
do
if
[[
!
$(
echo
"
$result
"
|
grep
${
match
})
]]
;
then
echo
${
bold
}${
red
}
echo
"FAIL!"
echo
"Describe
$resource
"
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
:"
echo
"
$result
"
echo
-n
${
reset
}
return
0
}
hack/test-cmd.sh
View file @
462fed62
...
...
@@ -236,6 +236,8 @@ runTests() {
kube::test::get_object_assert
'pods/valid-pod'
"{{
$id_field
}}"
'valid-pod'
# Describe command should print detailed information
kube::test::describe_object_assert pods
'valid-pod'
"Name:"
"Image(s):"
"Node:"
"Labels:"
"Status:"
"Replication Controllers"
# Describe command (resource only) should print detailed information
kube::test::describe_resource_assert pods
"Name:"
"Image(s):"
"Node:"
"Labels:"
"Status:"
"Replication Controllers"
### Dump current valid-pod POD
output_pod
=
$(
kubectl get pod valid-pod
-o
yaml
--output-version
=
v1
"
${
kube_flags
[@]
}
"
)
...
...
@@ -493,6 +495,8 @@ runTests() {
kube::test::get_object_assert services
"{{range.items}}{{
$id_field
}}:{{end}}"
'kubernetes:redis-master:'
# Describe command should print detailed information
kube::test::describe_object_assert services
'redis-master'
"Name:"
"Labels:"
"Selector:"
"IP:"
"Port:"
"Endpoints:"
"Session Affinity:"
# Describe command (resource only) should print detailed information
kube::test::describe_resource_assert services
"Name:"
"Labels:"
"Selector:"
"IP:"
"Port:"
"Endpoints:"
"Session Affinity:"
### Dump current redis-master service
output_service
=
$(
kubectl get service redis-master
-o
json
--output-version
=
v1
"
${
kube_flags
[@]
}
"
)
...
...
@@ -592,6 +596,8 @@ __EOF__
kube::test::get_object_assert rc
"{{range.items}}{{
$id_field
}}:{{end}}"
'frontend:'
# Describe command should print detailed information
kube::test::describe_object_assert rc
'frontend'
"Name:"
"Image(s):"
"Labels:"
"Selector:"
"Replicas:"
"Pods Status:"
# Describe command (resource only) should print detailed information
kube::test::describe_resource_assert rc
"Name:"
"Name:"
"Image(s):"
"Labels:"
"Selector:"
"Replicas:"
"Pods Status:"
### Scale replication controller frontend with current-replicas and replicas
# Pre-condition: 3 replicas
...
...
@@ -740,6 +746,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:"
"Labels:"
"CreationTimestamp:"
"Conditions:"
"Addresses:"
"Capacity:"
"Pods:"
# Describe command (resource only) should print detailed information
kube::test::describe_resource_assert nodes
"Name:"
"Labels:"
"CreationTimestamp:"
"Conditions:"
"Addresses:"
"Capacity:"
"Pods:"
### kubectl patch update can mark node unschedulable
# Pre-condition: node is schedulable
...
...
pkg/kubectl/cmd/describe.go
View file @
462fed62
...
...
@@ -56,6 +56,9 @@ $ kubectl describe pods/nginx
// Describe a pod using the data in pod.json.
$ kubectl describe -f pod.json
// Describe all pods
$ kubectl describe pods
// Describe pods by label name=myLabel
$ kubectl describe po -l name=myLabel
...
...
@@ -100,7 +103,7 @@ func RunDescribe(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []s
NamespaceParam
(
cmdNamespace
)
.
DefaultNamespace
()
.
FilenameParam
(
enforceNamespace
,
filenames
...
)
.
SelectorParam
(
selector
)
.
ResourceTypeOrNameArgs
(
fals
e
,
args
...
)
.
ResourceTypeOrNameArgs
(
tru
e
,
args
...
)
.
Flatten
()
.
Do
()
err
=
r
.
Err
()
...
...
pkg/kubectl/cmd/describe_test.go
View file @
462fed62
...
...
@@ -81,3 +81,22 @@ func TestDescribeObject(t *testing.T) {
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
func
TestDescribeListObjects
(
t
*
testing
.
T
)
{
pods
,
_
,
_
:=
testData
()
f
,
tf
,
codec
:=
NewAPIFactory
()
d
:=
&
testDescriber
{
Output
:
"test output"
}
tf
.
Describer
=
d
tf
.
Client
=
&
client
.
FakeRESTClient
{
Codec
:
codec
,
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
pods
)},
}
tf
.
Namespace
=
"test"
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
NewCmdDescribe
(
f
,
buf
)
cmd
.
Run
(
cmd
,
[]
string
{
"pods"
})
if
buf
.
String
()
!=
fmt
.
Sprintf
(
"%s
\n\n
%s
\n\n
"
,
d
.
Output
,
d
.
Output
)
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
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