Skip to content
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

Add support for publishing ports #40

Open
klutchell opened this issue Dec 8, 2023 · 8 comments
Open

Add support for publishing ports #40

klutchell opened this issue Dec 8, 2023 · 8 comments

Comments

@klutchell
Copy link
Collaborator

The host container is already running in host networking mode in order to create the TUN/TAP device, we just need to accept some port ranges via (env vars?) and create the required IP tables rules similar to how Docker would do.

@klutchell
Copy link
Collaborator Author

A better solution would be a bridge network for each VM that listens on all ports.

Perhaps we connect to the existing docker bridge?

@ab77
Copy link

ab77 commented Dec 11, 2023

Looking at the current implementation, the best option IMO, is to add a small haproxy load balancer to remote-workers-* compositions, which will map microVM ip:ports to the host's public interface (e.g. statically):

default
  mode tcp
  log stdout format raw daemon
  option tcplog
  timeout client  5s
  timeout connect 3600s # increase if required
  timeout server  3600s # increase if required

listen tcp-2376
  bind :2376
  server vm1 10.152.66.2:2376
  ...

listen tcp-2377
  bind :2377
  ...

This works because the tun-tap interfaces are available on the hostOS already, so a haproxy service running with host networking, will be able to proxy to these. We'll just need to set well known subnets, since random won't work with static haproxy config (unless we pipe it through envsubst).

.. outside of the MVP scope, for multiple VMs, we would expand to multiple frontend listeners (e.g. tcp-23761, tcp-23762, etc.).

.. for dynamic service discovery, we can implement a solution with haproxy + firecracker API. Fir example, running a supervisor process polling local firecracker APIs and updating HAProxy backends using its socket (mapped into each jailer container).

@klutchell
Copy link
Collaborator Author

@ab77 how is docker able to forward traffic from a public interface to an address on the docker bridge using only iptables and routes? I was hoping we could solve it in a similar way, even if we hardcode a bunch of it initially.

@ab77
Copy link

ab77 commented Dec 18, 2023

@ab77 how is docker able to forward traffic from a public interface to an address on the docker bridge using only iptables and routes? I was hoping we could solve it in a similar way, even if we hardcode a bunch of it initially.

Using a tcp proxy. Using iptables dynamically is much more complicated, messy and we should avoid it.

@klutchell
Copy link
Collaborator Author

I ask because we already add and remove rules as part of the TAP device creation so it seemed like a logical place to add some additional port rules and remain part of the overlay vs a separate sidecar app.

@ab77
Copy link

ab77 commented Dec 19, 2023

I ask because we already add and remove rules as part of the TAP device creation so it seemed like a logical place to add some additional port rules and remain part of the overlay vs a separate sidecar app.

Let's create a builder deployment first with both containerised and VM builders (lets start with amd64), deploy to staging and figure out the approach there.

@ab77
Copy link

ab77 commented Feb 22, 2024

@klutchell
Copy link
Collaborator Author

klutchell commented Feb 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants