Cloud Foundry
From Zero To Hero

08 How do I use custom domains?

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

Cloud Foundry Hero Badge

Outstanding Cloud Foundry Knowledge

Feature

As a CF hero
I want my app to be accessible at my domain
So that everyone can see my Cloud Foundry Hero Badge

How do I use custom domains?

$ cf create-domain cf-hero-YOUR-NAME YOUR-NAME.cf-hero.cloudcredo.io
# From the training home directory:
$ cd 08-domains-routes/cf-hero
# Uncomment domain & replace YOUR-NAME
$ vim manifest.yml
$ cf push

I want multiple routes
pointing to the same app

$ cf map-route cf-hero gerhard.cf-hero.cloudcredo.io -n www
$ cf apps

name     ..  urls
cf-hero  ..  gerhard.cf-hero.cloudcredo.io, www.gerhard.cloudcredo..

I also want multiple domains
pointing to the same app

$ cf domains

name                            status
cfapps.io                       shared
gerhard.cf-hero.cloudcredo.io   owned
$ cf map-route cf-hero cfapps.io -n gerhard-cf-hero
$ cf routes

space         host              domain                          apps
development                     gerhard.cf-hero.cloudcredo.io   ...
development   www               gerhard.cf-hero.cloudcredo.io   ...
development   gerhard-cf-hero   cfapps.io                       ...

What about multiple
domains & routes?

$ cat imaginary-manifest.yml

name: cf-hero
domains:
  - cloudcredo.io
  - cloudcredo.com
hosts:
  - gerhard
  - gerhard-lazu
$ cf routes

space          host            domain            apps
development    gerhard         cloudcredo.io     cf-hero
development    gerhard-lazu    cloudcredo.io     cf-hero
development    gerhard         cloudcredo.com    cf-hero
development    gerhard-lazu    cloudcredo.com    cf-hero

Experiment with app versions

$ cf push -f manifest-superhero.yml

And when it did its job…

$ cf delete -f -r cf-superhero

When you find
the best app version

# From the training home directory:
$ cd 08-domains-routes/cf-hero-static
# Replace YOUR-NAME
$ vim public/index.html
# Uncomment domain & replace YOUR-NAME
$ vim manifest.yml
$ cf push
$ cf app cf-hero-static

     state     since        cpu    memory        disk
#0   running   2015-11-02   0.0%   6.8M of 16M   33.6M of 64M
...
#3   running   2015-11-02   0.0%   6.7M of 16M   33.5M of 64M
$ cf delete -f cf-hero

Accidental blue/green deploy

You are now a
Cloud Foundry Hero


DELIVERED

As a CF hero
I want my app to be accessible at my domain
So that everyone can see my Cloud Foundry Hero Badge

Any questions?

Questions cannot be stupid. Answers can.

CF SUPERHERO

  • Set up a custom SSL certificate
  • Use feature flags instead of ENV vars
  • Delete all routes that are no longer used

    $ cf delete-orphaned-routes
    

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