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

Avoid auto switching agent to cluster mode #341

Open
smartnexus opened this issue Jun 21, 2022 · 7 comments
Open

Avoid auto switching agent to cluster mode #341

smartnexus opened this issue Jun 21, 2022 · 7 comments

Comments

@smartnexus
Copy link

I have a Swarm cluster for some network reasons, but I deploy containers in a specific node each time (depending on some requirements). So I want to launch my agent running on Docker standalone but it detects node is part of Swarm cluster, and switches to cluster mode, failing start.

2022/06/21 08:01:56 [INFO] [main] [message: Agent running on Docker platform]
2022/06/21 08:01:56 [DEBUG] [main] [Member tags: &{AgentPort:9001 EdgeKeySet:false NodeName:mars DockerConfiguration:{EngineStatus:2 Leader:false NodeRole:2} KubernetesConfiguration:{}}]
2022/06/21 08:01:56 [INFO] [main] [message: Agent running on a Swarm cluster node. Running in cluster mode]
2022/06/21 08:01:56 [DEBUG] [docker] [network_name: bridge] [scope: local] [ingress: false] [message: Skipping invalid container network]
2022/06/21 08:01:56 [WARN] [main] [message: Unable to retrieve agent container IP address, using '0.0.0.0' instead] [error: unable to retrieve the address on which the agent can advertise. Check your network settings]
2022/06/21 08:01:59 [ERROR] [main] [host: tasks.] [message: Unable to retrieve a list of IP associated to the host] [error: lookup tasks. on 172.16.0.2:53: no such host]

This is the cmd I am using:
docker run -it --rm -p 9001:9001 --name portainer_agent -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -e LOG_LEVEL=DEBUG portainer/agent:2.13.1

I think it will be nice to have an environment variable to disable auto swtiching.

@smartnexus
Copy link
Author

The key would be to add another condition to the if statement checking options var

if runtimeConfiguration.DockerConfiguration.EngineStatus == agent.EngineStatusSwarm {

@jamescarppe
Copy link
Member

For Portainer to work across a Swarm cluster, even when deploying containers to specific swarm nodes, the agent needs to be running on all the nodes in the cluster. Without it, functionality would be severely limited.

@smartnexus
Copy link
Author

With this the agent is going to be running in all swarm nodes, but not as a swarm cluster, just a bunch of nodes that are accesible by L3. When the agent runs in swarm mode, deploy is done by "docker stack deploy" and sometimes makes sense to use "docker compose" in just one node

@madpeteguy
Copy link

madpeteguy commented Oct 20, 2022

Hey, i have just ran into simmilar problem, and i love proposed solution.

My docker nodes are separate instances, mostly running container in macvlans.
They are joined in swarm only for prometheus monitoring, no more services use swarm.
I would like portainer agents to ignore swarm mode and act like on single docker. Swarm is only to provide an overlay network for monitoring, nodes are hosting dedicated services, as they are required to work separately, even if all other nodes are not reachable.

At last, they are managed separately even when connected as swarm.

@IlDordollano
Copy link

I have the same issue. It would be nice to have this feature implemented.

@Chuckame
Copy link

Chuckame commented Aug 2, 2024

Same issue. Would be great to have an env var to disable auto switch

@MikeFez
Copy link

MikeFez commented Aug 23, 2024

I would love this as well. I have a docker swarm set up specifically for the easy routing of a few items behind my reverse proxy. Portainer agents are not one of those items, and I'd very much love for them to run standalone specifically to be able to monitor the containers of the machine without the entire swarm network being displayed.

Basically, I'm hoping to clean up the portainer interface by having each of my machines (some of which are nodes in a swarm, but only for certain items) only display a list of the services they're running, rather than the entirety of the cluster.

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

6 participants