-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cant create a kind cluster after delete cluster in a docker in docker vscode devcontainer #3370
Comments
We don't recommend this and it may be a bug in the docker in docker environment. Please avoid adding additional nesting, it's a real headache to debug. |
@BenTheElder, I see that you replied this to a lot of similar issues lately, but I just want to say that using kind within an already containerized environment is a totally acceptable use case. Two important use cases:
I understand that this adds complexity on your end and makes debugging more difficult, but I just want to make sure you're aware of the valid use cases of running kind in containerized environments. Those use cases won't go away. @KieranJeffreySmart, see #3283 (comment). TL;DR, you likely need to enable cgroup v2 on the VM on which Docker runs for kind v20+ to work properly. |
I'm aware of the use cases, but we have limited bandwidth to provide supprt and it's available as a static go binary, you can't containerize docker itself either. We'll happily review proposed fixes from contributors but I just cannot justify spending my own time debugging this versus steering people towards more debuggable alternatives. Kind is already running containers in containers which is unfortunately insecure and error prone but similarly useful, I highly recommend avoid doing this again with another layer. See also #303 for additional footguns running nested inside of another Kubernetes cluster. |
For Windows specifically: #1529, nobody has contributed to work on CI for windows. ... let alone adding container nesting on Windows. |
Quick note for the audience with no Windows exposure: containers/docker on Windows (except for actual Windows containers which nobody uses) runs in a Linux kernel and for the most part behaves the same as if it were running on a bare metal Linux box. Although it's convenient, you don't need to run Docker Desktop on Windows -- regular Linux docker, or podman will work fine inside WSL2. Therefore the issues with nesting containers are essentially the same as for stock Linux. |
We tell people to avoid running kind in docker-in-docker on Linux. It's generally not necessary (it's no more secure than just passing the host dockerd socket, and more effort) and creates a lot of additional problems. There are some use cases where it makes sense, but adding another layer of nested containers is very "here be dragons". |
Also the environment in WSL2 is different from Linux run elsewhere, e.g. it often has a custom init system, and we don't have easy access to reproduce and debug (or the time / inclination really, there's so much to do and OSS developers could use Linux and we don't use Windows ourselves, nor is it really supported for developing Kubernetes/Kubernetes https://kind.sigs.k8s.io/docs/contributing/project-scope/) (Difference in the init, Kernel => different cgroups management => impact on containers) |
init is out of scope here though, since we're running inside a container. btw it turns out nested kind works just fine now, provided the container has the necessary secret sauce. The stock docker:dind container is an example of such a thing, albeit Alpine so...not for everyone. There is an Ubuntu equivalent image that also works: https://github.com/cruizba/ubuntu-dind You can start that container, install kind (or k3d) and create a cluster. It can be used as an existence proof from which to generate your own image for CI and so on. |
It's not, the init is responsible for setting up cgroups amongst other things and we're sharing that along with the rest of the kernel from the host since we're using containers instead of VMs. Privileged containers like kind nodes are "leakier" than normal containers but all containers are influenced by the host's init. |
Well, I've tested stock WSL2 on x86 and it works. I'll try aarm64 and report back... |
Reporting back: ARM WSL2 doesn't work :( |
Fwiw, the issue where |
This sort of problem is likely eliminated in cgroup v2+ cgroupns hosts and cgroup v1 is going into maintenance mode by Kubernetes kubernetes/enhancements#4572 and deprecated soon by various ecosystem projects (like OCI, systemd) On cgroup v1 we started forcing cgroupns=private on kind nodes which may help with some of these problems. |
@BenTheElder spent hours looking at this. Thanks for the hint.
My kind devcontainer then worked! |
awesome! maybe we should add this as a hint to https://kind.sigs.k8s.io/docs/user/using-wsl2/ |
What happened:
I am trying to create a kind cluster in a vscode devcontainer. I am working on windows with docker desktop and have been using a docker inside docker template.
When the container is first constructed I am able to create a cluster using kind create cluster from a terminal within the container and this works successful
However if i delete the cluster and try to create again it fails.
This doesn't happen when I repeat the process on the host windows machine, it will create every time.
This is to be used in a script so I need it to be repeatable, delete cluster then create cluster
kind-control-plane.zip
Thanks in advance for any assistance
What you expected to happen:
A new cluster is created
How to reproduce it (as minimally and precisely as possible):
New Dev Container...
menu optionkind create cluster
kind delete cluster
kind create cluster
Anything else we need to know?:
Environment:
Windows 11
Docker Desktop 4.23.0
Dev Container Features
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/mpriscella/features/kind:1": {},
"ghcr.io/devcontainers-contrib/features/kubectl-asdf:2": {}
Docker Info from inside Dev Container:
The text was updated successfully, but these errors were encountered: