How to delete a Stack and associated Buildpacks
search cancel

How to delete a Stack and associated Buildpacks

book

Article ID: 297441

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

Pivotal Cloud Foundry (PCF) provides stacks which contain the OS layer dependencies that are available to your app.  Over time some of these stacks may become obsolete and an Operator may wish to remove them from the Foundation as well as any buildpacks that are associated with it.

Resolution

List Stacks and Associated Buildpacks

The cf cli provides options for listing Stacks and Buildpacks on the Foundation.
 

➜ cf stacks
Getting stacks as admin...

name            description
cflinuxfs3      Cloud Foundry Linux-based filesystem - Ubuntu Bionic 18.04 LTS
windows2012R2   Microsoft Windows / .Net 64 bit
windows2016     Microsoft Windows 2016
windows         Windows Server

 

➜ cf buildpacks
Getting buildpacks as admin...

position   name                     stack         enabled   locked   filename
1          hwc_buildpack            windows       true      false    hwc_buildpack-cached-windows-v3.1.24.zip
2          hwc_buildpack            windows2016   true      false    hwc_buildpack-cached-windows2016-v3.1.24.zip
3          staticfile_buildpack     cflinuxfs3    true      false    staticfile_buildpack-cached-cflinuxfs3-v1.5.30.zip
4          java_buildpack_offline   cflinuxfs3    true      false    java-buildpack-offline-cflinuxfs3-v4.49.zip
5          ruby_buildpack           cflinuxfs3    true      false    ruby_buildpack-cached-cflinuxfs3-v1.8.54.zip
6          nginx_buildpack          cflinuxfs3    true      false    nginx_buildpack-cached-cflinuxfs3-v1.1.38.zip
7          nodejs_buildpack         cflinuxfs3    true      false    nodejs_buildpack-cached-cflinuxfs3-v1.7.70.zip
8          go_buildpack             cflinuxfs3    true      false    go_buildpack-cached-cflinuxfs3-v1.9.46.zip
9          r_buildpack              cflinuxfs3    true      false    r_buildpack-cached-cflinuxfs3-v1.1.29.zip
10         python_buildpack         cflinuxfs3    true      false    python_buildpack-cached-cflinuxfs3-v1.7.54.zip
11         php_buildpack            cflinuxfs3    true      false    php_buildpack-cached-cflinuxfs3-v4.4.62.zip
12         dotnet_core_buildpack    cflinuxfs3    true      false    dotnet-core_buildpack-cached-cflinuxfs3-v2.3.42.zip
13         binary_buildpack         cflinuxfs3    true      false    binary_buildpack-cached-cflinuxfs3-v1.0.45.zip
14         binary_buildpack         windows2016   true      false    binary_buildpack-cached-windows2016-v1.0.45.zip
15         binary_buildpack         windows       true      false    binary_buildpack-cached-windows-v1.0.45.zip



Delete Stacks and Associated Buildpacks

The cf cli provides an option for deleting Buildpacks associated with a Stack.

➜ cf delete-buildpack binary_buildpack -s windows2016
Really delete the buildpack binary_buildpack? [yN]: y
Deleting buildpack binary_buildpack with stack windows2016...
OK


The cf cli does not provide an option for deleting Stacks but the Cloud Foundry V3 API  does.

➜ cf stack windows2016 --guid
7548cebf-4c91-4704-bb9b-1eb20bee4460

➜ cf curl /v3/stacks/7548cebf-4c91-4704-bb9b-1eb20bee4460 -X DELETE


Using these examples an Operator can delete all of the buildpacks associated with an obsolete Stack followed by deleting the Stack itself.