Skip to content

Commit 61f9f4f

Browse files
authored
Add cpu_idle setting, default to true (#132)
This allows CPU to be throttle when the service is idle. --------- Signed-off-by: Nghia Tran <[email protected]>
1 parent 74b6332 commit 61f9f4f

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

modules/regional-go-service/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ No requirements.
8989

9090
| Name | Description | Type | Default | Required |
9191
|------|-------------|------|---------|:--------:|
92-
| <a name="input_containers"></a> [containers](#input\_containers) | The containers to run in the service. Each container will be run in each region. | <pre>map(object({<br> source = object({<br> base_image = optional(string, "cgr.dev/chainguard/static:latest-glibc")<br> working_dir = string<br> importpath = string<br> })<br> args = optional(list(string), [])<br> ports = optional(list(object({<br> name = optional(string, "http1")<br> container_port = number<br> })), [])<br> resources = optional(object({<br> limits = object({<br> cpu = string<br> memory = string<br> })<br> }), null)<br> env = optional(list(object({<br> name = string<br> value = optional(string)<br> value_source = optional(object({<br> secret_key_ref = object({<br> secret = string<br> version = string<br> })<br> }), null)<br> })), [])<br> regional-env = optional(list(object({<br> name = string<br> value = map(string)<br> })), [])<br> volume_mounts = optional(list(object({<br> name = string<br> mount_path = string<br> })), [])<br> }))</pre> | n/a | yes |
92+
| <a name="input_containers"></a> [containers](#input\_containers) | The containers to run in the service. Each container will be run in each region. | <pre>map(object({<br> source = object({<br> base_image = optional(string, "cgr.dev/chainguard/static:latest-glibc")<br> working_dir = string<br> importpath = string<br> })<br> args = optional(list(string), [])<br> ports = optional(list(object({<br> name = optional(string, "http1")<br> container_port = number<br> })), [])<br> resources = optional(<br> object(<br> {<br> limits = optional(object(<br> {<br> cpu = string<br> memory = string<br> }<br> ), null)<br> cpu_idle = optional(bool, true)<br> }<br> ),<br> {<br> cpu_idle = true<br> }<br> )<br> env = optional(list(object({<br> name = string<br> value = optional(string)<br> value_source = optional(object({<br> secret_key_ref = object({<br> secret = string<br> version = string<br> })<br> }), null)<br> })), [])<br> regional-env = optional(list(object({<br> name = string<br> value = map(string)<br> })), [])<br> volume_mounts = optional(list(object({<br> name = string<br> mount_path = string<br> })), [])<br> }))</pre> | n/a | yes |
9393
| <a name="input_egress"></a> [egress](#input\_egress) | The egress mode for the service. Must be one of ALL\_TRAFFIC, or PRIVATE\_RANGES\_ONLY. Egress traffic is routed through the regional VPC network from var.regions. | `string` | `"ALL_TRAFFIC"` | no |
9494
| <a name="input_ingress"></a> [ingress](#input\_ingress) | The ingress mode for the service. Must be one of INGRESS\_TRAFFIC\_ALL, INGRESS\_TRAFFIC\_INTERNAL\_LOAD\_BALANCER, or INGRESS\_TRAFFIC\_INTERNAL\_ONLY. | `string` | `"INGRESS_TRAFFIC_INTERNAL_ONLY"` | no |
9595
| <a name="input_name"></a> [name](#input\_name) | n/a | `string` | n/a | yes |

modules/regional-go-service/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ resource "google_cloud_run_v2_service" "this" {
7474
dynamic "resources" {
7575
for_each = containers.value.resources != null ? { "" : containers.value.resources } : {}
7676
content {
77-
limits = resources.value.limits
77+
limits = resources.value.limits
78+
cpu_idle = resources.value.cpu_idle
7879
}
7980
}
8081

modules/regional-go-service/variables.tf

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,22 @@ variable "containers" {
4444
name = optional(string, "http1")
4545
container_port = number
4646
})), [])
47-
resources = optional(object({
48-
limits = object({
49-
cpu = string
50-
memory = string
51-
})
52-
}), null)
47+
resources = optional(
48+
object(
49+
{
50+
limits = optional(object(
51+
{
52+
cpu = string
53+
memory = string
54+
}
55+
), null)
56+
cpu_idle = optional(bool, true)
57+
}
58+
),
59+
{
60+
cpu_idle = true
61+
}
62+
)
5363
env = optional(list(object({
5464
name = string
5565
value = optional(string)

0 commit comments

Comments
 (0)