Skip to content

Latest commit

 

History

History
121 lines (99 loc) · 4.58 KB

README.md

File metadata and controls

121 lines (99 loc) · 4.58 KB

Githut Action

Important Info

  • name: configure_gcp_endpoints
  • yaml reference: Auddia/cicd/actions/configure_gcp_endpoints@<tag>
  • action type: Docker Action

Description

This is a custom action used for deploying updated api definitions to gcp endpoints.

NOTE: This action assumes that you have setup the gcloud sdk with this action

Tags

This action is available on tags v0 and above

Action Steps

  1. Deploy new/updated endpoints configuration/definition (i.e. changes to the openapi.yaml) to GCP endpoints.
  2. Build a new image for the gateway proxy to endpoints and upload it to container registry, so it can be redeployed in cloud run.
  3. Redeploy the gateway proxy (i.e. a Cloud Run Service) using the newly generated image
  4. Update the default service account privileges, so it can invoke the backend endpoints through the gateway proxy

Required Setup

To use this action in your repository you need to do the following steps to configure the GCP environment properly.

  1. Create the Gateway Proxy for GCP endpoints
    1. Create Cloud Run Service by deploying ESPv2 container:
$ gcloud run deploy <API_NAME>-endpoints-cloudrun-service \
  --image="gcr.io/endpoints-release/endpoints-runtime-serverless:2" \
  --allow-unauthenticated \
  --platform managed \
  --project <GCP_PROJECT> \
  --region us-central1
  1. Map the custom subdomain to the desired backend service in cloud run.

    1. Go to the GCP cloud console.
    2. First click on to Cloud Run
    3. Then click Manage Custom Domains in the top banner
    4. Add the mapping of api service to the desired domain name.
      1. NOTE: Make sure the domain is verified in Cloud DNS
  2. Run the configure_gcp_endpoints action.

  3. (Optional) If you see an error about the ownership of the domain name and it is the first time you are attempting to successfully run this workflow follow the steps below to fix the issue.

    • Note: This may not solve the issue
    • Error Example: ERROR: (gcloud.endpoints.services.deploy) PERMISSION_DENIED: Ownership for domain name 'events.cfr-staging.auddia.services' on project 'cfr-projects-staging' cannot be verified.
    1. Automatically compile the openapi document or copy it from the CICD workflow into the file openapi.
    2. Run this command
      $ gcloud endpoints services deploy ./openapi --project <gcp_project>

Input Arguments

gcp_project
  • Description: The GCP project name
  • type: string
  • required: true
api_subdomain
  • Description: The subdomain of the api being deployed
  • type: string
  • required: true
api_name
  • Description: Name of the api
  • type: string
  • required: false
  • You must specify this field or the function_name field
function_name
  • Description: Name of the GCP function
  • type: string
  • required: false
  • You must specify this field or the api_name field
endpoints_service_name
  • Description: Name of the GCP endpoints service name
  • type: string
  • required: true
default_service_account
  • Description: The service account you want to run the gcloud deployment commands
  • type: string
  • required: true
openapi_yaml
  • Description: The location of the openapi yaml that defines the api's endpoints
  • type: string
  • default: ./open_api.yaml

Example Usage

jobs:
  example_job:
    name: 'Configure GCP Enpoints Example'
    runs-on: ubuntu-latest
    steps:
      - name: GCloud SDK Setup
        uses: Auddia/cicd/actions/setup_gcloud@<tag>
        with:
          gcp_credentials: ${{ secrets.GCP_CREDEENTIALS }}

      - name: 'Configure Endpoints'
        uses: Auddia/cicd/actions/configure_gcp_endpoints@<tag>
        with:
          gcp_project: ${{ inputs.gcp_project }}
          api_subdomain: ${{ inputs.api_subdomain }}
          api_name: ${{ inputs.api_name }}
          endpoints_service_name: ${{ inputs.endpoints_service_name }}
          default_service_account: ${{ inputs.default_service_account }}
          openapi_yaml: ${{ inputs.openapi_yaml }}

Additonal Usage