-
Notifications
You must be signed in to change notification settings - Fork 361
How to restage an app directly using V3 APIs (with examples)
Tim Downey edited this page Apr 30, 2019
·
1 revision
- Fetch the current droplet of the app to retrieve it's "current" package.
-
Endpoint:
GET /v3/apps/:guid/droplets/current
- Docs: Get Current Droplet
- Example:
$ cf curl /v3/apps/$(cf app my-app --guid)/droplets/current | jq .links.package.href
"https://api.neon-bite.capi.land/v3/packages/63f8c286-0df6-4837-86c8-544b594ab429"
-
Grab the package guid from the link. In the example above this would be:
63f8c286-0df6-4837-86c8-544b594ab429
-
Create a build (restage the package without affecting the app). This is functionally the same as
cf v3-stage
.
-
Endpoint:
POST /v3/builds
- Docs: Create a build
- Example:
$ cf curl -X POST /v3/builds -d '{ "package": { "guid": "63f8c286-0df6-4837-86c8-544b594ab429" } }'
{
"guid": "61b9dbea-a4da-479c-8873-31247cb1c1e6",
"created_at": "2019-04-30T18:07:06Z",
"updated_at": "2019-04-30T18:07:06Z",
"state": "STAGING",
"error": null,
"lifecycle": {
"type": "buildpack",
"data": {
"buildpacks": [],
"stack": "cflinuxfs3"
}
},
"package": {
"guid": "63f8c286-0df6-4837-86c8-544b594ab429"
},
"droplet": null,
"metadata": {
"labels": {},
"annotations": {}
},
"links": {
"self": {
"href": "https://api.neon-bite.capi.land/v3/builds/61b9dbea-a4da-479c-8873-31247cb1c1e6"
},
"app": {
"href": "https://api.neon-bite.capi.land/v3/apps/6efc923a-82fe-4ff2-82c2-d8ae65927c12"
}
},
"created_by": {
"guid": "dc72353e-3d76-4f7b-8de7-f582a5e6ab20",
"name": "admin",
"email": "admin"
}
}
- Poll the status of the build until it succeeds (or fails)
-
Endpoint:
GET /v3/builds/:guid
- Docs: Get a build
- Example:
$ cf curl /v3/builds/61b9dbea-a4da-479c-8873-31247cb1c1e6
{
"guid": "61b9dbea-a4da-479c-8873-31247cb1c1e6",
"created_at": "2019-04-30T18:07:06Z",
"updated_at": "2019-04-30T18:07:12Z",
"state": "STAGED",
"error": null,
"lifecycle": {
"type": "buildpack",
"data": {
"buildpacks": [
"staticfile_buildpack"
],
"stack": "cflinuxfs3"
}
},
"package": {
"guid": "63f8c286-0df6-4837-86c8-544b594ab429"
},
"droplet": {
"guid": "b6b19703-22f7-41a8-b31a-c351237530a0",
"href": "https://api.neon-bite.capi.land/v3/droplets/b6b19703-22f7-41a8-b31a-c351237530a0"
},
"metadata": {
"labels": {},
"annotations": {}
},
"links": {
"self": {
"href": "https://api.neon-bite.capi.land/v3/builds/61b9dbea-a4da-479c-8873-31247cb1c1e6"
},
"app": {
"href": "https://api.neon-bite.capi.land/v3/apps/6efc923a-82fe-4ff2-82c2-d8ae65927c12"
}
},
"created_by": {
"guid": "dc72353e-3d76-4f7b-8de7-f582a5e6ab20",
"name": "admin",
"email": "admin"
}
}
- Note the
state
field. If the state isSTAGED
Grab the droplet guid from the response.
$ cf curl /v3/builds/61b9dbea-a4da-479c-8873-31247cb1c1e6 | jq .droplet.guid
"b6b19703-22f7-41a8-b31a-c351237530a0"
- Update the app to use the new droplet guid (same as
cf v3-set-droplet
).
-
Endpoint:
PATCH /v3/apps/:guid/relationships/current_droplet
- Docs: Set current droplet
- Example:
$ cf curl -X PATCH /v3/apps/$(cf app my-app --guid)/relationships/current_droplet -d '{ "data": { "guid": "b6b19703-22f7-41a8-b31a-c351237530a0" } }'
{
"data": {
"guid": "b6b19703-22f7-41a8-b31a-c351237530a0"
},
"links": {
"self": {
"href": "https://api.neon-bite.capi.land/v3/apps/6efc923a-82fe-4ff2-82c2-d8ae65927c12/relationships/current_droplet"
},
"related": {
"href": "https://api.neon-bite.capi.land/v3/apps/6efc923a-82fe-4ff2-82c2-d8ae65927c12/droplets/current"
}
}
}
- Now restart the app to run it with this new droplet using
cf restart
orcf v3-zdt-restart
(on newer Cloud Foundry foundations that support the beta rolling app deployments feature).
-
Pipelines
-
Contributing
- Tips and Tricks
- Cloud Controller API v3 Style Guide
- Playbooks
- Development configuration
- Testing
-
Architectural Details
-
CC Resources
- Apps
- Audit Events
- Deployments
- Labels
- Services
- Sidecars
-
Dependencies
-
Troubleshooting
- Ruby Console Script to Find Fields that Cannot Be Decrypted
- Logging database queries in unit tests
- Inspecting blobstore cc resources and cc packages(webdav)
- How to Use USR1 Trap for Diagnostics
- How to Perf: Finding and Fixing Bottlenecks
- How to get access to mysql database
- How To Get a Ruby Heap Dumps & GC Stats from CC
- How to curl v4 internal endpoints with mtls
- How to access Bosh Director console and restore an outdated Cloud Config
- Analyzing Cloud Controller's NGINX logs using the toplogs script
-
k8s
-
Archive