basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
11.44k stars 457 forks source link

Allow overriding custom `kamal` network #1006

Closed luizkowalski closed 1 week ago

luizkowalski commented 1 month ago

hey πŸ‘‹πŸ»

I'm running a couple of accessories that require host network mode and since v2, Kamnal forces the usage of custom kamal network.

Is there any chance to make this option configurable? These containers do not run behind a proxy anyway so there's no need for them to be discoverable

mblayman commented 1 month ago

According to the upgrade guide, the recommendation for customizing the network is to use the docker-setup hook. https://kamal-deploy.org/docs/upgrading/network-changes/

luizkowalski commented 1 month ago

then I would need to create a network called β€œkamal” with host access, which is far from ideal. i dont want all containers with host access, nor have to deal with port mapping because some containers port clash and host network exposes it all

igor-alexandrov commented 1 month ago

@djmb I can add a configuration option to change the network if you are okay with this.

djmb commented 1 month ago

then I would need to create a network called β€œkamal” with host access, which is far from ideal. i dont want all containers with host access, nor have to deal with port mapping because some containers port clash and host network exposes it all

I don't think this would work - it would put the app and proxy containers in a host network as well, and then the proxy won't be able to access the app container by its container ID.

@igor-alexandrov - yes please if you have a chance to add this πŸ‘

We'd add something like network: <name> I guess and then you can set it to network: host?

accessories:
  redis:
    image: redis:latest
    port: 6379
    network: host
honzasterba commented 1 month ago

you can have your accessories on multiple networks, for example for a Typesense cluster, static IPs are required. I solved this by adding:

accessories:
  typesense:
    options:
      network: name=my-custom-net,ip=my-custom-ip

this way the accessory is on the kamal network as well on my-custom-net

luizkowalski commented 4 weeks ago

host network can't be mixed with bridge network for example

madmax commented 1 week ago

I have the same problem - node_explorer for monitoring server require network host.

When setup accessory

  node_explorer: 
    image: quay.io/prometheus/node-exporter:latest
    host: <SERVER.IP> 
    cmd: "--path.rootfs=/host --collector.systemd --collector.processes"
    directories:
      - /:/host:ro,rslave
    options: 
      net: "host"
      pid: "host"

It will not work because kamal force to use own network

docker stderr: docker: conflicting options: cannot attach both user-defined and non-user-defined network-modes.
honzasterba commented 1 week ago

1) I dont think you want to manage monitoring/ops stuff with kamal, kamal should be used for stuff thats application related, use different tools to manage obsevability and other tasks (like ansible) 2) are you absolutely sure that node-explorer needs to run on host network?