forked from cloudfoundry/docs-cf-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack-auditor.html.md.erb
170 lines (128 loc) · 5.76 KB
/
stack-auditor.html.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
---
title: Using the Stack Auditor Plugin
owner: Buildpacks
---
This topic describes how to use the Stack Auditor plugin for the Cloud Foundry Command Line Interface (cf CLI).
## <a id="overview"></a> Overview
Stack Auditor is a cf CLI plugin that provides commands for listing apps and their stacks, migrating apps to a new stack, and deleting a stack.
One use case for Stack Auditor is when you must migrate a large number of apps to a new stack. This includes moving from `cflinuxfs2` to `cflinuxfs3` in preparation to upgrade your deployment to a version that does not contain `cflinuxfs3`. The following table describes the workflow you can use:
<table>
<tr>
<th>Stage</th>
<th>Description</th>
</tr>
<tr>
<td>1</td>
<td>Operator audits stack usage to determine which apps need to be migrated. See <a href="#list-stacks">List Apps and Their Stacks</a>.</td>
</tr>
<tr>
<td>2</td>
<td>Operator communicates with developers that they must migrate their existing apps to a new stack and begin pushing all new apps to the a new stack.</td>
</tr>
<tr>
<td>3</td>
<td>Developers migrate their apps to a new stack. See <a href="#change-stacks">Change Stacks</a>.</td>
</tr>
<tr>
<td>4</td>
<td>Operator confirms apps have been migrated.</td>
</tr>
<tr>
<td>5</td>
<td>Operator deletes buildpacks associated with the old stack.</td>
</tr>
<tr>
<td>6</td>
<td>Operator deletes the old stack. See <a href="#delete-stacks">Delete a Stack</a>.
<p class="note"><strong>Note</strong>: If you upgrade your deployment to a version that contains the stack you deleted, the stack returns on upgrade.</p></td>
</tr>
<tr>
<td>7</td>
<td>If applicable, operator upgrades the deployment to the version that does not contain the old stack.</td>
</tr>
</table>
## <a id="install"></a> Install Stack Auditor
To install Stack Auditor, do the following:
1. <%= vars.get_auditor_binary %>
1. Unzip the binary file you downloaded:
```
tar xvzf PATH-TO-BINARY
```
1. Install the plugin with the cf CLI:
```
cf install-plugin PATH-TO-BINARY
```
## <a id="use"></a> Use Stack Auditor
The sections below describe how to use Stack Auditor.
### <a id="list-stacks"></a> List Apps and Their Stacks
This section describes how to see the apps in each org and space and what stack they are using.
1. To see which apps are using which stack, run the following command. It lists apps for each org you have access to. To see all the apps in your deployment, ensure that you are logged in to the cf CLI as a user who can access all orgs.
```
cf audit-stack
```
See the following example output:
<pre class="terminal">
$ cf audit-stack
first-org/development/first-app cflinuxfs2
first-org/staging/first-app cflinuxfs2
first-org/production/first-app cflinuxfs2
second-org/development/second-app cflinuxfs3
second-org/staging/second-app cflinuxfs3
second-org/production/second-app cflinuxfs3
...
</pre>
### <a id="change-stacks"></a> Change Stacks
This section describes how to change the stack that an app uses. Stack Auditor rebuilds the app onto the new stack without a change in the source code of the app. If you want to move the app to a new stack with updated source code, follow the procedure in the [Changing Stacks](../devguide/deploy-apps/stacks.html) topic.
<p class="note warning"><strong>WARNING</strong>: Stack Auditor rebuilds the app, which causes downtime. To avoid downtime, use a blue-green deployment strategy. See <a href="../devguide/deploy-apps/blue-green.html">Using Blue-Green Deployment to Reduce Downtime and Risk</a>.</p>
To change the stack an app uses, do the following:
1. Target the org and space of the app:
```
cf target ORG SPACE
```
Where:
* `ORG` is the org the app is in
* `SPACE` is the space the app is in
1. Run the following command:
<p class="note"><strong>Note</strong>: If the app is in a <code>stopped</code> state, it remains stopped after changing stacks.</p>
```
cf change-stack APP-NAME STACK-NAME
```
Where:
* `APP-NAME` is the app that you want to move to a new stack
* `STACK-NAME` is the stack you want to move the app to
See the following example output:
<pre class="terminal">
$ cf change-stack my-app cflinuxfs3
Attempting to change stack to cflinuxfs3 for my-app...
Starting app my-app in org pivotal-pubtools / space pivotalcf-staging as [email protected]...
Downloading staticfile_buildpack...
. . .
requested state: started
instances: 1/1
usage: 64M x 1 instance
urls: example.com
last uploaded: Thu Mar 28 17:44:46 UTC 2019
stack: cflinuxfs3
buildpack: staticfile_buildpack
state since cpu memory disk details
#0 running 2019-04-02 03:18:57 PM 0.0% 8.2M of 64M 6.9M of 1G
Application my-app was successfully changed to Stack cflinuxfs3
</pre>
### <a id="delete-stacks"></a> Delete a Stack
This section describes how to delete a stack from your deployment. You must be an admin user to complete this step.
1. To delete a stack, run the following command. This action cannot be undone, with the following exception: If you upgrade your deployment to a version that contains the stack you deleted, the stack returns on upgrade.
```
cf delete-stack STACK-NAME
```
Where `STACK-NAME` is the name of the stack you want to delete.
<pre class="terminal">
$ cf delete-stack cflinuxfs2
Are you sure you want to remove the cflinuxfs2 stack? If so, type the name of the stack [cflinuxfs2]
>cflinuxfs2
Deleting stack cflinuxfs2...
Stack cflinuxfs2 has been deleted.
</pre>
If you have any apps still running on `cflinuxfs2`, the command returns the following error:
<pre class="terminal">
Failed to delete stack cflinuxfs2 with error: Please delete the app associations for your stack.
</pre>