basecamp / kamal

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

Request: Option to skip auto create kamal network #1033

Open aarroisi opened 1 day ago

aarroisi commented 1 day ago

I would like to request the ability to skip creating "kamal" network. In the docs, it is suggested that we pre-create the "kamal" network prior to deployment, but in my case it's not sufficient if you are trying to connect all the deployed apps to the same overlay, swarm network.

My use case is as follow:

HOWEVER, overlay swarm network in Docker that spans multiple servers has a condition in which a host is not yet connected to the network unless it has a running container connected to the network.

So, currently, what happened in my setup is as follow:

  1. I have a new node that I want to add as a deployment target
  2. I have previously created the network in the manager node, named "kamal"; overlay driver + swarm scope
  3. In the docker-setup hook, I connect the new node to the swarm as worker. Note: the new node is not automatically connected to the network since there is no running container that connected to the network. It's a new server after all.
  4. In one of the deployment steps, Kamal tries to create "kamal" network in the worker node. It will successfully create the new local bridge network named "kamal" (because at this point before auto creation of the network, the new node is not yet connected to the previously created overlay network, so no conflicting network name)
  5. Now there are two networks named kamal; one is the "correct" overlay network and the other is the local bridge network in the new node

With that new behavior in Kamal 2 (always tries to create new "kamal" network), I have 2 somewhat hacky solutions:

  1. Make all nodes act as manager node in the swarm. No worker nodes. This way, all nodes can manage the swarm network.
  2. Create a "dummy" service that make all the servers have a running container, making the "kamal" overlay network immediately discoverable

My ideal solution would be an ability to skip auto creation of "kamal" network.