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
3841690d
Commit
3841690d
authored
Jan 17, 2017
by
Julien Balestra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kubelet-rkt: Add useful informations for Ops on the Kubelet Host
Create a Systemd SyslogIdentifier inside the [Service] Create a Systemd Description inside the [Unit]
parent
7b471136
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
rkt.go
pkg/kubelet/rkt/rkt.go
+15
-0
rkt_test.go
pkg/kubelet/rkt/rkt_test.go
+29
-0
No files found.
pkg/kubelet/rkt/rkt.go
View file @
3841690d
...
...
@@ -1108,6 +1108,18 @@ func (r *Runtime) getSelinuxContext(opt *v1.SELinuxOptions) (string, error) {
return
strings
.
Join
(
ctx
,
":"
),
nil
}
// From the generateName or the podName return a basename for improve the logging with the Journal
// journalctl -t podBaseName
func
constructSyslogIdentifier
(
generateName
string
,
podName
string
)
string
{
if
(
len
(
generateName
)
>
1
&&
generateName
[
len
(
generateName
)
-
1
]
==
'-'
)
{
return
generateName
[
0
:
len
(
generateName
)
-
1
]
}
else
if
(
len
(
generateName
)
>
0
)
{
return
generateName
}
else
{
return
podName
}
}
// preparePod will:
//
// 1. Invoke 'rkt prepare' to prepare the pod, and get the rkt pod uuid.
...
...
@@ -1174,6 +1186,9 @@ func (r *Runtime) preparePod(pod *v1.Pod, podIP string, pullSecrets []v1.Secret,
// This enables graceful stop.
newUnitOption
(
"Service"
,
"KillMode"
,
"mixed"
),
newUnitOption
(
"Service"
,
"TimeoutStopSec"
,
fmt
.
Sprintf
(
"%ds"
,
getPodTerminationGracePeriodInSecond
(
pod
))),
// Ops helpers
newUnitOption
(
"Unit"
,
"Description"
,
pod
.
Name
),
newUnitOption
(
"Service"
,
"SyslogIdentifier"
,
constructSyslogIdentifier
(
pod
.
GenerateName
,
pod
.
Name
)),
// Track pod info for garbage collection
newUnitOption
(
unitKubernetesSection
,
unitPodUID
,
string
(
pod
.
UID
)),
newUnitOption
(
unitKubernetesSection
,
unitPodName
,
pod
.
Name
),
...
...
pkg/kubelet/rkt/rkt_test.go
View file @
3841690d
...
...
@@ -1952,3 +1952,31 @@ func TestPreparePodArgs(t *testing.T) {
assert
.
Equal
(
t
,
testCase
.
cmd
,
cmd
,
fmt
.
Sprintf
(
"Test case #%d"
,
i
))
}
}
func
TestConstructSyslogIdentifier
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
podName
string
podGenerateName
string
identifier
string
}{
{
"prometheus-node-exporter-rv90m"
,
"prometheus-node-exporter-"
,
"prometheus-node-exporter"
,
},
{
"simplepod"
,
""
,
"simplepod"
,
},
{
"p"
,
""
,
"p"
,
},
}
for
i
,
testCase
:=
range
testCases
{
identifier
:=
constructSyslogIdentifier
(
testCase
.
podGenerateName
,
testCase
.
podName
)
assert
.
Equal
(
t
,
testCase
.
identifier
,
identifier
,
fmt
.
Sprintf
(
"Test case #%d"
,
i
))
}
}
\ No newline at end of file
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