This is a Concourse resource for doing zero downtime deploys to Cloudfoundry. Previously this worked in conjunction with the halfpipe-cf-plugin. Now this project contains all behaviour. This resource also allows you to deploy docker-images to cf and to use the experimental rolling deploy feature of cf api version 7.
You can use the docker image by defining the resource type in your pipeline YAML.
For example:
resource_types:
- name: cf-resource
type: docker-image
source:
repository: platformengineering/cf-resource
tag: stable
api
: required. The CF API you wish to deploy to.org
: required. The Org the app should be deployed in.space
: required. The Space the app should be deployed into.username
: required. The username for the user to use when deploying.password
: required. The password for the user to use when deploying.
resources:
- name: cf-resource
type: cf-resource
source:
api: ((cloudfoundry.api-dev))
org: my-org
space: my-space
username: ((cloudfoundry.username))
password: ((cloudfoundry.password))
Does nothing
Does nothing
Deploys app to cf
command
: required. The halfpipe-cf-plugin command to use. Must be one ofhalfpipe-push
,halfpipe-check
,halfpipe-promote
orhalfpipe-cleanup
.manifestPath
: required. Relative or absolute path to cf manifest.appPath
: required for halfpipe-push. Relative or absolute path to the app bits you wish to deploy.testDomain
: required for halfpipe-push and halfpipe-promte. Domain that will be used when constructing the candidate route for the app.vars
: optional. Hash map containing environment variables that should be set on the application.gitRefPath
: optional. Path to the.git/ref
file. If this is set the app will get the environment variableGIT_REVISION
set.timeout
: optional. Timeout for each of the commands that the halfpipe cf plugin will execute.preStartCommand
: optional. A CF command to run immediately beforecf start
in thehalfpipe-push
command. e.g.cf events <app-name>
.dockerUsername
: optional. The username to use when pushing a docker image to cf.dockerPassword
: optional. The password to use when pushing a docker image to cf.dockerTag
: optional. The dockertag to set or override the dockertag set in the cf manifest.buildVersionPath
: optional. path to the versionfile. If this is set the app will get the environment variableBUILD_VERSION
set.instances
: optional. The number of instances to deploy when using the rolling deploy strategy.
jobs:
- name: deploy-to-dev
plan:
- get: my-apps-git-repo
- put: cf-resource
params:
appPath: my-apps-git-repo/target/distribution/artifact.zip
command: halfpipe-push
manifestPath: my-apps-git-repo/manifest.yml
testDomain: some.random.domain.com
gitRefPath: my-apps-git-repo/.git/ref
vars:
EXTRA_VAR: "Yo, im a env var in the CF app"
SECRET_VAR: ((some.secret))
- put: cf-resource
params:
command: halfpipe-promote
manifestPath: my-apps-git-repo/manifest.yml
testDomain: some.random.domain.com
timeout: 10m
- put: cf-resource
params:
command: halfpipe-delete
manifestPath: my-apps-git-repo/manifest.yml
This resource supports the use of the rolling strategy introduced in cf api v3. One of the benefits of this strategy is that the amount of resources needed to deploy is significantly less.
To still make use of the candidate-app to do smoke tests against, simply first use halfpipe-push
command.
After that you can do a rolling deploy with halfpipe-rolling-deploy
.
To cleanup the test app created by halfpipe-push
use halfpipe-delete-test
.
jobs:
- name: deploy-to-dev
plan:
- get: my-apps-git-repo
- put: cf-resource
params:
appPath: my-apps-git-repo/target/distribution/artifact.zip
command: halfpipe-push
manifestPath: my-apps-git-repo/manifest.yml
testDomain: some.random.domain.com
gitRefPath: my-apps-git-repo/.git/ref
vars:
EXTRA_VAR: "Yo, im a env var in the CF app"
SECRET_VAR: ((some.secret))
- put: cf-resource
params:
put: cf rolling deploy
manifestPath: my-apps-git-repo/manifest.yml
timeout: 10m
- put: remove test app
resource: rolling cf snpaas halfpipe-examples
params:
command: halfpipe-delete-test
manifestPath: my-apps-git-repo/manifest.yml
timeout: 1h
attempts: 2
This simply deploys the application as app-name-CANDIDATE
to a test route app-name-{SPACE}-CANDIDATE.{DOMAIN}
Checks that all instances of the app is up and running, useful to stick between halfpipe-push
and halfpipe-promote
- This binds all the routes from the manifest to the
app-name-CANDIDATE
- Removes the test route from
app-name-CANDIDATE
- renames
app-name-OLD
toapp-name-DELETE
- renames
app-name
toapp-name-OLD
- renames
app-name-CANDIDATE
toapp-name
- stops
app-name-OLD
Simply deletes the app app-name-DELETE
This command pushes an app with the rolling strategy. This command also supports the rolling deployment of docker images in cf.
Use in conjunction with halfpipe-rolling-deploy
to delete any test-app pushed with halfpipe-push