Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

emerald-squad/cf-blue-green-resource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATION WARNING

This resource has been replaced with cf-zero-downtime-resource.

Development have ceased on this resource and pull requests will not be merged in.

We recommend everyone to switch to cf-zero-downtime-resource.

The switch is very easy. It only requires you to remove the hostname parameters and replace it with the routes.route attribute in the manifest.yml.

why?

This resource has several limitations and problems that needed to be addressed:

  • App name constantly change between app-name-blue and app-name-green. This makes it hard to know which is the active at any given time. One must check the route of the application to know which one is active.
  • Because of the route renaming and external health check script, this resource needs to deploy the application twice (Eureka and SSO services don't know how to handle route changes once an app is deployed).
  • Only one route is supported. We had pull request to support multiple routes, but there is no robust solutions to do it. We believe that the manifest.yml file should be the sole truth for how the application is deployed and configured.
  • This resource does not support deploying Docker Images.

We carefully considered modifying this resource, but choose to create a new one. Resolving the mentioned issues meant a major rewrite and we already have hundredth of pipelines that use it. Many using the latest tag. The risk of breaking thing was too high. Also, the name zero-downtime is better suited for how it behave than blue-green.

Cloud Foundry Blue Green Deploy Resource

An output only resource that will deploy an application to Cloud Foundry using blue-green pattern.

This resource focuses a robust deployment of the application. The current crop of zero-downtime cf CLI plugins fails when applications are bound to CF services such as Service Registry (Eureka) and Identity Service (UAA).

Source Configuration

  • api : Required. The adress of Cloud Foundry Cloud Controller.
  • username : Required. The username used to authenticate.
  • password : Required. The password used to authenticate.
  • organization : Required. The organization to push the application to.
  • space : Required. The space to push the application to.
  • skip_cert_check : Optional. Check the validity of the CF SSL cert. Defaults to false.

out. Deploy application to Cloud Foundry

The application is pushed to Cloud Foundry using the blue-green deployment pattern.

The application is always pushed with the app name suffixed by either -blueor -green. The active application always have the name route. The process first determine which of blue or green is currently active and then deploy the new application using the other suffix. The application is deployed once using the suffixed route and the health check script is run. The script receives the APP (application name), HOSTNAME (application base hostname), NEXT (blue or green) and DOMAIN (application domain) as environment variables. The hostname for healthchecking the new application is ${HOSTNAME}-${NEXT}.${DOMAIN}. If the script exit with an error level, it the new application will be stopped and left in that state. If the script exit with 0. The new application will be deleted and pushed again with the normal route. At this time, both the new and current appications will receive requests. The current application route is unmapped and the it is stopped.

Parameters

  • name : Required. The name of the application. This is also used for the always available route to the app.
  • manifest : Required. The application manifest.
  • path : Required. Path to the application to deploy.

Example

resource_types: 

- name: cf-blue-green-resource
  type: docker-image
  source:
    repository: emeraldsquad/cf-blue-green-resource

resources:
- name: pcf
  type: cf-blue-green-resource
  source:
    api: {{pcf-api}}
    username: {{pcf-user}}
    password: ((pcf-passwd))
    organization: {{pcf-org}}
    space: {{pcf-space}}

jobs:
  - name: blue-green-deploy
    serial: true
    public: false
    plan:
    - get: myapp
    - put: pcf
      params:
        name: myapp
        manifest: myapp/ci/manifest.yml
        path: myapp/annuaire-service-*.jar
        hostname: myapp