Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Google Cloud Run #1361

Open
aliscott opened this issue Feb 9, 2022 · 3 comments · May be fixed by #3067
Open

Add support for Google Cloud Run #1361

aliscott opened this issue Feb 9, 2022 · 3 comments · May be fixed by #3067
Assignees
Labels
google Issue related to Google Cloud new resources New cloud resources to be added

Comments

@aliscott
Copy link
Member

aliscott commented Feb 9, 2022

Google pricing: https://cloud.google.com/run/pricing
Terraform resources:

  • google_cloud_run_* - some of these might be free

Details

google_cloud_run_service

We will need to extract the following attributes from the Terraform:

  • template.spec.containers[*].resources.limits.cpu
  • template.spec.containers[*].resources.limits.memory
  • template.metadata.annotations["autoscaling.knative.dev/minScale"]
  • template.metadata.annotations["run.googleapis.com/cpu-throttling"] (this is true by default)

And add the following usage attributes:

  • monthly_requests
  • These are used if CPU throttling is enabled:
    • average_request_duration
    • concurrent_requests_per_instance
  • These are only used if CPU throttling is disabled.
    • instance_hrs

The cost components will then be calculated as:

  • CPU allocation:
    • If CPU throttling is disabled
      • if instance_hrs is specified use that, otherwise use the min scale value * 730 for the instance hours.
      • Multiply the instance hours by the sum of the CPU values to find the CPU usage.
    • If CPU throttling is enabled:
      • The instance hours should be calculated from (monthly requests * average request_duration) / concurrent requests per instance. This should then be multiplied by the sum of the CPU values.
  • Memory allocation:
    • Use the same calculation as CPU. This should follow the same logic depending on if CPU throttling is disabled or not.
  • Requests:
    • Based on the monthly_requests usage value

The prices for all the cost components are also based on whether the region of the resource is a Tier 1 or Tier 2 region. We might need to define a static mapping for these initially.

google_cloud_run_v2_service

This uses the same logic as the google_cloud_run_service resource but the attributes are slightly different:

  • template.containers[*].resources.limits.cpu
  • template.containers[*].resources.limits.memory
  • template.scaling.min_instance_count
  • template.containers[*].resources.limits.cpu_idle

google_cloud_run_v2_job

We will need to extract the following attributes from the Terraform:

  • template.template.containers[*].resources.limits.cpu
  • template.template.containers[*].resources.limits.memory
  • template.task_count

Pricing again depends on if the region is a tier 1 or tier 2 region.

And add the following usage attributes:

  • monthly_job_executions
  • average_task_execution_mins

The cost components will then be calculated as:

  • CPU allocation: monthly job executions * task count * task_execution_mins * cpu
  • Memory allocation: monthly job executions * task count * task_execution_mins * memory

These resources can be added as free resources:

  • google_cloud_run_service_iam_policy
  • google_cloud_run_service_iam_binding
  • google_cloud_run_service_iam_member
  • google_cloud_run_domain_mapping
  • google_cloud_run_v2_job_iam
  • google_cloud_run_v2_service_iam
@aliscott aliscott added new resources New cloud resources to be added google Issue related to Google Cloud needs details Issue needs more details labels Feb 9, 2022
@jyriok
Copy link

jyriok commented Aug 4, 2023

any news about this ?

@awaismemon26
Copy link

I would like to contribute to this issue, It would be nice to get resource implementation details on this and also cost components names, units, and some pricing details.

@vdmgolub
Copy link
Contributor

@awaismemon26 Hello! Thank you! Please give us some time to figure out the details that the resource needs and we'll update the issue. I saw you requested access to the Cloud Pricing API in community Slack. we'll ping you there with the instructions too. I'll assign you to the issue just now. Thanks again!

@aliscott aliscott removed the needs details Issue needs more details label Feb 20, 2024
@awaismemon26 awaismemon26 linked a pull request May 9, 2024 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
google Issue related to Google Cloud new resources New cloud resources to be added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants