Code Monkey home page Code Monkey logo

cf-bg-demo's Introduction

cf-bg-demo

Demonstrate Blue-Green Deployments on Cloud Foundry with this simple (one Groovy file, one HTML file) Spring Boot CLI application!

Running Locally

$ spring run app.groovy

Running on Cloud Foundry

The application requires the latest version of the Java Buildpack, so we’ll use that from GitHub. Cloud Foundry requires unique URLs, so use the '-n' flag to define a unique HOSTNAME and add a short alphanumeric suffix.

$ $ cf push cf-scale-boot -m 512M -b https://github.com/cloudfoundry/java-buildpack -n cf-scale-boot-a123z

Doing a Blue-Green Demo

This application leverages the colors blue and green to demonstrate the dynamic routing and load balancing capabilities of Cloud Foundry in a Blue-Green Deployment Scenario.

Steps:

  1. Push the application as-is, with blue appended to the application name. Use '-n' to define a unique HOSTNAME:

    $ cf push cf-bg-demo-blue -m 512M -b https://github.com/cloudfoundry/java-buildpack -n cf-bg-demo-blue-a123z
  2. Map a ``zero downtime'' route to the application and use '-n' to define a unique HOSTNAME:

    cf map-route cf-bg-demo-blue cfapps.io -n cf-bg-demo-a123z

    Visit your application in the browser using your zero downtime route to see that it is working.

  3. Modify app.groovy to use the color green (line 8):

    model['color'] = 'green'
  4. Push the modified application, with green appended to the application name and again use '-n' to define a unique HOSTNAME:

    $ cf push cf-bg-demo-green -m 512M -b https://github.com/cloudfoundry/java-buildpack -n cf-bg-demo-green-a123z
  5. Map the ``zero downtime'' route to the modified application, including the HOSTNAME suffix you added in Step 2:

    cf map-route cf-bg-demo-green cfapps.io -n cf-bg-demo-a123z

    Visit your application in the browser using your zero downtime route to see that the platform is load balancing between the two instances.

  6. Un-map the ``zero downtime'' route from the original application, including the HOSTNAME suffix you added in Step 2:

    cf unmap-route cf-bg-demo-blue cfapps.io -n cf-bg-demo-a123z

    Visit your application in the browser using your zero downtime route to see that only the modified application is now in play.

What you get:

screenshot

cf-bg-demo's People

Contributors

cholick avatar scottfrederick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cf-bg-demo's Issues

No need to use thymeleaf

... for such a simple project the built in Groovy templating would be fine. You could scrap the @Grab completely, and just do this in your controller:

@RestController
class WebApplication {

    @RequestMapping('/')
    String home(Map<String,Object> model) {     
        model['color'] = 'blue'
        template 'index.html', model
    }
}

(template is an auto-import of a static convenience method to render a Groovy template, using the stock template engine. Variables are resolved using ${} placeholders and erb-style <% %> script escapes.)

See here for an example: https://github.com/spring-io/initializr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.