rancher: Rancher agent not connecting to Rancher server on same host with "Custom" Add Host
I am running Rancher server in the provided container on DigitalOcean (exposing 8080) and the admin seems to work fine. My firewall rules seems reasonable:
$ sudo ufw status
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
80/tcp ALLOW Anywhere
2376/tcp ALLOW Anywhere
3376/tcp ALLOW Anywhere
500/udp ALLOW Anywhere
4500/udp ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
2376/tcp (v6) ALLOW Anywhere (v6)
3376/tcp (v6) ALLOW Anywhere (v6)
500/udp (v6) ALLOW Anywhere (v6)
4500/udp (v6) ALLOW Anywhere (v6)
But when I want to add the same host, as an agent, it hangs on attempting to connect to the master.
I click through the admin interface for “custom”, and it tells me to do:
$ docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock rancher/agent:v0.7.11 http://<ip>:8080/v1/scripts/328B791E15E99D370F1D:1438639200000:8aQ7dtSOvfPpOLb1OzuWIMsOKoQ
When I run that locally, I get logs in the container like:
INFO: Running Agent Registration Process, CATTLE_URL=<ip>:8080/v1
INFO: Checking for Docker version >= 1.6.0
INFO: Found Server version: 1.7.1
INFO: docker version: Client version: 1.6.0
INFO: docker version: Client API version: 1.18
INFO: docker version: Go version (client): go1.4.2
INFO: docker version: Git commit (client): 4749651
INFO: docker version: OS/Arch (client): linux/amd64
INFO: docker version: Server version: 1.7.1
INFO: docker version: Server API version: 1.19
INFO: docker version: Go version (server): go1.4.2
INFO: docker version: Git commit (server): 786b29d
INFO: docker version: OS/Arch (server): linux/amd64
INFO: docker info: Containers: 6
INFO: docker info: Images: 46
INFO: docker info: Storage Driver: aufs
INFO: docker info: Root Dir: /var/lib/docker/aufs
INFO: docker info: Backing Filesystem: extfs
INFO: docker info: Dirs: 58
INFO: docker info: Dirperm1 Supported: false
INFO: docker info: Execution Driver: native-0.2
INFO: docker info: Kernel Version: 3.13.0-57-generic
INFO: docker info: Operating System: Ubuntu 14.04.2 LTS
INFO: docker info: CPUs: 2
INFO: docker info: Total Memory: 1.955 GiB
INFO: docker info: Name: beefydrop
INFO: docker info: ID: AG5H:ECGI:PIYD:HJO4:S7FY:WBPC:YWSB:YJ2H:FGO2:6A5I:7TGR:IHXE
INFO: docker info: Http Proxy:
INFO: docker info: Https Proxy:
INFO: docker info: No Proxy:
WARNING: No swap limit support
INFO: docker info: Labels:
INFO: docker info: provider=digitalocean
INFO: Attempting to connect to: http://<ip>:8080/v1
WARNING: No swap limit support
ERROR: http://<ip>:8080/v1 is not accessible
I managed to add another host fine. What’s going on? Other issues (https://github.com/rancher/rancher/issues/872) suggested -e CATTLE_AGENT_IP=<ip>, but that didn’t work for me.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 20
I’ve fixed! The problem is with my certificate. In the server logs, these messages where being displayed every second:
After correcting the certificate issue, restarting the server, go to UI, adding a host again and re-run the agent with this command, the issue was fixed:
Please reopen this case.
I’ve created a new EC2 instance using this ami ID on AWS EC2: rancheros-v0.4.2-hvm-0 (ami-53045239). After the instance is reachable through ssh, I’ve setup the rancher server container on it using this command:
After the rancher server’s container is running, I’ve installed a nginx container for proxy requests on HTTPs/443 to 8080 of rancher server’s container:
With these two containers running, I was able to connect to https://ranchermgmt.mydomain.com using SSL/443 with my own certificate using any browser.
Very well, now I want to add this EC2 instance as a host to the rancher server container that is running inside it. For doing it, I’ve first enabled a local authentication on rancher server, by using it’s web ui. After that, I’ve did the procedure described here: http://docs.rancher.com/rancher/rancher-ui/infrastructure/hosts/custom/#adding-hosts-to-the-same-machine-as-rancher-server, but the procedure not works.
These are my host interfaces:
These are the security groups that my EC2 instance is associated:
I’ve tried to create many containers with many CATTLE_AGENT_IPs, but all of them reports this error:
These are the commands that I’ve executed to create the containers:
Even using the latest rancher agent image, the agent not works
I can’t resolve this issue by using ufw because rancheros 0.4.2 doesn’t have ufw instaled. But, even using iptables directly, I think it isn’t necessary because iptables INPUT Chain in openned by default:
I need a solution for this if possible…
Ok, I reproduced and adding
ufw allow 8080/tcpto the firewall rules fixed the problem.The questionable thing was why were you able to get to the UI/API via the browser. Long story short, the iptables rule that was created when you did
docker run ip 8080:8080 ...was allowing external traffic in, but not internal traffic. Internal traffic was being blocked by ufw.