2015-10-11 18:13:29 -07:00
2015-07-22 00:01:54 -07:00
2015-10-09 18:22:32 -07:00
2013-04-02 16:50:35 -07:00
2015-07-22 00:01:54 -07:00
2015-10-09 18:22:32 -07:00
2015-10-11 18:13:29 -07:00
2015-10-11 18:13:29 -07:00
2015-10-09 18:22:32 -07:00
2015-10-11 18:13:29 -07:00

PROBABLY NEEDS TO BE DOCKER IN DOCKER FOR IT TO WORK SMOOTHLY, MAYBE DROP THE DJ GO RUN THING AND DO IT NORMALLY.

MicroServices Gateway / API Gateway

First things first, register an app:

curl -H "Content-Type: application/json" -X POST -d '{"name":"myapp","password":"xyz"}' http://localhost:8080/test/1/projects/123/apps

Now add routes to the app. First we'll add a route to the output of a docker container:

curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello.rb","image":"treeder/hello.rb", "type":"run"}' http://localhost:8080/test/1/projects/123/apps/myapp/routes

Test out the route:

curl -i -X GET http://localhost:8080/hello.rb?app=myapp

Now try mapping an app endpoint:

curl -H "Content-Type: application/json" -X POST -d '{"path":"/sinatra","image":"treeder/hello-sinatra", "type":"app", "cpath":"/"}' http://localhost:8080/test/1/projects/123/apps/myapp/routes

And test it out:

curl -i -X GET http://localhost:8080/sinatra?app=myapp

Building/Testing

dj go build
docker run --rm -it --privileged --net=host -v "$PWD":/app -v $HOME:/root:ro -w /app -p 8080:8080 treeder/go-dind sh -c 'rc default && ./app'

Then run the commands above to use it.

Previous version:

What's going on?

  • worker.rb connects to router and adds routes.
  • client.rb connects to router which checks the routing table, proxies the request to one of the destinations and returns the response.

The idea here is that IronWorker backend can tell the router that it started a process and to start routing requests.

Usage

iron worker upload --name hello-sinatra --host YOURHOST treeder/hello-sinatra

Then hit the url:

http://router.iron.io/?rhost=YOURHOST

Todo

This is just a simple prototype. To get to production would need:

  • Ability to start new workers based on some auto scaling scheme.
  • Authentication (same as always).

Testing for reals on staging

1) Deploy router

Using DockerJockey:

dj run --on aws -i --name router -v "$(pwd)":/app -w /app -p 80:8080 treeder/golang-ubuntu:1.3.3on14.04 ./router

2) Update DNS

Update DNS entry router.iron.io to point to the newly launched server after dj deploy.

Or SimpleDeployer:

Deploying to production

  • just deploy as normal from SD project
  • use routertest.irondns.info for host
Description
The container native, cloud agnostic serverless platform.
Readme Apache-2.0 170 MiB
Languages
Go 97.4%
Shell 1.2%
Ruby 0.5%
Makefile 0.4%
Dockerfile 0.4%
Other 0.1%