-
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.
Support Rootless Docker, with vanilla Kubernetes
Signed-off-by: Akihiro Suda <[email protected]>
- Loading branch information
1 parent
abd0bfd
commit 3304c25
Showing
5 changed files
with
193 additions
and
6 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
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,51 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2020 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
RUNTIME="runc" | ||
|
||
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 | ||
# kube-proxy wants to read "/sys/module/nf_conntrack/parameters/hashsize", but it fails with EACCES when running inside userns. | ||
# So we bind-mount a fake file. | ||
# Workaround until https://github.com/kubernetes/kubernetes/pull/92863 gets merged | ||
echo "65536" >"/run/nf_conntrack_fake_hashsize" | ||
q='.mounts += [{"destination": "/sys/module/nf_conntrack/parameters/hashsize", "source": "/run/nf_conntrack_fake_hashsize", "type": "none", "options": ["bind"]}]' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,6 +425,50 @@ The structure of the logs will look more or less like this: | |
The logs contain information about the Docker host, the containers running | ||
kind, the Kubernetes cluster itself, etc. | ||
|
||
### Rootless Docker | ||
|
||
Starting with kind 0.10.0 and Docker 20.10, Rootless Docker can be used as the node provider of kind. | ||
|
||
#### Host requirements | ||
The host needs to be running with cgroup v2. | ||
|
||
cgroup v2 is enabled by default on Fedora. | ||
On other distros, cgroup v2 can be typically enabled by adding `GRUB_CMDLINE_LINUX="systemd.unified_cgroup_hierarchy=1"` to `/etc/default/grub` and | ||
running `sudo update-grub`. | ||
|
||
Also, depending on the host configuration, the following steps might be needed: | ||
|
||
- Create `/etc/systemd/system/[email protected]/delegate.conf` with the following content, and then run `sudo systemctl daemon-reload`: | ||
``` | ||
[Service] | ||
Delegate=yes | ||
EOF | ||
``` | ||
|
||
- Create `/etc/sysctl.d/99-rootless.conf` with the following content, and then run `sudo sysctl --system`: | ||
``` | ||
kernel.dmesg_restrict=0 | ||
``` | ||
|
||
#### Restrictions | ||
|
||
The restrictions of Rootless Docker applies to kind clusters as well. | ||
|
||
e.g. | ||
- OverlayFS cannot be used unless the host is Ubuntu or Debian | ||
- Cannot mount block storages | ||
- Cannot mount NFS | ||
|
||
#### Creating a kind cluster with Rootless Docker | ||
|
||
To create a kind cluster with Rootless Docker, just run `kind create cluster` command with | ||
`DOCKER_HOST=unix://${XDG_RUNTIME_DIR}/docker.sock`. | ||
|
||
```console | ||
$ export DOCKER_HOST=unix://${XDG_RUNTIME_DIR}/docker.sock | ||
$ kind create cluster | ||
``` | ||
|
||
[go-supported]: https://golang.org/doc/devel/release.html#policy | ||
[known issues]: /docs/user/known-issues | ||
[releases]: https://github.com/kubernetes-sigs/kind/releases | ||
|