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
2b91c141
Commit
2b91c141
authored
Jan 05, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create selfLink for pods from config files and indicate hostname as part of event source.
parent
3a4d5fd6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
3 deletions
+13
-3
resource_printer.go
pkg/kubectl/resource_printer.go
+3
-2
file.go
pkg/kubelet/config/file.go
+5
-0
file_test.go
pkg/kubelet/config/file_test.go
+3
-0
util.go
pkg/kubelet/util.go
+2
-1
No files found.
pkg/kubectl/resource_printer.go
View file @
2b91c141
...
@@ -193,7 +193,7 @@ var replicationControllerColumns = []string{"CONTROLLER", "CONTAINER(S)", "IMAGE
...
@@ -193,7 +193,7 @@ var replicationControllerColumns = []string{"CONTROLLER", "CONTAINER(S)", "IMAGE
var
serviceColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
serviceColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
minionColumns
=
[]
string
{
"NAME"
,
"LABELS"
}
var
minionColumns
=
[]
string
{
"NAME"
,
"LABELS"
}
var
statusColumns
=
[]
string
{
"STATUS"
}
var
statusColumns
=
[]
string
{
"STATUS"
}
var
eventColumns
=
[]
string
{
"TIME"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"CONDITION"
,
"REASON"
,
"MESSAGE"
}
var
eventColumns
=
[]
string
{
"TIME"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"CONDITION"
,
"REASON"
,
"
SOURCE"
,
"
MESSAGE"
}
// addDefaultHandlers adds print handlers for default Kubernetes types.
// addDefaultHandlers adds print handlers for default Kubernetes types.
func
(
h
*
HumanReadablePrinter
)
addDefaultHandlers
()
{
func
(
h
*
HumanReadablePrinter
)
addDefaultHandlers
()
{
...
@@ -339,13 +339,14 @@ func printStatus(status *api.Status, w io.Writer) error {
...
@@ -339,13 +339,14 @@ func printStatus(status *api.Status, w io.Writer) error {
func
printEvent
(
event
*
api
.
Event
,
w
io
.
Writer
)
error
{
func
printEvent
(
event
*
api
.
Event
,
w
io
.
Writer
)
error
{
_
,
err
:=
fmt
.
Fprintf
(
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\n
"
,
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\
t
%s
\
n
"
,
event
.
Timestamp
.
Time
.
Format
(
time
.
RFC1123Z
),
event
.
Timestamp
.
Time
.
Format
(
time
.
RFC1123Z
),
event
.
InvolvedObject
.
Name
,
event
.
InvolvedObject
.
Name
,
event
.
InvolvedObject
.
Kind
,
event
.
InvolvedObject
.
Kind
,
event
.
InvolvedObject
.
FieldPath
,
event
.
InvolvedObject
.
FieldPath
,
event
.
Condition
,
event
.
Condition
,
event
.
Reason
,
event
.
Reason
,
event
.
Source
,
event
.
Message
,
event
.
Message
,
)
)
return
err
return
err
...
...
pkg/kubelet/config/file.go
View file @
2b91c141
...
@@ -159,6 +159,11 @@ func extractFromFile(filename string) (api.BoundPod, error) {
...
@@ -159,6 +159,11 @@ func extractFromFile(filename string) (api.BoundPod, error) {
if
len
(
pod
.
Namespace
)
==
0
{
if
len
(
pod
.
Namespace
)
==
0
{
pod
.
Namespace
=
api
.
NamespaceDefault
pod
.
Namespace
=
api
.
NamespaceDefault
}
}
// TODO(dchen1107): BoundPod is not type of runtime.Object. Once we allow kubelet talks
// about Pod directly, we can use SelfLinker defined in package: latest
// Currently just simply follow the same format in resthandler.go
pod
.
ObjectMeta
.
SelfLink
=
fmt
.
Sprintf
(
"/api/v1beta2/pods/%s?namespace=%s"
,
pod
.
Name
,
pod
.
Namespace
)
if
glog
.
V
(
4
)
{
if
glog
.
V
(
4
)
{
glog
.
Infof
(
"Got pod from file %q: %#v"
,
filename
,
pod
)
glog
.
Infof
(
"Got pod from file %q: %#v"
,
filename
,
pod
)
...
...
pkg/kubelet/config/file_test.go
View file @
2b91c141
...
@@ -124,6 +124,7 @@ func TestReadFromFile(t *testing.T) {
...
@@ -124,6 +124,7 @@ func TestReadFromFile(t *testing.T) {
Name
:
"test"
,
Name
:
"test"
,
UID
:
simpleSubdomainSafeHash
(
file
.
Name
()),
UID
:
simpleSubdomainSafeHash
(
file
.
Name
()),
Namespace
:
"default"
,
Namespace
:
"default"
,
SelfLink
:
"/api/v1beta2/pods/test?namespace=default"
,
},
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"test/image"
,
TerminationMessagePath
:
"/dev/termination-log"
}},
Containers
:
[]
api
.
Container
{{
Image
:
"test/image"
,
TerminationMessagePath
:
"/dev/termination-log"
}},
...
@@ -161,6 +162,7 @@ func TestExtractFromValidDataFile(t *testing.T) {
...
@@ -161,6 +162,7 @@ func TestExtractFromValidDataFile(t *testing.T) {
file
:=
writeTestFile
(
t
,
os
.
TempDir
(),
"test_pod_config"
,
string
(
text
))
file
:=
writeTestFile
(
t
,
os
.
TempDir
(),
"test_pod_config"
,
string
(
text
))
defer
os
.
Remove
(
file
.
Name
())
defer
os
.
Remove
(
file
.
Name
())
expectedPod
.
ObjectMeta
.
SelfLink
=
"/api/v1beta2/pods/"
+
expectedPod
.
Name
+
"?namespace=default"
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
sourceFile
{
file
.
Name
(),
ch
}
c
:=
sourceFile
{
file
.
Name
(),
ch
}
err
=
c
.
extractFromPath
()
err
=
c
.
extractFromPath
()
...
@@ -226,6 +228,7 @@ func TestExtractFromDir(t *testing.T) {
...
@@ -226,6 +228,7 @@ func TestExtractFromDir(t *testing.T) {
}
}
ioutil
.
WriteFile
(
name
,
data
,
0755
)
ioutil
.
WriteFile
(
name
,
data
,
0755
)
files
[
i
]
=
file
files
[
i
]
=
file
pods
[
i
]
.
ObjectMeta
.
SelfLink
=
"/api/v1beta2/pods/"
+
pods
[
i
]
.
Name
+
"?namespace=default"
}
}
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
...
...
pkg/kubelet/util.go
View file @
2b91c141
...
@@ -130,8 +130,9 @@ func SetupEventSending(authPath string, apiServerList util.StringList) {
...
@@ -130,8 +130,9 @@ func SetupEventSending(authPath string, apiServerList util.StringList) {
glog
.
Errorf
(
"Unable to make apiserver client: %v"
,
err
)
glog
.
Errorf
(
"Unable to make apiserver client: %v"
,
err
)
}
else
{
}
else
{
// Send events to APIserver if there is a client.
// Send events to APIserver if there is a client.
hostname
:=
util
.
GetHostname
(
""
)
glog
.
Infof
(
"Sending events to APIserver."
)
glog
.
Infof
(
"Sending events to APIserver."
)
record
.
StartRecording
(
apiClient
.
Events
(
""
),
"kubelet
"
)
record
.
StartRecording
(
apiClient
.
Events
(
""
),
"kubelet
:"
+
hostname
)
}
}
}
}
}
}
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