7. [23:08] jacopen@cape ~/Project/dora ✘╹◡╹✘ (master) cf push dora
Creating app dora in org jacopen / space jacopen-space as admin...
OK
Creating route dora.107.22.72.200.xip.io...
OK
Binding dora.107.22.72.200.xip.io to dora...
OK
Uploading dora...
Uploading from: /Users/jacopen/Project/dora
1.2M, 36 files
OK
Starting app dora in org jacopen / space jacopen-space as admin...
OK
(中略)
1 of 1 instances running
App started
Showing health and status for app dora in org jacopen / space jacopen-space as admin...
OK
requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: dora.107.22.72.200.xip.io
state since cpu memory disk
#0 running 2014-04-21 11:09:25 PM 0.0% 72.2M of 256M 0 of 1G
8. ok
[23:09] jacopen@cape ~/Project/dora ✘╹◡╹✘ (master) cf apps
Getting apps in org jacopen / space jacopen-space as admin...
OK
name requested state instances memory disk urls
dora started 1/1 256M 1G dora.107.22.72.200.xip.io
12. Agenda
3 chapters to understand mechanism of Cloud Foundry
• Inspect Cloud Foundry internal from external interface
• Understand role of Cloud Foundry components
• Understand communications between Cloud Foundry
components
13. Not included this time
• Explanation of Warden container and Buildpack
• Explanation of services such as MySQL or
Postgress.
• Explanation of related services such as
loggregator
19. GET /v2/spaces/dbf6ed0a-3108-45d8-9c78-a512d5071358/apps?q=name%3Adora&inline-relations-depth=1 HTTP/1.1
HTTP/1.1 200 OK
POST /v2/apps?async=true HTTP/1.1
{"name":"dora","space_guid":"dbf6ed0a-3108-45d8-9c78-a512d5071358"}
HTTP/1.1 201 Created
GET /v2/shared_domains HTTP/1.1
HTTP/1.1 200 OK
GET /v2/domains?inline-relations-depth=1&q=name%3A107.22.72.200.xip.io HTTP/1.1
HTTP/1.1 200 OK
GET /v2/routes?inline-relations-depth=1&q=host%3Adora%3Bdomain_guid%3A524ba14d-4d3f-495f-a2c7-a5ed25a70e81 HTTP/1.1
HTTP/1.1 200 OK
POST /v2/routes?async=true&inline-relations-depth=1 HTTP/1.1
{"host":"dora","domain_guid":"524ba14d-4d3f-495f-a2c7-a5ed25a70e81","space_guid":"dbf6ed0a-3108-45d8-9c78-a512d5071358"}
HTTP/1.1 201 Created
PUT /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/routes/ed912294-be29-4013-8b1c-735851acee24 HTTP/1.1
HTTP/1.1 201 Created
PUT /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/bits?async=true HTTP/1.1
Content-Type: multipart/form-data;
HTTP/1.1 201 Created
GET /v2/jobs/6dd46fe7-40b0-41d1-94aa-dd2ee80fd3b2 HTTP/1.1
HTTP/1.1 200 OK
(queued)
GET /v2/jobs/6dd46fe7-40b0-41d1-94aa-dd2ee80fd3b2 HTTP/1.1
HTTP/1.1 200 OK
(finished)
CONNECTING TO WEBSOCKET: wss://loggregator.107.22.72.200.xip.io:443/tail/?app=0e948568-aa90-47e9-a128-9ff3cc680600
PUT /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600?async=true&inline-relations-depth=1 HTTP/1.1
{"state":"STARTED"}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 400 Bad Request
{"code":170002,"description":"App has not finished staging","error_code":"CF-NotStaged"}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 400 Bad Request
{"code":170002,"description":"App has not finished staging","error_code":"CF-NotStaged"}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 200 OK
{"0":{"state":"RUNNING","since":1398092703.1739626,"debug_ip":null,"debug_port":null,"console_ip":null,"console_port":null}}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/stats HTTP/1.1
HTTP/1.1 200 OK
{"0":{"state":"RUNNING","stats":{"name":"dora","uris":["dora.107.22.72.200.xip.io"],"host":"10.244.0.26","port":61026,"uptime":3,"mem_quota":268435456,"disk_quota":1073741824,"fds_quota":16384,"usage"
:{"time":"2014-04-21 15:05:04 +0000","cpu":0,"mem":75673600,"disk":0}}}}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 200 OK
{"0":{"state":"RUNNING","since":1398092703.1739626,"debug_ip":null,"debug_port":null,"console_ip":null,"console_port":null}}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/stats HTTP/1.1
HTTP/1.1 200 OK
{"0":{"state":"RUNNING","stats":{"name":"dora","uris":["dora.107.22.72.200.xip.io"],"host":"10.244.0.26","port":61026,"uptime":4,"mem_quota":268435456,"disk_quota":1073741824,"fds_quota":16384,"usage"
:{"time":"2014-04-21 15:05:05 +0000","cpu":0,"mem":75673600,"disk":0}}}}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/summary HTTP/1.1
HTTP/1.1 200 OK
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 200 OK
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/stats HTTP/1.1
HTTP/1.1 200 OK
Communicating something to
api.107.22.72.200.xip.io
27. $ nslookup api.107.22.72.200.xip.io
Server: 192.168.11.1
Address: 192.168.11.1#53
Non-authoritative answer:
api.107.22.72.200.xip.io canonical name = api.1jkk1uz.xip.io.
Name: api.1jkk1uz.xip.io
Address: 107.22.72.200
$ nslookup dora.107.22.72.200.xip.io
Server: 192.168.11.1
Address: 192.168.11.1#53
Non-authoritative answer:
dora.107.22.72.200.xip.io canonical name = dora.1jkk1uz.xip.io.
Name: dora.1jkk1uz.xip.io
Address: 107.22.72.200
IP addresses are same for both API and App
28. cf push
Something to dispatch access
based on URL
Somethingtodispatchaccess
Browser
Something which runs
application
Something which provides
API
29. cf scale
$ cf scale -i 3 -m 256M dora
Scaling app dora in org jacopen / space jacopen-space as admin...
OK
cf scale command changes “number of active
instances” and/or “memory size”.
46. Router
Based on URL, dispatches access to appropriate
component. Similar to L7 load balancer.
This is different from “router” in network equipment.
It is implemented as an application (called Gorouter)
which runs on Ubuntu. Written in Go.
49. Cloud Controller
Router
DEA
Health
Manager
router.register
Multiple targets are handled for the same
URL
dora.107.22.72.200.xip.io => 10.244.0.26:61032
dora.107.22.72.200.xip.io => 10.244.0.27:58719
api.107.22.72.200.xip.io => 10.244.0.138:9022
api.107.22.72.200.xip.io => 10.244.0.139:9022
api.107.22.72.200.xip.io
dora.107.22.72.200.xip.io
Cloud Controller
DEA
51. Cloud Controller
A component to provide API.
Receive application from cf command, etc.
Control application start/stop against DEA.
Control creation of service such as database.
Etc, etc. Control overall Cloud Foundry.
52. POST /v2/apps?async=true HTTP/1.1
{"name":"dora","space_guid":"dbf6ed0a-3108-45d8-9c78-a512d5071358"}
HTTP/1.1 201 Created
GET /v2/shared_domains HTTP/1.1
HTTP/1.1 200 OK
GET /v2/domains?inline-relations-depth=1&q=name%3A107.22.72.200.xip.io HTTP/1.1
HTTP/1.1 200 OK
GET /v2/routes?inline-relations-depth=1&q=host%3Adora%3Bdomain_guid%3A524ba14d-4d3f-495f-a2c7-a5ed25a70e81 HTTP/1.1
HTTP/1.1 200 OK
POST /v2/routes?async=true&inline-relations-depth=1 HTTP/1.1
{"host":"dora","domain_guid":"524ba14d-4d3f-495f-a2c7-a5ed25a70e81","space_guid":"dbf6ed0a-3108-45d8-9c78-a512d5071358"}
HTTP/1.1 201 Created
PUT /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/routes/ed912294-be29-4013-8b1c-735851acee24 HTTP/1.1
HTTP/1.1 201 Created
PUT /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/bits?async=true HTTP/1.1
Content-Type: multipart/form-data;
HTTP/1.1 201 Created
GET /v2/jobs/6dd46fe7-40b0-41d1-94aa-dd2ee80fd3b2 HTTP/1.1
HTTP/1.1 200 OK
(queued)
GET /v2/jobs/6dd46fe7-40b0-41d1-94aa-dd2ee80fd3b2 HTTP/1.1
HTTP/1.1 200 OK
(finished)
CONNECTING TO WEBSOCKET: wss://loggregator.107.22.72.200.xip.io:443/tail/?app=0e948568-aa90-47e9-a128-9ff3cc680600
PUT /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600?async=true&inline-relations-depth=1 HTTP/1.1
{"state":"STARTED"}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 400 Bad Request
{"code":170002,"description":"App has not finished staging","error_code":"CF-NotStaged"}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 400 Bad Request
{"code":170002,"description":"App has not finished staging","error_code":"CF-NotStaged"}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 200 OK
{"0":{"state":"RUNNING","since":1398092703.1739626,"debug_ip":null,"debug_port":null,"console_ip":null,"console_port":null}}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/stats HTTP/1.1
HTTP/1.1 200 OK
{"0":{"state":"RUNNING","stats":{"name":"dora","uris":["dora.107.22.72.200.xip.io"],"host":"10.244.0.26","port":61026,"uptime":3,"mem_quota":268435456,"disk_quota":1073741824,"fds_quota":16384,"usage":{"time":"2014-
04-21 15:05:04 +0000","cpu":0,"mem":75673600,"disk":0}}}}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 200 OK
{"0":{"state":"RUNNING","since":1398092703.1739626,"debug_ip":null,"debug_port":null,"console_ip":null,"console_port":null}}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/stats HTTP/1.1
HTTP/1.1 200 OK
{"0":{"state":"RUNNING","stats":{"name":"dora","uris":["dora.107.22.72.200.xip.io"],"host":"10.244.0.26","port":61026,"uptime":4,"mem_quota":268435456,"disk_quota":1073741824,"fds_quota":16384,"usage":{"time":"2014-
04-21 15:05:05 +0000","cpu":0,"mem":75673600,"disk":0}}}}
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/summary HTTP/1.1
HTTP/1.1 200 OK
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/instances HTTP/1.1
HTTP/1.1 200 OK
GET /v2/apps/0e948568-aa90-47e9-a128-9ff3cc680600/stats HTTP/1.1
HTTP/1.1 200 OK
⇐ Create app
⇐ Obtain domain
⇐verify routes
⇐create routes
⇐ bind app and routes
⇐upload source files
⇐start app
54. DEA
A component to run user’s application.
Abbreviation of “Droplet Execution Agent"
In CF V2, it is responsible for user application staging (e.g.
Ruby bundle install).
DEA uses Linux container called Warden to run user
application. (Warden is not described this time)
55. Receive source files from client
Cloud Controller
Router
DEA
Health
Manager
cf push
Gemfile
lib/
bin/
config.ru
app.rb
79. NATS
Publish-Subscribe model lightweight messaging
Developed by Derek Collison designed and architected
the industry's first Open PaaS, Cloud Foundry
Exists at the beginning of Cloud Foundry. Key component
in the architecture.
It was implemented in Ruby using EventMachine. It is re-
written using Go language (dnatsd)
83. All subscriber receive the same message
NATS
Cloud
Controller
DEA
Router
Subject: router.register
{“host":"10.244.0.138","port":
9022,"uris":["api.107.22.72.2
00.xip.io"]}
Subject: router.register
{“host":"10.244.0.111","port":
37902,"uris":["dora.107.22.7
2.200.xip.io"]}
Router
Router
Publisher Subscriber
84. When there is no NATS component…
NATS
Direct Communication
1.Run Router
2.Router subscribe
router.register
1.Register new Router in
admin DB
2.Run Router
3.DEA or Cloud Controler
obtain Router list from
admin DB
4.Sead message to each
Router
86. Cloud Foundry Architecture
• Centered around NATS, loosely coupled
component communications. Scalable.
• Self-organized distributed system. Administrative
information is minimal.
• Self healing. The point is that it heals by itself.
• Removes SPoF( Single Point of Failure). Except
recent NATS.
88. Difference between CF v1 and v2
Overall architecture has not been changed.
DEA became DEAng, and runs Linux container called
Warden
Many components were re-written in Go.
Can use Heroku Buildpack
There is no API compatibility !