Cloud Foundry
From Zero To Hero

03 How do I CF push my first app?

This content is copyright of CloudCredo. © CloudCredo 2015. All rights reserved.

Feature

As a CF hero
I want my app to be accessible at a public URL
So that the whole world can see it

How do I push my app into CF?

# From the training home directory:
$ cd 03-first-app/web-app
$ cf push

...

urls: web-app-unpassionate-eighteen.cfapps.io

...

What apps are in the CF space?

$ cf apps

name      state     instances   memory   disk   urls
web-app   started   1/1         32M      256M   web-app-unpass...

I want to see more app info

$ cf app web-app

requested state: started
instances: 1/1
usage: 32M x 1 instances
urls: web-app-unpassionate-eighteen.cfapps.io
last uploaded: Mon Nov 2 10:18:05 UTC 2015
stack: cflinuxfs2
buildpack: ruby 1.6.7

     state     since        cpu    memory         disk
#0   running   2015-11-02   0.0%   25.7M of 32M   95.1M of 256M

Where did the app name & quotas come from?

$ cat 03-first-app/web/manifest.yml

name: web-app
memory: 32M
disk_quota: 256M
random-route: true
buildpack: ruby_buildpack

What are the
default app quotas?

  • Memory: 1G
  • Disk: 1G

What does random route do?

cfapps.io is shared by all run.pivotal.io apps

$ cf app web-app

...

urls: web-app-unpassionate-eighteen.cfapps.io

...

Where does the app run?

                           CONSUMER

                              |

                            ROUTER

                            /    \
                           /      \
                          /        \
                         /          \

                      HOST 1       HOST 2

                        |            |
      APP A INSTANCE 1 -|            |- APP A INSTANCE 2
      APP B INSTANCE 2 -|            |- APP B INSTANCE 1

What happens when I cf push?

  1. App files sent to CF
  2. Runnable app artefact is created (droplet)
  3. App starts on an app host

App receives web requests (if it binds to TCP port)

1. App files sent to CF

By the cf cli, no other dependency required

Define in .cfignore files that should not be sent

2. Runnable app artefact

App Files + Runtime Dependencies = App Artefact

3. App starts on an app host

If it’s a web process, it binds to a TCP port

App receives web requests

Randomly distributed across multiple app instances

How do I push a worker app?

# From the training home directory:
$ cd 03-first-app/worker-app
$ cf push
$ cf app worker-app

requested state: started
instances: 1/1
usage: 16M x 1 instances
urls:
last uploaded: Mon Nov 2 13:56:39 UTC 2015
stack: cflinuxfs2
buildpack: binary_buildpack

     state     since        cpu    memory         disk
#0   running   2015-11-02   0.0%   10.7M of 16M   27.3M of 64M

How can I check what this worker app does?

$ cf logs worker-app --recent

...
2015... [App/0] ERR + main
2015... [App/0] ERR + find_my_public_ip
2015... [App/0] ERR + which curl
2015... [App/0] ERR + curl -sL https://api.ipify.org?format=json
2015... [App/0] OUT {"ip":"54.236.219.204"}
2015... [App/0] ERR + suspend_myself
2015... [App/0] ERR + kill -STOP 11

DELIVERED

As a CF hero
I want my app to be accessible at a public URL
So that the whole world can see it

Make room for better apps

$ cf delete worker-app
$ cf delete -f -r web-app

Any questions?

Questions cannot be stupid. Answers can.

CF SUPERHERO

This content is copyright of CloudCredo. © CloudCredo 2015. All rights reserved.