apache / openwhisk

Apache OpenWhisk is an open source serverless cloud platform
https://openwhisk.apache.org/
Apache License 2.0
6.54k stars 1.17k forks source link

cannot call openwhisk from outside world #692

Closed lfzCarlosC closed 8 years ago

lfzCarlosC commented 8 years ago

After setting up vagrant image and couch db. Then it works fine when invoke action (echo) inside Vagrant image. But I cannot find a way to operate(crud operation) action,rule,trigger from outside world.The reason is that fowwing the guide https://github.com/openwhisk/openwhisk/blob/master/docs/reference.md, I cannot tell what $BASEURL$ should be.I have tried following command on my laptop(host machine) but it does not work:

curl -X GET https://127.0.0.1:10001/api/v1/namespaces/ Failed to connect to 127.0.0.1 port 10001: Connection refused:--

But inside Vagrant image env ,it works fine. I know there is a port forward method which could expose image intra port to host and you can call from outside. But this relates to another issue.If I forward a port to host for openwhisk(I think crud operation is through controller port), I need to execute vagrant reload to make the port map working.But after image reloads, openwhisk will not work(like wsk action list returns "connection refused"). So,what is the right way to operate action , rule,trigger outside?

rabbah commented 8 years ago

Use your Vagrant machine IP instead which is 192.168.33.13 by default (check your Vagrant file). Also see https://github.com/openwhisk/openwhisk/tree/master/tools/vagrant/custom#using-cli-from-outside-the-vm-optional.

lfzCarlosC commented 8 years ago

there are 2 ip , IP address for eth0: 10.0.2.15 IP address for docker0: 172.17.0.1 which one?

lehoanganh commented 8 years ago

they are the IPs inside your vagrant. You have to use the IPs in your local dev env.

houshengbo commented 8 years ago

The easiest way to cope with situation is to add private network into your vagrantfile. You can either configure it as a static IP or DHCP: https://www.vagrantup.com/docs/networking/private_network.html.

To make it easier, I used to add config.vm.network "private_network", ip: "192.168.50.4" into the vagrantfile. Then you can access your vagrant via 192.168.50.4.

lfzCarlosC commented 8 years ago

@houshengbo you mean you set this before creating vagrant vm or you set it and then vagrant reload

@rabbah I check simple Vagrantfile and there is no 192.168.33.13 configuration.I add MACHINE_IP = ENV['MACHINE_IP'] || '192.168.33.13' to the script and then "vagrant up" to create new Vagrant image. Then execute vagrant ssh -- ip route get 8.8.8.8 | awk '{print $NF; exit}' and it returns 10.0.2.15 . I ping 192.168.33.13 and terminal shows no connection info.

lfzCarlosC commented 8 years ago

---from host machine--- $ wsk property set --apihost 10.0.2.15 --namespace guest --auth 23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP ok: whisk auth set ok: whisk API host set ok: namespace set to guest

$ wsk property get whisk API host 10.0.2.15 whisk API version v1 whisk namespace guest whisk CLI version 2016-06-18T00:37:38Z whisk API build 2016-06-18T00:34:26Z whisk API buildno latest

$ wsk action invoke /whisk.system/samples/echo -p message hello --blocking --result { "message": "hello" }

$ curl -u vagrant:vagrant https://10.0.2.15/api/v1/namespaces/whisk.system/packages curl: (28) Connection timed out after 300091 milliseconds

Another question is, given 10.0.2.15 is a intra address that host machine can only communicate with, how does other machines in the LAN(these machines are setup with host machine in the same LAN) call the Vagrant openwhisk service? I know using vagrant sharing is a good idea.But I do not know which port inside vagrant I should map in order to visit REST API or wsk command , like http://$VagrantShareURL/api/v1/namespaces can be called.

I have bind port 443 with shared url by running: config.vm.network :forwarded_port, guest: 443, host:443 before vagrant up

and

vagrant share -http 443

and visit http://curious-wildcat-6554.vagrantshare.com

Then, it returns 400 The plain HTTP request was sent to HTTPS port

lfzCarlosC commented 8 years ago

I tried using public ip of host machine, it worked.