The easiest way to update your stack is to do a `cf push
`. You can set the `cf push -s <stack>
` flag or set `stack: <stack>
` in your application.yml
file and it will set a specific stack for your application to use.
For example: `cf push -s cflinuxfs3 my-cool-app
`
The push executes, updates the stack being used, re-stages your application using the new stack, and when the app starts, it will be running on the new stack.
Note: Please keep in mind that doing a `cf push
` can result in downtime for your app. The app is stopped before it is restaged. The period of time between your app staging and starting will be downtime. It is recommended that you do a blue/green deploy if you need to avoid downtime for your application.
There is a cf CLI plugin called Stack Auditor which can be used to:
This is an excellent option if you do not want to perform a `cf push
` for reasons such as:
Instructions for installing the plugin can be found here. Basic usage instructions for the plugin can be found here.
To list apps and their stacks, execute the following cf command:
$ cf audit-stack Retrieving stack information for all apps... cf-support/aarif/FTServiceCore cflinuxfs2 cf-support/aarif/anser-app-02 cflinuxfs2 cf-support/aarif/anser-php-app-03 cflinuxfs2 cf-support/aarif/directory-service-anser cflinuxfs2 ...
To switch an app's stack, execute the following cf command:
$ cf change-stack nginxappy cflinuxfs3 Attempting to change stack to cflinuxfs3 for acceptance/nginxappy/... Restarting nginxappy with down time... Restoring prior application state: STARTED Application nginxappy was successfully changed to Stack cflinuxfs3
Please keep in mind that running `cf change-stack
` will re-stage your app.
As mentioned above, this can cause downtime. The change-stack command runs two logical steps.
Please perform a blue/green deployment instead of using `cf change-stack
` if downtime is unacceptable for your application.
The change-stack command also supports a --v3 flag
. The --v3 flag
will make use of the CAPI zero downtime endpoints, resulting in a true zero-downtime migration.
Note: This flag is only applicable for PWS or Open Source installations of Cloud Foundry. This should not be used with PAS versions 2.3 or 2.4, as it will lead to unexpected behavior.
$cf change-stack nginxappy cflinuxfs3 --v3 Attempting to change stack to cflinuxfs3 for acceptance/nginxappy/... Restarting nginxappy with zero down time... Restoring prior application state: STARTED Application nginxappy was successfully changed to Stack cflinuxfs3
cf audit-stack
` shows all the apps in all the orgs and spaces where you have visibility, including those already running `cflinuxfs3
` or even Windows stacks. To find all of the apps that need to be migrated from a specific stack, like `cflinuxfs2
` run `c
f audit-stack | grep 'cflinuxfs2'
`.cf audit-stack | grep -e '^<org-name>
'`, where `<org-name>
` is the desired org name.cf audit-stack | awk -F '[/ ]' '{ print $3 }
'. If you'd like other information, you can use $1 which is the org, $2 which is the space, $3 which is the app and $4 which is the stack.cflinuxfs2
` apps in an specific org (remember this will incur downtime for each app):
cf audit-stack | grep 'cflinuxfs2' | grep -e '^<org-name>' | awk -F '[/ ]' '{ print "cf t -o \""$1"\" -s \""$2"\"\ncf change-stack "$3" cflinuxfs3" }' > update-stack.shTo actually make the change, run the script: `
bash update-stack
.
sh
`.