compose: Switch to host-mode port publishing by default #88
Reference in New Issue
Block a user
No description provided.
Delete Branch "mirsal/traefik:host-mode-port-publishing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
By default, swarm services use ingress mode port publishing, which is
not ideal for traefik (it breaks IPv6 ingress and there is no need to
load-balance traffic between multiple traefik instances or to route it
from multiple swarm nodes)
This PR switches traefik's port publishing mode to
hostfor all ofits exposed ports as well as:
containers exposing the same port when using host-mode publishing)
endpoint_mode: dnsrrinstead of the defaultvipcompose.host.yml, leaving the file emptyfor backwards compatibility
/!\ This is a breaking change
Closes: #52
looks good to me, but maybe we should also add a
compose.no-host.ymlthat overwritesendpoint-modetovipand themodeof theports 80/443 toingressor do you think we don't need that? :)I had Traefik deployed with compose.host.yml and compose.nextcloud-talk-hpb.yml. Upgrading to this PR worked mostly ok, except for Nextcloud Talk ports:
From the nextcloud readme:
I had previously run
docker service update --publish-add published=3478,target=3478,protocol=udp traefik_XXX_XXX_appAfter upgrading to this PR,
docker service inspect traefik_XXX_XXX_app | grep 3478 -a2no longer showed the UDP binding (I believe this also happens when redeploying the current version, so nothing new), but I couldn't add the UDP port binding again; it didn't work.I noticed
docker service inspect traefik_XXX_XXX_appstill showed a vip mode under EndpointSpec with ingress mode for 3478. I guess this manual --publish-add was still hanging somewhere and removed it:docker service update --publish-rm 3478/udp traefik_XXX_XXX_appAnd then I could add the UDP port again by specifying host mode:
docker service update --publish-add published=3478,target=3478,protocol=udp,mode=host traefik_XXX_XXX_appLGTM! tysm @mirsal ❤️🔥
Testers welcome! Great stuff @dannygroenewegen!
Thanks a lot for testing this, since this will hit us as soon as we make the changes as well.
this bug is so bad and i think we can't do much about it, since currently compose is still broken when handling the port merging :'D @p4u1 and i thought about forking the compose library, to get it under control. Not sure if we ever made the PR to the upstream library? (or was there one and it's just not getting merged?)
I intentionally left that part out originally because I am not sure that the publish mode would merge properly into existing port definitions.
Additionally, there's a big gotcha because setting the endpoint_mode to vip bars from using any of the compose overrides which add published ports to the traefik service.
I'm adding compose.no-host.yml as a separate commit, so that we can decide whether to include it or not (if we do, then I'll squash them)
See:
41ce894cc1Thanks a lot for testing this!
I am not sure about what to do about that bug, maybe documenting the issue in the release notes is enough?
afaict,
compose.mumble.ymlis also affectedThe nextcloud talk bug will be fixed with toolshed/abra#741
WIP: compose: Switch to host-mode port publishing by defaultto compose: Switch to host-mode port publishing by defaultI already thought you had a reason for that, but wanted to make sure :D
i don't really understand what you mean by that, since this worked as of right now or didn't it? To be honest, i still have a bit of a hard time to fully wrap my head around the different concepts in swarm networking.
We don't inevitably need to add the no-host override yml from my pov, i just thought this might leave the door open for the few cases someone maybe needs it and we don't know yet, but i'm fine to go without it :)
Basically, if someone uses:
then port 2222 will still be published in host mode, which would make the switch to ingress-mode pointless because our override files (compose.gitea.yml in this case) use host-mode port publishing anyway.
That's the reason why I added the big fat warning in
.envand didn't switchupdate_configback tostart-firstincompose.no-host.yml(unfortunately, there are other gun-foots when mixing ingress and host mode port publishing)I think having it is ok, it's just a bit confusing.
It's fine as long as users don't expect it to work intuitively with overrides.
🥇
@mirsal thanks for the amazing work 🙏 Could you add a release note in
release/next?41ce894cc1toce1c863b3aDone, along with squashing this PR's commits into one :)