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
0ac4c6a0
Commit
0ac4c6a0
authored
Jan 27, 2024
by
Edgar Lee
Committed by
Brad Davidson
Feb 09, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose rootless containerd socket directories for external access
Signed-off-by:
Edgar Lee
<
edgarhinshunlee@gmail.com
>
parent
14c6c63b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
mounts.go
pkg/rootless/mounts.go
+19
-0
No files found.
pkg/rootless/mounts.go
View file @
0ac4c6a0
...
...
@@ -6,6 +6,7 @@ package rootless
import
(
"fmt"
"os"
"os/user"
"path/filepath"
"strings"
...
...
@@ -25,11 +26,17 @@ func setupMounts(stateDir string) error {
_
=
os
.
RemoveAll
(
f
)
}
runDir
,
err
:=
resolveRunDir
()
if
err
!=
nil
{
return
err
}
mountMap
:=
[][]
string
{
{
"/var/log"
,
filepath
.
Join
(
stateDir
,
"logs"
)},
{
"/var/lib/cni"
,
filepath
.
Join
(
stateDir
,
"cni"
)},
{
"/var/lib/kubelet"
,
filepath
.
Join
(
stateDir
,
"kubelet"
)},
{
"/etc/rancher"
,
filepath
.
Join
(
stateDir
,
"etc"
,
"rancher"
)},
{
"/run/k3s/containerd"
,
filepath
.
Join
(
runDir
,
"k3s"
,
"containerd"
)},
}
for
_
,
v
:=
range
mountMap
{
...
...
@@ -91,3 +98,15 @@ func setupMount(target, dir string) error {
logrus
.
Debug
(
"Mounting "
,
dir
,
target
,
" none bind"
)
return
unix
.
Mount
(
dir
,
target
,
"none"
,
unix
.
MS_BIND
,
""
)
}
func
resolveRunDir
()
(
string
,
error
)
{
runDir
:=
os
.
Getenv
(
"XDG_RUNTIME_DIR"
)
if
runDir
==
""
{
u
,
err
:=
user
.
Lookup
(
os
.
Getenv
(
"USER"
))
if
err
!=
nil
{
return
""
,
err
}
runDir
=
filepath
.
Join
(
"/run/user"
,
u
.
Uid
)
}
return
runDir
,
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