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
a8a37fb7
Commit
a8a37fb7
authored
May 22, 2018
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created directories in /var/lib/kubelet directly.
parent
9f80de37
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
server.go
cmd/kubelet/app/server.go
+1
-1
nsenter_mount.go
pkg/util/mount/nsenter_mount.go
+23
-3
nsenter_mount_unsupported.go
pkg/util/mount/nsenter_mount_unsupported.go
+1
-1
No files found.
cmd/kubelet/app/server.go
View file @
a8a37fb7
...
...
@@ -360,7 +360,7 @@ func UnsecuredDependencies(s *options.KubeletServer) (*kubelet.Dependencies, err
var
writer
kubeio
.
Writer
=
&
kubeio
.
StdWriter
{}
if
s
.
Containerized
{
glog
.
V
(
2
)
.
Info
(
"Running kubelet in containerized mode"
)
mounter
,
err
=
mount
.
NewNsenterMounter
()
mounter
,
err
=
mount
.
NewNsenterMounter
(
s
.
RootDirectory
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/util/mount/nsenter_mount.go
View file @
a8a37fb7
...
...
@@ -43,9 +43,15 @@ const (
// the host's mount namespace.
type
NsenterMounter
struct
{
ne
*
nsenter
.
Nsenter
// rootDir is location of /var/lib/kubelet directory.
rootDir
string
}
func
NewNsenterMounter
()
(
*
NsenterMounter
,
error
)
{
// NewNsenterMounter creates a new mounter for kubelet that runs as a container.
// rootDir is location of /var/lib/kubelet directory (in case it's not on the
// default place). This directory must be available in the container
// on the same place as it's on the host.
func
NewNsenterMounter
(
rootDir
string
)
(
*
NsenterMounter
,
error
)
{
ne
,
err
:=
nsenter
.
NewNsenter
()
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -305,14 +311,28 @@ func (mounter *NsenterMounter) SafeMakeDir(subdir string, base string, perm os.F
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error resolving symlinks in %s: %s"
,
fullSubdirPath
,
err
)
}
kubeletSubdirPath
:=
mounter
.
ne
.
KubeletPath
(
evaluatedSubdirPath
)
evaluatedSubdirPath
=
filepath
.
Clean
(
evaluatedSubdirPath
)
evaluatedBase
,
err
:=
mounter
.
ne
.
EvalSymlinks
(
base
,
true
/* mustExist */
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error resolving symlinks in %s: %s"
,
base
,
err
)
}
kubeletBase
:=
mounter
.
ne
.
KubeletPath
(
evaluatedBase
)
evaluatedBase
=
filepath
.
Clean
(
evaluatedBase
)
rootDir
:=
filepath
.
Clean
(
mounter
.
rootDir
)
if
pathWithinBase
(
evaluatedBase
,
rootDir
)
{
// Base is in /var/lib/kubelet. This directory is shared between the
// container with kubelet and the host. We don't need to add '/rootfs'.
// This is useful when /rootfs is mounted as read-only - we can still
// create subpaths for paths in /var/lib/kubelet.
return
doSafeMakeDir
(
evaluatedSubdirPath
,
evaluatedBase
,
perm
)
}
// Base is somewhere on the host's filesystem. Add /rootfs and try to make
// the directory there.
// This requires /rootfs to be writable.
kubeletSubdirPath
:=
mounter
.
ne
.
KubeletPath
(
evaluatedSubdirPath
)
kubeletBase
:=
mounter
.
ne
.
KubeletPath
(
evaluatedBase
)
return
doSafeMakeDir
(
kubeletSubdirPath
,
kubeletBase
,
perm
)
}
...
...
pkg/util/mount/nsenter_mount_unsupported.go
View file @
a8a37fb7
...
...
@@ -25,7 +25,7 @@ import (
type
NsenterMounter
struct
{}
func
NewNsenterMounter
()
(
*
NsenterMounter
,
error
)
{
func
NewNsenterMounter
(
rootDir
string
)
(
*
NsenterMounter
,
error
)
{
return
&
NsenterMounter
{},
nil
}
...
...
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