|
|
|
|
@@ -21,6 +21,7 @@ Cloud Run Services and Jobs, with support for IAM roles and Eventarc trigger cre
|
|
|
|
|
- [Creating Cloud Run Jobs](#creating-cloud-run-jobs)
|
|
|
|
|
- [Tag bindings](#tag-bindings)
|
|
|
|
|
- [IAP Configuration](#iap-configuration)
|
|
|
|
|
- [Adding GPUs](#adding-gpus)
|
|
|
|
|
- [Variables](#variables)
|
|
|
|
|
- [Outputs](#outputs)
|
|
|
|
|
- [Fixtures](#fixtures)
|
|
|
|
|
@@ -931,31 +932,128 @@ module "cloud_run" {
|
|
|
|
|
}
|
|
|
|
|
# tftest modules=1 resources=2 e2e
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Adding GPUs
|
|
|
|
|
GPU support is available for all types of Cloud Run resources: jobs, services and worker pools.
|
|
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
module "job" {
|
|
|
|
|
source = "./fabric/modules/cloud-run-v2"
|
|
|
|
|
project_id = var.project_id
|
|
|
|
|
name = "job"
|
|
|
|
|
region = var.region
|
|
|
|
|
launch_stage = "BETA"
|
|
|
|
|
revision = {
|
|
|
|
|
gpu_zonal_redundancy_disabled = true
|
|
|
|
|
node_selector = {
|
|
|
|
|
accelerator = "nvidia-l4"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
type = "JOB"
|
|
|
|
|
containers = {
|
|
|
|
|
hello = {
|
|
|
|
|
image = "us-docker.pkg.dev/cloudrun/container/hello"
|
|
|
|
|
resources = {
|
|
|
|
|
limits = {
|
|
|
|
|
cpu = "4000m"
|
|
|
|
|
memory = "16Gi"
|
|
|
|
|
"nvidia.com/gpu" = "1"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
deletion_protection = false
|
|
|
|
|
}
|
|
|
|
|
# tftest inventory=gpu-job.yaml e2e
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
module "service" {
|
|
|
|
|
source = "./fabric/modules/cloud-run-v2"
|
|
|
|
|
project_id = var.project_id
|
|
|
|
|
name = "service"
|
|
|
|
|
region = var.region
|
|
|
|
|
revision = {
|
|
|
|
|
gpu_zonal_redundancy_disabled = true
|
|
|
|
|
node_selector = {
|
|
|
|
|
accelerator = "nvidia-l4"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
service_config = {
|
|
|
|
|
gen2_execution_environment = true
|
|
|
|
|
}
|
|
|
|
|
containers = {
|
|
|
|
|
hello = {
|
|
|
|
|
image = "us-docker.pkg.dev/cloudrun/container/hello"
|
|
|
|
|
resources = {
|
|
|
|
|
limits = {
|
|
|
|
|
cpu = "4000m"
|
|
|
|
|
memory = "16Gi"
|
|
|
|
|
"nvidia.com/gpu" = "1"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
deletion_protection = false
|
|
|
|
|
}
|
|
|
|
|
# tftest inventory=gpu-service.yaml e2e
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
module "worker" {
|
|
|
|
|
source = "./fabric/modules/cloud-run-v2"
|
|
|
|
|
project_id = var.project_id
|
|
|
|
|
name = "worker"
|
|
|
|
|
region = var.region
|
|
|
|
|
launch_stage = "ALPHA"
|
|
|
|
|
revision = {
|
|
|
|
|
gpu_zonal_redundancy_disabled = true
|
|
|
|
|
node_selector = {
|
|
|
|
|
accelerator = "nvidia-l4"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
type = "WORKERPOOL"
|
|
|
|
|
containers = {
|
|
|
|
|
hello = {
|
|
|
|
|
image = "us-docker.pkg.dev/cloudrun/container/hello"
|
|
|
|
|
resources = {
|
|
|
|
|
limits = {
|
|
|
|
|
cpu = "4000m"
|
|
|
|
|
memory = "16Gi"
|
|
|
|
|
"nvidia.com/gpu" = "1"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
deletion_protection = false
|
|
|
|
|
}
|
|
|
|
|
# tftest inventory=gpu-workerpool.yaml e2e
|
|
|
|
|
```
|
|
|
|
|
<!-- BEGIN TFDOC -->
|
|
|
|
|
## Variables
|
|
|
|
|
|
|
|
|
|
| name | description | type | required | default |
|
|
|
|
|
|---|---|:---:|:---:|:---:|
|
|
|
|
|
| [name](variables.tf#L143) | Name used for Cloud Run service. | <code>string</code> | ✓ | |
|
|
|
|
|
| [project_id](variables.tf#L148) | Project id used for all resources. | <code>string</code> | ✓ | |
|
|
|
|
|
| [region](variables.tf#L153) | Region used for all resources. | <code>string</code> | ✓ | |
|
|
|
|
|
| [containers](variables.tf#L17) | Containers in name => attributes format. | <code title="map(object({ image = string depends_on = optional(list(string)) command = optional(list(string)) args = optional(list(string)) env = optional(map(string)) env_from_key = optional(map(object({ secret = string version = string }))) liveness_probe = optional(object({ grpc = optional(object({ port = optional(number) service = optional(string) })) http_get = optional(object({ http_headers = optional(map(string)) path = optional(string) port = optional(number) })) failure_threshold = optional(number) initial_delay_seconds = optional(number) period_seconds = optional(number) timeout_seconds = optional(number) })) ports = optional(map(object({ container_port = optional(number) name = optional(string) }))) resources = optional(object({ limits = optional(object({ cpu = string memory = string })) cpu_idle = optional(bool) startup_cpu_boost = optional(bool) })) startup_probe = optional(object({ grpc = optional(object({ port = optional(number) service = optional(string) })) http_get = optional(object({ http_headers = optional(map(string)) path = optional(string) port = optional(number) })) tcp_socket = optional(object({ port = optional(number) })) failure_threshold = optional(number) initial_delay_seconds = optional(number) period_seconds = optional(number) timeout_seconds = optional(number) })) volume_mounts = optional(map(string)) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [deletion_protection](variables.tf#L80) | Deletion protection setting for this Cloud Run service. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [encryption_key](variables.tf#L86) | The full resource name of the Cloud KMS CryptoKey. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [iam](variables.tf#L92) | IAM bindings for Cloud Run service in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [job_config](variables.tf#L98) | Cloud Run Job specific configuration. | <code title="object({ max_retries = optional(number) task_count = optional(number) timeout = optional(string) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
| [labels](variables.tf#L113) | Resource labels. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [launch_stage](variables.tf#L119) | The launch stage as defined by Google Cloud Platform Launch Stages. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [managed_revision](variables.tf#L136) | Whether the Terraform module should control the deployment of revisions. | <code>bool</code> | | <code>true</code> |
|
|
|
|
|
| [revision](variables.tf#L158) | Revision template configurations. | <code title="object({ labels = optional(map(string)) name = optional(string) vpc_access = optional(object({ connector = optional(string) egress = optional(string) network = optional(string) subnet = optional(string) tags = optional(list(string)) }), {}) timeout = optional(string) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
| [service_account](variables.tf#L214) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [service_account_create](variables.tf#L220) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [service_config](variables.tf#L226) | Cloud Run service specific configuration options. | <code title="object({ custom_audiences = optional(list(string), null) eventarc_triggers = optional( object({ audit_log = optional(map(object({ method = string service = string }))) pubsub = optional(map(string)) storage = optional(map(object({ bucket = string path = optional(string) }))) service_account_email = optional(string) service_account_create = optional(bool, false) }), {}) gen2_execution_environment = optional(bool, false) iap_config = optional(object({ iam = optional(list(string), []) iam_additive = optional(list(string), []) }), null) ingress = optional(string, null) invoker_iam_disabled = optional(bool, false) max_concurrency = optional(number) scaling = optional(object({ max_instance_count = optional(number) min_instance_count = optional(number) })) timeout = optional(string) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
| [tag_bindings](variables.tf#L290) | Tag bindings for this service, in key => tag value id format. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [type](variables.tf#L297) | Type of Cloud Run resource to deploy: JOB, SERVICE or WORKERPOOL. | <code>string</code> | | <code>"SERVICE"</code> |
|
|
|
|
|
| [volumes](variables.tf#L307) | Named volumes in containers in name => attributes format. | <code title="map(object({ secret = optional(object({ name = string default_mode = optional(string) path = optional(string) version = optional(string) mode = optional(string) })) cloud_sql_instances = optional(list(string)) empty_dir_size = optional(string) gcs = optional(object({ bucket = string is_read_only = optional(bool) })) nfs = optional(object({ server = string path = optional(string) is_read_only = optional(bool) })) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [name](variables.tf#L152) | Name used for Cloud Run service. | <code>string</code> | ✓ | |
|
|
|
|
|
| [project_id](variables.tf#L157) | Project id used for all resources. | <code>string</code> | ✓ | |
|
|
|
|
|
| [region](variables.tf#L162) | Region used for all resources. | <code>string</code> | ✓ | |
|
|
|
|
|
| [containers](variables.tf#L17) | Containers in name => attributes format. | <code title="map(object({ image = string depends_on = optional(list(string)) command = optional(list(string)) args = optional(list(string)) env = optional(map(string)) env_from_key = optional(map(object({ secret = string version = string }))) liveness_probe = optional(object({ grpc = optional(object({ port = optional(number) service = optional(string) })) http_get = optional(object({ http_headers = optional(map(string)) path = optional(string) port = optional(number) })) failure_threshold = optional(number) initial_delay_seconds = optional(number) period_seconds = optional(number) timeout_seconds = optional(number) })) ports = optional(map(object({ container_port = optional(number) name = optional(string) }))) resources = optional(object({ limits = optional(map(string)) cpu_idle = optional(bool) startup_cpu_boost = optional(bool) })) startup_probe = optional(object({ grpc = optional(object({ port = optional(number) service = optional(string) })) http_get = optional(object({ http_headers = optional(map(string)) path = optional(string) port = optional(number) })) tcp_socket = optional(object({ port = optional(number) })) failure_threshold = optional(number) initial_delay_seconds = optional(number) period_seconds = optional(number) timeout_seconds = optional(number) })) volume_mounts = optional(map(string)) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [deletion_protection](variables.tf#L89) | Deletion protection setting for this Cloud Run service. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [encryption_key](variables.tf#L95) | The full resource name of the Cloud KMS CryptoKey. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [iam](variables.tf#L101) | IAM bindings for Cloud Run service in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [job_config](variables.tf#L107) | Cloud Run Job specific configuration. | <code title="object({ max_retries = optional(number) task_count = optional(number) timeout = optional(string) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
| [labels](variables.tf#L122) | Resource labels. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [launch_stage](variables.tf#L128) | The launch stage as defined by Google Cloud Platform Launch Stages. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [managed_revision](variables.tf#L145) | Whether the Terraform module should control the deployment of revisions. | <code>bool</code> | | <code>true</code> |
|
|
|
|
|
| [revision](variables.tf#L167) | Revision template configurations. | <code title="object({ gpu_zonal_redundancy_disabled = optional(bool) labels = optional(map(string)) name = optional(string) node_selector = optional(object({ accelerator = string })) vpc_access = optional(object({ connector = optional(string) egress = optional(string) network = optional(string) subnet = optional(string) tags = optional(list(string)) }), {}) timeout = optional(string) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
| [service_account](variables.tf#L227) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [service_account_create](variables.tf#L233) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [service_config](variables.tf#L239) | Cloud Run service specific configuration options. | <code title="object({ custom_audiences = optional(list(string), null) eventarc_triggers = optional( object({ audit_log = optional(map(object({ method = string service = string }))) pubsub = optional(map(string)) storage = optional(map(object({ bucket = string path = optional(string) }))) service_account_email = optional(string) service_account_create = optional(bool, false) }), {}) gen2_execution_environment = optional(bool, false) iap_config = optional(object({ iam = optional(list(string), []) iam_additive = optional(list(string), []) }), null) ingress = optional(string, null) invoker_iam_disabled = optional(bool, false) max_concurrency = optional(number) scaling = optional(object({ max_instance_count = optional(number) min_instance_count = optional(number) })) timeout = optional(string) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
| [tag_bindings](variables.tf#L303) | Tag bindings for this service, in key => tag value id format. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [type](variables.tf#L310) | Type of Cloud Run resource to deploy: JOB, SERVICE or WORKERPOOL. | <code>string</code> | | <code>"SERVICE"</code> |
|
|
|
|
|
| [volumes](variables.tf#L320) | Named volumes in containers in name => attributes format. | <code title="map(object({ secret = optional(object({ name = string default_mode = optional(string) path = optional(string) version = optional(string) mode = optional(string) })) cloud_sql_instances = optional(list(string)) empty_dir_size = optional(string) gcs = optional(object({ bucket = string is_read_only = optional(bool) })) nfs = optional(object({ server = string path = optional(string) is_read_only = optional(bool) })) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [vpc_connector_create](variables-vpcconnector.tf#L17) | Populate this to create a Serverless VPC Access connector. | <code title="object({ ip_cidr_range = optional(string) machine_type = optional(string) name = optional(string) network = optional(string) instances = optional(object({ max = optional(number) min = optional(number) }), {} ) throughput = optional(object({ max = optional(number) min = optional(number) }), {} ) subnet = optional(object({ name = optional(string) project_id = optional(string) }), {}) })">object({…})</code> | | <code>null</code> |
|
|
|
|
|
| [workerpool_config](variables.tf#L341) | Cloud Run Worker Pool specific configuration. | <code title="object({ scaling = optional(object({ manual_instance_count = optional(number) max_instance_count = optional(number) min_instance_count = optional(number) mode = optional(string) })) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
| [workerpool_config](variables.tf#L354) | Cloud Run Worker Pool specific configuration. | <code title="object({ scaling = optional(object({ manual_instance_count = optional(number) max_instance_count = optional(number) min_instance_count = optional(number) mode = optional(string) })) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
|
|
|
|
|
## Outputs
|
|
|
|
|
|
|
|
|
|
|