Skip to content

Commit 22a4003

Browse files
authored
Add max instance count field to Cloud Run Service (GoogleCloudPlatform#14724)
1 parent 62c8541 commit 22a4003

File tree

5 files changed

+35
-27
lines changed

5 files changed

+35
-27
lines changed

mmv1/products/cloudrunv2/Service.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ properties:
340340
type: Integer
341341
description: |
342342
Minimum number of instances for the service, to be divided among all revisions receiving traffic.
343+
- name: 'maxInstanceCount'
344+
type: Integer
345+
description: |
346+
Combined maximum number of instances for all revisions receiving traffic.
343347
- name: 'scalingMode'
344348
type: Enum
345349
description: |

mmv1/templates/terraform/examples/cloudrunv2_service_basic.tf.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" {
33
location = "us-central1"
44
deletion_protection = false
55
ingress = "INGRESS_TRAFFIC_ALL"
6+
7+
scaling {
8+
max_instance_count = 100
9+
}
610

711
template {
812
containers {

mmv1/templates/terraform/examples/cloudrunv2_service_gpu.tf.tmpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" {
44
deletion_protection = false
55
ingress = "INGRESS_TRAFFIC_ALL"
66

7+
scaling {
8+
max_instance_count = 1
9+
}
10+
711
template {
812
containers {
913
image = "us-docker.pkg.dev/cloudrun/container/hello"
@@ -20,8 +24,5 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" {
2024
accelerator = "nvidia-l4"
2125
}
2226
gpu_zonal_redundancy_disabled = true
23-
scaling {
24-
max_instance_count = 1
25-
}
2627
}
2728
}

mmv1/templates/terraform/examples/cloudrunv2_service_sql.tf.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ resource "google_cloud_run_v2_service" "{{$.PrimaryResourceId}}" {
44
deletion_protection = false
55
ingress = "INGRESS_TRAFFIC_ALL"
66

7-
template {
8-
scaling {
9-
max_instance_count = 2
10-
}
11-
7+
scaling {
8+
max_instance_count = 2
9+
}
10+
11+
template {
1212
volumes {
1313
name = "cloudsql"
1414
cloud_sql_instance {

mmv1/third_party/terraform/services/cloudrunv2/resource_cloud_run_v2_service_test.go.tmpl

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ resource "google_cloud_run_v2_service" "default" {
6363
}
6464
client = "client-1"
6565
client_version = "client-version-1"
66+
scaling {
67+
min_instance_count = 1
68+
max_instance_count = 3
69+
}
6670
template {
6771
labels = {
6872
label-1 = "value-1"
6973
}
7074
timeout = "300s"
7175
service_account = google_service_account.service_account.email
7276
execution_environment = "EXECUTION_ENVIRONMENT_GEN2"
73-
scaling {
74-
max_instance_count = 3
75-
min_instance_count = 1
76-
}
7777
annotations = {
7878
generated-by = "magic-modules"
7979
}
@@ -131,18 +131,17 @@ resource "google_cloud_run_v2_service" "default" {
131131
}
132132
client = "client-update"
133133
client_version = "client-version-update"
134-
134+
scaling {
135+
min_instance_count = 1
136+
max_instance_count = 2
137+
}
135138
template {
136139
labels = {
137140
label-1 = "value-update"
138141
}
139142
timeout = "500s"
140143
service_account = google_service_account.service_account.email
141144
execution_environment = "EXECUTION_ENVIRONMENT_GEN1"
142-
scaling {
143-
max_instance_count = 2
144-
min_instance_count = 1
145-
}
146145
annotations = {
147146
generated-by = "magic-modules"
148147
}
@@ -253,17 +252,17 @@ resource "google_cloud_run_v2_service" "default" {
253252
}
254253
client = "client-1"
255254
client_version = "client-version-1"
255+
scaling {
256+
min_instance_count = 1
257+
max_instance_count = 3
258+
}
256259
template {
257260
labels = {
258261
label-1 = "value-1"
259262
}
260263
timeout = "300s"
261264
service_account = google_service_account.service_account.email
262265
execution_environment = "EXECUTION_ENVIRONMENT_GEN2"
263-
scaling {
264-
max_instance_count = 3
265-
min_instance_count = 1
266-
}
267266
annotations = {
268267
generated-by = "magic-modules"
269268
}
@@ -1327,6 +1326,9 @@ resource "google_cloud_run_v2_service" "default" {
13271326
}
13281327
client = "client-1"
13291328
client_version = "client-version-1"
1329+
scaling {
1330+
max_instance_count = 1
1331+
}
13301332
template {
13311333
containers {
13321334
image = "us-docker.pkg.dev/cloudrun/container/hello"
@@ -1338,9 +1340,6 @@ resource "google_cloud_run_v2_service" "default" {
13381340
startup_cpu_boost = true
13391341
}
13401342
}
1341-
scaling {
1342-
max_instance_count = 1
1343-
}
13441343
}
13451344
}
13461345
`, context)
@@ -1362,6 +1361,9 @@ resource "google_cloud_run_v2_service" "default" {
13621361
}
13631362
client = "client-1"
13641363
client_version = "client-version-1"
1364+
scaling {
1365+
max_instance_count = 1
1366+
}
13651367
template {
13661368
containers {
13671369
image = "us-docker.pkg.dev/cloudrun/container/hello"
@@ -1378,9 +1380,6 @@ resource "google_cloud_run_v2_service" "default" {
13781380
accelerator = "nvidia-l4"
13791381
}
13801382
gpu_zonal_redundancy_disabled = true
1381-
scaling {
1382-
max_instance_count = 1
1383-
}
13841383
}
13851384
}
13861385
`, context)

0 commit comments

Comments
 (0)