-
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
Allow configuration of hosts on worker nodes using --add-host flag #3282
Comments
I think we should just correctly handle this case instead of adding another config surface
|
Okay, cool, I will take a closer look next week and come back with a proposal around updating that, thanks! |
I think another config surface makes a bit of sense here since this is technically a configurable surface on Docker (?). It's hard to anticipate every need going into the future IMO, and this definitely isn't something that should be on by default I think either. |
From a maintainability point of view we do NOT support all possible docker options. The goal is to provide Kubernetes clusters, and every knob is another possible broken interaction that we need to test and support.
It's not supportable to cover every possible usage anyhow. |
I was wrong, see below. |
This is possible with or without the host name. The hostname just makes it slightly less complicated to discover the IP. There are docker installs (mac, Windows) that already have the host name available by default. One thing not discussed so far: podman and #3429 (nerctl) |
Yep, sorry I forgot to come back to this issue later. You're right this has no impact on security considerations from that perspective. |
What would you like to be added:
In the Docker provision module there is logic that assembles the arguments for running Nodes. While there are many arguments that can be specified, one that is missing is the --add-host flag.
The addition of this flag would be very beneficial to alleviate an issue we have happened across, described below.
The general idea would be to add a new block (
extra_hosts
?) to the configuration that defines a single flag instance to be passed through to the Docker run command, thus this:would translate to:
--add-host=host.docker.internal:172.17.0.1
Of course naming is hard, so those names are just placeholders pending discussion.
I am willing to do the work, scheduling and timing T.B.D. if the community believes this is a worthwhile effort.
Why is this needed:
Docker Networking and the magic host
When running Docker on Mac and Windows there exists a magic host entry (host.docker.internal) that can be used to reference other containers running in Docker.
This host is not available, by default, when running Docker in Linux. It is possible to add this host when running an image with the
--add-host=host.docker.internal:host-gateway
flag, e.g.:### Note: the --add-host flag is required only when running Docker on Linux... docker run -rm -dit --add-host:host.docker.internal:host-gateway
This is a pretty straight-forward way to ensure the DNS entry is available in Linux.
While there are a number of available options for configuring system nodes using Kind; the option to add hosts does not exist.
This means there is no straight-forward way to add the magic Docker DNS entry to the Kind Worker Nodes when running on Linux.
Options
Three options were considered for solving this issue:
/etc/hosts
file;--add-hosts
flag;Spike the DNS entries
This was a super hacky way of solving the issue by running a command on each worker node that added an entry to the hosts file for
host.docker.internal
.Note: The
172.17.0.1
magic IP address is the default IP for the Docker bridge network.Submit a PR to Kind
This is actually the most desirable solution. It is clean, it improves the quality of an existing project that is widely used and respected, and it avoids any hackery to the Kubernetes cluster.
Update CoreDNS hosts
This involves editing a ConfigMap in the Cluster used by CoreDNS for configuration. CoreDNS allows configuration of plugins in the ConfigMap, one of which is the hosts plugin.
This involves a manual step, and manual input which can be error-prone; however, the editing mechanism in k8s includes a validation
step that disallows invalid ConfigMaps from being applied. So there is a safety net in place.
The general idea is:
kubectl edit
to edit the CoreDNS ConfigMap;Workaround
We are presently using the third option, updating the CoreDNS Corefile with the record, but as noted, being able to do this in Kind would be ideal.
The text was updated successfully, but these errors were encountered: