Skip to content

homedepot/cloud-runner

Repository files navigation

cloud-runner

Cloud Runner is a simple microservice that builds and runs a gcloud run deploy command against a given GCP project ID. For flag support please visit the wiki.

Development

Environment Variables

Name Description Required Notes
API_KEY Validated for Create/Delete operations ✔️
SQL_HOST SQL host If not set will default to local sqlite DB
SQL_NAME SQL database name If not set will default to local sqlite DB
SQL_PASS SQL password If not set will default to local sqlite DB
SQL_USER SQL username If not set will default to local sqlite DB

Build

make build

Test

make test

Run Locally

The following will show you how to run Cloud Runner locally and onboard your first account! Running locally will by default create a SQLite DB named cloud-runner.db in the current directory.

  1. Run cloud-runner
$ export API_KEY=test
$ make run
  1. Create an account. Cloud Runner connects to Spinnaker's fiat (at http://spin-fiat.spinnaker:7003) when deploying to GCP to verify the current user has read and write access to the account. The user is defined in the X-Spinnaker-User request header. When onboarding an account into Cloud Runner make sure to define the read and write groups correctly! If no account field is provided one will be generated in the format cr-<GCP_PROJECT_ID>.
$ curl -H "API-Key: test" localhost:80/v1/credentials -d '{
  "account": "test-account-name",
  "projectID": "test-project-id",
  "readGroups": [
    "test-group"
  ],
  "writeGroups": [
    "test-group"
  ]
}' | jq

You should see the response

{
  "account": "test-account-name",
  "projectID": "test-project-id",
  "readGroups": [
    "test-group"
  ],
  "writeGroups": [
    "test-group"
  ]
}
  1. List credentials
$ curl localhost:80/v1/credentials | jq

You should see the response

{
  "credentials": [
    {
      "account": "test-account-name",
      "projectID": "test-project-id",
      "readGroups": [
        "test-group"
      ],
      "writeGroups": [
        "test-group"
      ]
    }
  ]
}

To generate CURL commands to create and monitor a deployment, reference the swagger YAML at api/swagger.yaml.