rburgst / rancherci-presentation

The instruction repository containing the conference slides and instructions on how to setup a jenkins CI environment on a Rancher Server cluster
2 stars 1 forks source link

Trouble running the scripts #1

Open benzht opened 7 years ago

benzht commented 7 years ago

Hello Rainer, thanks your great presentation at the Spring I/O 2017 in Barcelona last week and making everything available so fast!

Now I am trying to run your setup following the readme and I am running into some difficulties. Some of them I have already fixed/updated in my fork. If you like, I can open a pull-request later when everything works.

With me, the registry-gui consistently refuses to show the registry content. The progress-bar gets stuck and the browser console in both Chrome and Firefox (on Mac) report JSON parse error and undefined variables (see below). Because this is not really essential to the script, I have just moved on.

Step 5 worked OK and delivered the expected command that I've added to step 6:

docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher-server:5000/rancher/agent:v1.2.2 http://rancher-server.shared:8080/v1/scripts/4329A188616B610F184E:1483142400000:WwVEuv4YyIkNnPLQvRaveJ2tuTI

Next thing that fails is registering the rancher agent:

./06-start-rancher-agent.sh

INFO: Running Agent Registration Process, CATTLE_URL=http://rancher-server.shared:8080/v1
INFO: Attempting to connect to: http://rancher-server.shared:8080/v1
ERROR: http://rancher-server.shared:8080/v1 is not accessible
ERROR: http://rancher-server.shared:8080/v1 is not accessible

When I ssh into the agent and 'curl http://rancher-server.shared:8080/v1' I get a long JSON string as reply - so it is accessible. And here I seem to be stuck.

Can you spot what is going wrong here?

Thanks in advance Hartmut

Crome/Firefox console errors when Browsing registry:

Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
S@http://rancher-server:9000/scripts/vendor.254c89c2.js:3:27842
transformResponse@http://rancher-server:9000/scripts/scripts.055f0e39.js:1:12553
ib@http://rancher-server:9000/scripts/vendor.254c89c2.js:4:30655
e@http://rancher-server:9000/scripts/vendor.254c89c2.js:4:31273
i@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:17452
j/<@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:17624
$eval@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:25012
$digest@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:23517
$apply@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:25281
f@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:875
r@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:2736
nb/</v.onload@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:3276
  vendor.254c89c2.js:5:11943
Error: a.config is undefined
responseError@http://rancher-server:9000/scripts/vendor.254c89c2.js:12:29646
i@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:17452
j/<@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:17624
$eval@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:25012
$digest@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:23517
$apply@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:25281
f@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:875
r@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:2736
nb/</v.onload@http://rancher-server:9000/scripts/vendor.254c89c2.js:5:3276
rburgst commented 7 years ago

Hmm, which VM engine are you using? I am using parallels and it does some nice things that eases networking (it automatically generates hosts entries, etc.). Please try to see whether you can reach

http://rancher-server:8080 from a container WITHIN the agent. (e.g. run it within busybox). I have the feeling that the host resolution within docker containers doesnt extend to the rancher-server host.

benzht commented 7 years ago

Sorry, I forgot to mention the technical details: macOs 10.12.5, VirtualBox 5.1.22, docker 17.03.1-ce-mac12, docker-machine 0.10.0, docker-compose 1.11.2

I had already noticed that the hosts were not added to the /etc/hosts files as you suggest (and I've added respective text to the readme in my fork). The rancher server was happily answering on rancher-server(.shared):8080 from within the agent (see also original post). But something I notice now is that my additions modifications of /etc/hosts are lost after rebooting the VMs. Perhaps some processes do not see my manual changes? Here /etc/hosts from the agent. The server has the identical two lines attached to the file.

docker@rancher-agent-01:~$ cat /etc/hosts
127.0.0.1 rancher-agent-01 localhost localhost.local

# The following lines are desirable for IPv6 capable hosts
# (added automatically by netbase upgrade)

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
192.168.99.101  rancher-server.shared rancher-server
192.168.99.100  rancher-agent-01.shared rancher-agent-01
rburgst commented 7 years ago

I dont see any entries for the server in the agent hosts file. Please try and start a busybox container on the agent and see whether it can connect to the rancher server. My guess is that it might not even see it. Parallels does some magic with the resolve.conf file which ensures that the server is visible from containers within the agent machine. My gut feeling is that VirtualBox doesn't do that. benzht notifications@github.com schrieb am So. 28. Mai 2017 um 10:47:

Sorry, I forgot to mention the technical details: macOs 10.12.5, VirtualBox 5.1.22, docker 17.03.1-ce-mac12, docker-machine 0.10.0, docker-compose 1.11.2

I had already noticed that the hosts were not added to the /etc/hosts files as you suggest (and I've added respective text to the readme in my fork). The rancher server was happily answering on rancher-server(.shared):8080 from within the agent (see also original post). But something I notice now is that my additions modifications of /etc/hosts are lost after rebooting the VMs. Perhaps some processes do not see my manual changes? Here /etc/hosts from the agent. The server has the identical two lines attached to the file.

docker@rancher-agent-01:~$ cat /etc/hosts 127.0.0.1 rancher-agent-01 localhost localhost.local

The following lines are desirable for IPv6 capable hosts

(added automatically by netbase upgrade)

::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts 192.168.99.101 rancher-server.shared rancher-server 192.168.99.100 rancher-agent-01.shared rancher-agent-01

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/rburgst/rancherci-presentation/issues/1#issuecomment-304501170, or mute the thread https://github.com/notifications/unsubscribe-auth/AABZux-_WpqY24QJEWMPj1ukpn5KGq7Dks5r-TSpgaJpZM4NnbO5 .

rburgst commented 7 years ago

This might also help. https://docs.docker.com/engine/userguide/networking/get-started-overlay/#overlay-networking-with-an-external-key-value-store

Unfortunately I don't have a VirtualBox setup since I don't have good past experiences mixing different VM providers

benzht commented 7 years ago

You are right. The docker containers within the boot2docker VMs do not automatically get the /etc/hosts entries of the boot2docker VM. On top, the repository-gui VM is using ENV_DOCKER_REGISTRY_HOST: "rancher-server", which resolves to a 172.xxxx docker IP address and for reasons so far unknown the registry does not answer on that port.

Networking with boot2docker and VirtualBox seems to be a bit of a headache. So I guess I will first try my luck with 'real' machines in the cloud. Maybe some VirtualBox/docker wizard come across this issue and can help.

rburgst commented 7 years ago

You can change the "external rancher address" when adding the new agent in the rancher ui. Add the iP address of your rancher-server host (the one that you added to /etc/hosts) then you won't need to rely on dns or hosts entries). In the end this should only affect the internal url that the agent container uses in order to access the rancher server. Once rancher is up and running it shout take care about networks etc.