-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
containerd: add /etc/containerd/config-rootless.toml
`/etc/containerd/config-rootless.toml` is the config for running kind in rootless Docker/Podman. * `ociwrapper` script is used to remove `.linux.resources.devices` from `config.json`, because `.linux.resources.devices` is meaningless on rootless and yet produces errors. Workaround until we get proper fixes in containerd and runc. * restrict_oom_score_adj is set to true to ignore oom_score_adj errors The entrypoint overrides `/etc/containerd/config.toml` with `config-rootless.toml` when running in rootless Docker/Podman. The rootless-ness is detected by comparing `/proc/1/uid_map` with `0 0 4294967295`. Note that Kubernetes needs to be patched as well (see the PR description text) Signed-off-by: Akihiro Suda <[email protected]>
- Loading branch information
1 parent
5590149
commit 554d2e0
Showing
5 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
# | ||
# A wrapper script to remove .linux.resources.devices, which are meaningless in userns. | ||
# Needs jq. | ||
# | ||
# Workaround until we get proper fixes in containerd and runc | ||
set -eu -o pipefail | ||
RUNTIME="runc" | ||
|
||
if egrep -q "0[[:space:]]+0[[:space:]]+4294967295" /proc/self/uid_map; then | ||
# we are not in userns, no need to patch the config | ||
exec $RUNTIME "$@" | ||
exit $? | ||
fi | ||
|
||
bundle="." | ||
bundle_flag="" | ||
# FIXME: support `--bundle=STRING` as well | ||
for f in $@; do | ||
if [[ -n $bundle_flag ]]; then | ||
bundle=$f | ||
break | ||
else | ||
case $f in | ||
-b | --bundle) | ||
bundle_flag=$f | ||
;; | ||
esac | ||
fi | ||
done | ||
|
||
if [ -f $bundle/config.json ]; then | ||
q="del(.linux.resources.devices) | del(.linux.devices)" | ||
tmp=$(mktemp -d ociwrapper.XXXXXXXX) | ||
jq "$q" <$bundle/config.json >$tmp/config.json | ||
mv $tmp/config.json $bundle/config.json | ||
rm -rf $tmp | ||
fi | ||
|
||
exec $RUNTIME "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters