-
Notifications
You must be signed in to change notification settings - Fork 364
How to Create an App Using V3 of the CC API
- Find the GUID of your space and set an APP_NAME:
CF_API_ENDPOINT=$(cf api | grep "API endpoint" | awk '{print $3}')
SPACE_GUID=$(cf space `cf target | tail -n 1 | awk '{print $2}'` --guid)
APP_NAME=[your-app-name]
- Create an empty app (docs):
Here is the most common way:
APP_GUID=$(cf curl /v3/apps -X POST -d "{\"name\": \"${APP_NAME}\", \"relationships\": {\"space\": {\"data\": {\"guid\": \"${SPACE_GUID}\"}}}}" | tee /dev/tty | jq -r .guid)
- Create an empty package for the app (docs):
PACKAGE_GUID=$(cf curl /v3/packages -X POST -d "{\"type\":\"bits\", \"relationships\": {\"app\": {\"data\": {\"guid\": \"$APP_GUID\"}}}}" | tee /dev/tty | jq -r .guid)
Note: Other package types are also supported. See documentation for Create a Package.
- If your package is type buildpack, create a ZIP file of your application:
zip -r my-app.zip *
Note: The zip file should not have a folder as the top-level item (e.g. create the zip file from within your app’s directory)
- If your package is type buildpack, upload your bits to your new package (docs):
curl $CF_API_ENDPOINT/v3/packages/$PACKAGE_GUID/upload -F bits=@"my-app.zip" -H "Authorization: $(cf oauth-token | grep bearer)"
- Stage your package and create a build (docs):
BUILD_GUID=$(cf curl /v3/builds -X POST -d '{ "package" : { "guid" : "'$PACKAGE_GUID'" } }' | tee /dev/tty | jq -r .guid)
Note: The output of this command includes your new build's GUID
- Wait for the state of the new build to reach
STAGED
:
watch cf curl /v3/builds/$BUILD_GUID
- Get the droplet corresponding to the staged build:
DROPLET_GUID=$(cf curl /v3/builds/$BUILD_GUID | jq -r '.droplet.guid')
- Assign the droplet to the app:
cf curl /v3/apps/$APP_GUID/relationships/current_droplet -X PATCH -d '{"data": {"guid": "'$DROPLET_GUID'"}}'
- Create a route:
CF_TRACE=true cf create-route [space-name] [domain-name] -n [host-name]
ROUTE_GUID=[copy route's GUID under metadata->guid of the last response]
- Map the route to your app (docs):
cf curl /v3/route_mappings -X POST -d '{"relationships": {"route": {"guid": "'$ROUTE_GUID'"}, "app": {"guid": "'$APP_GUID'"} } }'
- Start your app (docs):
cf curl /v3/apps/$APP_GUID/start -X PUT
- Visit your app at the new route to confirm that it is up
-
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