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
698e8dd0
Commit
698e8dd0
authored
Feb 05, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kubectl should be able to display endpoints directly and for service
kubectl get endpoints <servicename> kubectl describe service <servicename> should have printers for endpoints
parent
bb6b332a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
describe.go
pkg/kubectl/describe.go
+6
-0
resource_printer.go
pkg/kubectl/resource_printer.go
+14
-0
resource_printer_test.go
pkg/kubectl/resource_printer_test.go
+2
-1
No files found.
pkg/kubectl/describe.go
View file @
698e8dd0
...
@@ -249,6 +249,11 @@ func (d *ServiceDescriber) Describe(namespace, name string) (string, error) {
...
@@ -249,6 +249,11 @@ func (d *ServiceDescriber) Describe(namespace, name string) (string, error) {
return
""
,
err
return
""
,
err
}
}
endpoints
,
err
:=
d
.
Endpoints
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
endpoints
=
&
api
.
Endpoints
{}
}
events
,
_
:=
d
.
Events
(
namespace
)
.
Search
(
service
)
events
,
_
:=
d
.
Events
(
namespace
)
.
Search
(
service
)
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
return
tabbedString
(
func
(
out
io
.
Writer
)
error
{
...
@@ -256,6 +261,7 @@ func (d *ServiceDescriber) Describe(namespace, name string) (string, error) {
...
@@ -256,6 +261,7 @@ func (d *ServiceDescriber) Describe(namespace, name string) (string, error) {
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
formatLabels
(
service
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
formatLabels
(
service
.
Labels
))
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
formatLabels
(
service
.
Spec
.
Selector
))
fmt
.
Fprintf
(
out
,
"Selector:
\t
%s
\n
"
,
formatLabels
(
service
.
Spec
.
Selector
))
fmt
.
Fprintf
(
out
,
"Port:
\t
%d
\n
"
,
service
.
Spec
.
Port
)
fmt
.
Fprintf
(
out
,
"Port:
\t
%d
\n
"
,
service
.
Spec
.
Port
)
fmt
.
Fprintf
(
out
,
"Endpoints:
\t
%s
\n
"
,
stringList
(
endpoints
.
Endpoints
))
if
events
!=
nil
{
if
events
!=
nil
{
describeEvents
(
events
,
out
)
describeEvents
(
events
,
out
)
}
}
...
...
pkg/kubectl/resource_printer.go
View file @
698e8dd0
...
@@ -218,6 +218,7 @@ func (h *HumanReadablePrinter) validatePrintHandlerFunc(printFunc reflect.Value)
...
@@ -218,6 +218,7 @@ func (h *HumanReadablePrinter) validatePrintHandlerFunc(printFunc reflect.Value)
var
podColumns
=
[]
string
{
"POD"
,
"IP"
,
"CONTAINER(S)"
,
"IMAGE(S)"
,
"HOST"
,
"LABELS"
,
"STATUS"
}
var
podColumns
=
[]
string
{
"POD"
,
"IP"
,
"CONTAINER(S)"
,
"IMAGE(S)"
,
"HOST"
,
"LABELS"
,
"STATUS"
}
var
replicationControllerColumns
=
[]
string
{
"CONTROLLER"
,
"CONTAINER(S)"
,
"IMAGE(S)"
,
"SELECTOR"
,
"REPLICAS"
}
var
replicationControllerColumns
=
[]
string
{
"CONTROLLER"
,
"CONTAINER(S)"
,
"IMAGE(S)"
,
"SELECTOR"
,
"REPLICAS"
}
var
serviceColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
serviceColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
endpointColumns
=
[]
string
{
"NAME"
,
"ENDPOINTS"
}
var
minionColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"STATUS"
}
var
minionColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"STATUS"
}
var
statusColumns
=
[]
string
{
"STATUS"
}
var
statusColumns
=
[]
string
{
"STATUS"
}
var
eventColumns
=
[]
string
{
"TIME"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"REASON"
,
"SOURCE"
,
"MESSAGE"
}
var
eventColumns
=
[]
string
{
"TIME"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"REASON"
,
"SOURCE"
,
"MESSAGE"
}
...
@@ -232,6 +233,7 @@ func (h *HumanReadablePrinter) addDefaultHandlers() {
...
@@ -232,6 +233,7 @@ func (h *HumanReadablePrinter) addDefaultHandlers() {
h
.
Handler
(
replicationControllerColumns
,
printReplicationControllerList
)
h
.
Handler
(
replicationControllerColumns
,
printReplicationControllerList
)
h
.
Handler
(
serviceColumns
,
printService
)
h
.
Handler
(
serviceColumns
,
printService
)
h
.
Handler
(
serviceColumns
,
printServiceList
)
h
.
Handler
(
serviceColumns
,
printServiceList
)
h
.
Handler
(
endpointColumns
,
printEndpoints
)
h
.
Handler
(
minionColumns
,
printMinion
)
h
.
Handler
(
minionColumns
,
printMinion
)
h
.
Handler
(
minionColumns
,
printMinionList
)
h
.
Handler
(
minionColumns
,
printMinionList
)
h
.
Handler
(
statusColumns
,
printStatus
)
h
.
Handler
(
statusColumns
,
printStatus
)
...
@@ -255,6 +257,13 @@ func (h *HumanReadablePrinter) printHeader(columnNames []string, w io.Writer) er
...
@@ -255,6 +257,13 @@ func (h *HumanReadablePrinter) printHeader(columnNames []string, w io.Writer) er
return
nil
return
nil
}
}
func
stringList
(
list
[]
string
)
string
{
if
len
(
list
)
==
0
{
return
"<empty>"
}
return
strings
.
Join
(
list
,
","
)
}
func
podHostString
(
host
,
ip
string
)
string
{
func
podHostString
(
host
,
ip
string
)
string
{
if
host
==
""
&&
ip
==
""
{
if
host
==
""
&&
ip
==
""
{
return
"<unassigned>"
return
"<unassigned>"
...
@@ -352,6 +361,11 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
...
@@ -352,6 +361,11 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
return
nil
return
nil
}
}
func
printEndpoints
(
endpoint
*
api
.
Endpoints
,
w
io
.
Writer
)
error
{
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\n
"
,
endpoint
.
Name
,
stringList
(
endpoint
.
Endpoints
))
return
err
}
func
printMinion
(
minion
*
api
.
Node
,
w
io
.
Writer
)
error
{
func
printMinion
(
minion
*
api
.
Node
,
w
io
.
Writer
)
error
{
conditionMap
:=
make
(
map
[
api
.
NodeConditionKind
]
*
api
.
NodeCondition
)
conditionMap
:=
make
(
map
[
api
.
NodeConditionKind
]
*
api
.
NodeCondition
)
NodeAllConditions
:=
[]
api
.
NodeConditionKind
{
api
.
NodeReady
,
api
.
NodeReachable
}
NodeAllConditions
:=
[]
api
.
NodeConditionKind
{
api
.
NodeReady
,
api
.
NodeReachable
}
...
...
pkg/kubectl/resource_printer_test.go
View file @
698e8dd0
...
@@ -452,10 +452,11 @@ func TestPrinters(t *testing.T) {
...
@@ -452,10 +452,11 @@ func TestPrinters(t *testing.T) {
"pod"
:
&
api
.
Pod
{
ObjectMeta
:
om
(
"pod"
)},
"pod"
:
&
api
.
Pod
{
ObjectMeta
:
om
(
"pod"
)},
"emptyPodList"
:
&
api
.
PodList
{},
"emptyPodList"
:
&
api
.
PodList
{},
"nonEmptyPodList"
:
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{{}}},
"nonEmptyPodList"
:
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{{}}},
"endpoints"
:
&
api
.
Endpoints
{
Endpoints
:
[]
string
{
"127.0.0.1"
,
"localhost:8080"
}},
}
}
// map of printer name to set of objects it should fail on.
// map of printer name to set of objects it should fail on.
expectedErrors
:=
map
[
string
]
util
.
StringSet
{
expectedErrors
:=
map
[
string
]
util
.
StringSet
{
"template2"
:
util
.
NewStringSet
(
"pod"
,
"emptyPodList"
),
"template2"
:
util
.
NewStringSet
(
"pod"
,
"emptyPodList"
,
"endpoints"
),
}
}
for
pName
,
p
:=
range
printers
{
for
pName
,
p
:=
range
printers
{
...
...
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