Cloud foundry - How to retrieve version of artifac

2019-09-20 17:21发布

问题:

In PCF platform, We have multiple Orgs and multiple Spaces within each Org.

Each space has multiple apps deployed with manifest file mentioning the artifact version. For example: If you push an app(some-api) is deployed with below manifest file that has artifact version(0.0.1).

---
applications:
- name: some-api
  instances: 1
  memory: 1G
  buildpack: java_buildpack_offline
  path: target/artifact.jar
  routes:
  - route: some.router.com
  services:
  - abc
  - def
  env:
    ARTIFACT_VERSION: 0.0.1

Goal is to have a dashboard of app to artifact version across Orgs. App that is in Running state


1) As artifact version is stored as environment variable of an app, amidst push of an app, across Orgs/spaces, Is it possible to retrieve artifact version of each app?

2) If no, what is the better approach to store artifact version of every app running in PCF? in order to retrieve the artifact version of any app in Running state across Orgs/spaces

3) To show the list of app's artifact versions in browser dashboard. Does PCF platform provide any tool(like firehouse) to provide a dashboard of metrics available in PCF?

回答1:

You can build custom app with requested functionality (dashboard with all running apps and ARTIFACT_VERSION value) which will use Cloud Foundry API.

There is also CLI version cf env (doc) for quick checking in CLI.

Update:

Apparently, you want to use event stream and not regular pulling of the app env state. In that case use Firehouse and watch for Staging Complete events, which will trigger getEnvValue(ARTIFACT_VERSION) action for the app with that Staging Complete event.