Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hepto
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACIDES
Hepto
Commits
691ff236
Commit
691ff236
authored
2 years ago
by
kaiyou
Browse files
Options
Downloads
Patches
Plain Diff
Evacuate cgroups and use cgroupfs for kubelets
parent
a639ec3b
No related branches found
Branches containing commit
Tags
v3.0.0rc1
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/cluster/kubeconfig.go
+1
-1
1 addition, 1 deletion
pkg/cluster/kubeconfig.go
pkg/selfcontain/init.go
+21
-6
21 additions, 6 deletions
pkg/selfcontain/init.go
with
22 additions
and
7 deletions
pkg/cluster/kubeconfig.go
+
1
−
1
View file @
691ff236
...
...
@@ -60,7 +60,7 @@ authorization:
clusterDomain: "cluster.local"
imageMinimumGCAge: "120h"
resolvConf: "/etc/resolv.conf"
cgroupDriver:
systemd
cgroupDriver:
cgroupfs
runtimeRequestTimeout: "15m"
tlsCertFile: "{{.TLSCert}}"
tlsPrivateKeyFile: "{{.TLSKey}}"
...
...
This diff is collapsed.
Click to expand it.
pkg/selfcontain/init.go
+
21
−
6
View file @
691ff236
...
...
@@ -9,10 +9,10 @@ import (
)
// libcontainer uses a three-step containerization technique:
// 1. spawn a fifo for later communication with containerized init
// 2. unshare the current process and fork/execve /proc/self/exe with a
// special argument to trigger later initialization
// 3. Use the fifo to communicatie with init and initialize mounts, etc.
//
1. spawn a fifo for later communication with containerized init
//
2. unshare the current process and fork/execve /proc/self/exe with a
//
special argument to trigger later initialization
//
3. Use the fifo to communicatie with init and initialize mounts, etc.
//
// This init checks for said special argument and call into libcontainer
// initialization routines, which in turn will execve the Process provided
...
...
@@ -25,11 +25,26 @@ func init() {
// Do not start the full featured runtime
runtime
.
GOMAXPROCS
(
1
)
runtime
.
LockOSThread
()
// Evacuate cgroups, which is required for many in-container cgroup
// use cases, since we are now at the root cgroup
// Libcontainer cgroup manager is not designed for evacuation and will
// fail in such a case, so we are using cgroupfs directly, which is
// explicitely available due to defaults, and simple since we are
// the only running process at the moment
err
:=
os
.
Mkdir
(
"/sys/fs/cgroup/selfcontain"
,
0
o755
)
if
err
!=
nil
{
logrus
.
Fatal
(
"could not create evacuation cgroup: "
,
err
)
}
err
=
os
.
WriteFile
(
"/sys/fs/cgroup/selfcon/cgroup.procs"
,
[]
byte
(
"0"
),
0
o755
)
if
err
!=
nil
{
logrus
.
Fatal
(
"could not evacuate self: "
,
err
)
}
// Run libcontainer initialization, which will fork/exec to the
// provided process executable, a.k.a ourselves
factory
,
_
:=
libcontainer
.
New
(
""
)
if
err
:=
factory
.
StartInitialization
();
err
!=
nil
{
logrus
.
Fatal
(
err
)
err
=
factory
.
StartInitialization
()
if
err
!=
nil
{
logrus
.
Fatal
(
"could not run self-contained app: "
,
err
)
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment