Making use of H2C configurable for GCP Cloud Run (#162)
See https://github.com/fleetdm/fleet/issues/37352 Whether or not H2C vs. HTTP v1 is used for GCP Cloud Run deployments needs to be configurable. --------- Co-authored-by: Jorge Falcon <22119513+BCTBB@users.noreply.github.com>
This commit is contained in:
1 parent
75854ad3f0
commit
6bb6f3e736
5 files changed
+36
-9
No files matched your search
+12
-1
@@ -76,6 +76,7 @@ This Terraform project automates the deployment of Fleet Device Management (Flee
|
||||
# max_instance_count = 3
|
||||
# exec_migration = true # Set to true to run migrations on `terraform apply`
|
||||
# (e.g., when changing image_tag)
|
||||
# use_h2c = false # Set to true to use h2c
|
||||
}
|
||||
|
||||
```
|
||||
@@ -94,6 +95,16 @@ This Terraform project automates the deployment of Fleet Device Management (Flee
|
||||
|
||||
Review `variables.tf` and `byo-project/variables.tf` for all available options and their defaults.
|
||||
|
||||
## Known Limitations
|
||||
|
||||
1. To handle large uploads, we need to bypass GCP cloud run's 32MB HTTP/1 body limit, by setting `fleet_config.use_h2c = true` which forces Fleet to use HTTP/2. However, as Cloud Run documentation notes, HTTP/2 end-to-end breaks connection upgrades, affecting WebSocket support and Fleet functionality for features such as Live Queries.
|
||||
|
||||
**Workaround**: [Use Fleet Gitops Flow](https://fleetdm.com/docs/using-fleet/gitops#managing-software-installers)
|
||||
* Set `fleet_config.use_h2c = false` to force HTTP/1
|
||||
* If you have large uploads, use `fleetctl apply` with a url field in your software YAML. The data flow avoids the ingress limit:
|
||||
* Apply the YAML (small request).
|
||||
* The Fleet Server makes an outbound GET request to download the file from the URL (S3, GCS, etc).
|
||||
* Cloud Run doesn't apply the 32MB limit to outbound requests.
|
||||
|
||||
## Deployment Steps
|
||||
|
||||
@@ -220,4 +231,4 @@ graph TD
|
||||
LB --> CloudRun
|
||||
NAT --> GitHub
|
||||
|
||||
```
|
||||
```
|
||||
+18
-6
@@ -76,6 +76,7 @@ This Terraform project automates the deployment of Fleet Device Management (Flee
|
||||
# max_instance_count = 3
|
||||
# exec_migration = true # Set to true to run migrations on `terraform apply`
|
||||
# (e.g., when changing image_tag)
|
||||
# use_h2c = false # Set to true to use h2c
|
||||
}
|
||||
|
||||
```
|
||||
@@ -86,12 +87,23 @@ This Terraform project automates the deployment of Fleet Device Management (Flee
|
||||
* `dns_zone_name`: The DNS zone that will be created/managed in Cloud DNS (e.g., `mydomain.com.`). **Must end with a dot.**
|
||||
* `dns_record_name`: The specific DNS record for Fleet (e.g., `fleet.mydomain.com.`). **Must end with a dot.**
|
||||
* `project_name`: A descriptive name for the project to be created.
|
||||
* `fleet_config.image_tag`: The Docker image tag for the Fleet version you want to deploy (e.g., `fleetdm/fleet:v4.76.0`).
|
||||
* `fleet_config.image_tag`: The Docker image tag for the Fleet version you want to deploy (e.g., `fleetdm/fleet:v4.79.1`).
|
||||
* `fleet_config.exec_migration`: Set to `true` when you are upgrading the `fleet_config.image_tag` to automatically run database migrations. Set to `false` if you want to manage migrations manually or if it's not an image upgrade.
|
||||
* `fleet_config.license_key` (Optional, inside the `fleet_config` object): Your Fleet license key if you have one.
|
||||
|
||||
Review `variables.tf` and `byo-project/variables.tf` for all available options and their defaults.
|
||||
|
||||
## Known Limitations
|
||||
|
||||
1. To handle large uploads, we need to bypass GCP cloud run's 32MB HTTP/1 body limit, by setting `fleet_config.use_h2c = true` which forces Fleet to use HTTP/2. However, as Cloud Run documentation notes, HTTP/2 end-to-end breaks connection upgrades, affecting WebSocket support and Fleet functionality for features such as Live Queries.
|
||||
|
||||
**Workaround**: [Use Fleet Gitops Flow](https://fleetdm.com/docs/using-fleet/gitops#managing-software-installers)
|
||||
* Set `fleet_config.use_h2c = false` to force HTTP/1
|
||||
* If you have large uploads, use `fleetctl apply` with a url field in your software YAML. The data flow avoids the ingress limit:
|
||||
* Apply the YAML (small request).
|
||||
* The Fleet Server makes an outbound GET request to download the file from the URL (S3, GCS, etc).
|
||||
* Cloud Run doesn't apply the 32MB limit to outbound requests.
|
||||
|
||||
## Deployment Steps
|
||||
|
||||
1. **Authenticate with GCP:**
|
||||
@@ -245,20 +257,20 @@ No resources.
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:--------:|
|
||||
| <a name="input_billing_account_id"></a> [billing\_account\_id](#input\_billing\_account\_id) | billing account id | `any` | n/a | yes |
|
||||
| <a name="input_cache_config"></a> [cache\_config](#input\_cache\_config) | Configuration for the Memorystore (Redis) instance. | <pre>object({<br> name = string<br> tier = string<br> engine_version = string<br> connect_mode = string<br> memory_size = number<br> })</pre> | <pre>{<br> "connect_mode": "PRIVATE_SERVICE_ACCESS",<br> "engine_version": null,<br> "memory_size": 1,<br> "name": "fleet-cache",<br> "tier": "STANDARD_HA"<br>}</pre> | no |
|
||||
| <a name="input_database_config"></a> [database\_config](#input\_database\_config) | Configuration for the Cloud SQL (MySQL) instance. | <pre>object({<br> name = string<br> database_name = string<br> database_user = string<br> collation = string<br> charset = string<br> deletion_protection = bool<br> database_version = string<br> tier = string<br> })</pre> | <pre>{<br> "charset": "utf8mb4",<br> "collation": "utf8mb4_unicode_ci",<br> "database_name": "fleet",<br> "database_user": "fleet",<br> "database_version": "MYSQL_8_0",<br> "deletion_protection": false,<br> "name": "fleet-mysql",<br> "tier": "db-n1-standard-1"<br>}</pre> | no |
|
||||
| <a name="input_cache_config"></a> [cache\_config](#input\_cache\_config) | Configuration for the Memorystore (Redis) instance. | <pre>object({<br/> name = string<br/> tier = string<br/> engine_version = string<br/> connect_mode = string<br/> memory_size = number<br/> })</pre> | <pre>{<br/> "connect_mode": "PRIVATE_SERVICE_ACCESS",<br/> "engine_version": null,<br/> "memory_size": 1,<br/> "name": "fleet-cache",<br/> "tier": "STANDARD_HA"<br/>}</pre> | no |
|
||||
| <a name="input_database_config"></a> [database\_config](#input\_database\_config) | Configuration for the Cloud SQL (MySQL) instance. | <pre>object({<br/> name = string<br/> database_name = string<br/> database_user = string<br/> collation = string<br/> charset = string<br/> deletion_protection = bool<br/> database_version = string<br/> tier = string<br/> })</pre> | <pre>{<br/> "charset": "utf8mb4",<br/> "collation": "utf8mb4_unicode_ci",<br/> "database_name": "fleet",<br/> "database_user": "fleet",<br/> "database_version": "MYSQL_8_0",<br/> "deletion_protection": false,<br/> "name": "fleet-mysql",<br/> "tier": "db-n1-standard-1"<br/>}</pre> | no |
|
||||
| <a name="input_dns_record_name"></a> [dns\_record\_name](#input\_dns\_record\_name) | The DNS record for Fleet (e.g., 'fleet.my-fleet-infra.com.') | `string` | n/a | yes |
|
||||
| <a name="input_dns_zone_name"></a> [dns\_zone\_name](#input\_dns\_zone\_name) | The DNS name of the managed zone (e.g., 'my-fleet-infra.com.') | `string` | n/a | yes |
|
||||
| <a name="input_fleet_config"></a> [fleet\_config](#input\_fleet\_config) | Configuration for the Fleet application deployment. | <pre>object({<br> installers_bucket_name = string<br> image_tag = string<br> fleet_cpu = string<br> fleet_memory = string<br> debug_logging = bool<br> license_key = optional(string)<br> min_instance_count = number<br> max_instance_count = number<br> exec_migration = bool<br> extra_env_vars = optional(map(string))<br> extra_secret_env_vars = optional(map(object({<br> secret = string<br> version = string<br> })))<br> })</pre> | <pre>{<br> "debug_logging": false,<br> "exec_migration": true,<br> "extra_env_vars": {},<br> "extra_secret_env_vars": {},<br> "fleet_cpu": "1000m",<br> "fleet_memory": "4096Mi",<br> "image_tag": "fleetdm/fleet:v4.76.0",<br> "installers_bucket_name": "",<br> "max_instance_count": 5,<br> "min_instance_count": 1<br>}</pre> | no |
|
||||
| <a name="input_fleet_config"></a> [fleet\_config](#input\_fleet\_config) | Configuration for the Fleet application deployment. | <pre>object({<br/> installers_bucket_name = string<br/> image_tag = string<br/> fleet_cpu = string<br/> fleet_memory = string<br/> debug_logging = bool<br/> license_key = optional(string)<br/> min_instance_count = number<br/> max_instance_count = number<br/> exec_migration = bool<br/> use_h2c = bool<br/> extra_env_vars = optional(map(string))<br/> extra_secret_env_vars = optional(map(object({<br/> secret = string<br/> version = string<br/> })))<br/> })</pre> | <pre>{<br/> "debug_logging": false,<br/> "exec_migration": true,<br/> "extra_env_vars": {},<br/> "extra_secret_env_vars": {},<br/> "fleet_cpu": "1000m",<br/> "fleet_memory": "4096Mi",<br/> "image_tag": "fleetdm/fleet:v4.78.2",<br/> "installers_bucket_name": "",<br/> "max_instance_count": 5,<br/> "min_instance_count": 1,<br/> "use_h2c": false<br/>}</pre> | no |
|
||||
| <a name="input_fleet_image"></a> [fleet\_image](#input\_fleet\_image) | n/a | `string` | `"v4.67.3"` | no |
|
||||
| <a name="input_labels"></a> [labels](#input\_labels) | resource labels | `map(string)` | <pre>{<br> "application": "fleet"<br>}</pre> | no |
|
||||
| <a name="input_labels"></a> [labels](#input\_labels) | resource labels | `map(string)` | <pre>{<br/> "application": "fleet"<br/>}</pre> | no |
|
||||
| <a name="input_location"></a> [location](#input\_location) | The general location for resources, e.g., 'us' for GCS buckets. | `string` | `"us"` | no |
|
||||
| <a name="input_org_id"></a> [org\_id](#input\_org\_id) | organization id | `any` | n/a | yes |
|
||||
| <a name="input_prefix"></a> [prefix](#input\_prefix) | A prefix used for naming resources within the byo-project module. | `string` | `"fleet"` | no |
|
||||
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | n/a | `string` | `"fleet"` | no |
|
||||
| <a name="input_random_project_id"></a> [random\_project\_id](#input\_random\_project\_id) | n/a | `bool` | `true` | no |
|
||||
| <a name="input_region"></a> [region](#input\_region) | The GCP region for regional resources. | `string` | `"us-central1"` | no |
|
||||
| <a name="input_vpc_config"></a> [vpc\_config](#input\_vpc\_config) | Configuration for the VPC network and subnets. | <pre>object({<br> network_name = string<br> subnets = list(object({<br> subnet_name = string<br> subnet_ip = string<br> subnet_region = string<br> subnet_private_access = bool<br> }))<br> })</pre> | <pre>{<br> "network_name": "fleet-network",<br> "subnets": [<br> {<br> "subnet_ip": "10.10.10.0/24",<br> "subnet_name": "fleet-subnet",<br> "subnet_private_access": true,<br> "subnet_region": "us-central1"<br> }<br> ]<br>}</pre> | no |
|
||||
| <a name="input_vpc_config"></a> [vpc\_config](#input\_vpc\_config) | Configuration for the VPC network and subnets. | <pre>object({<br/> network_name = string<br/> subnets = list(object({<br/> subnet_name = string<br/> subnet_ip = string<br/> subnet_region = string<br/> subnet_private_access = bool<br/> }))<br/> })</pre> | <pre>{<br/> "network_name": "fleet-network",<br/> "subnets": [<br/> {<br/> "subnet_ip": "10.10.10.0/24",<br/> "subnet_name": "fleet-subnet",<br/> "subnet_private_access": true,<br/> "subnet_region": "us-central1"<br/> }<br/> ]<br/>}</pre> | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ locals {
|
||||
})
|
||||
fleet_env_vars = merge(var.fleet_config.extra_env_vars, {
|
||||
FLEET_LICENSE_KEY = var.fleet_config.license_key
|
||||
FLEET_SERVER_FORCE_H2C = "true"
|
||||
FLEET_SERVER_FORCE_H2C = var.fleet_config.use_h2c
|
||||
FLEET_MYSQL_PROTOCOL = "tcp"
|
||||
FLEET_MYSQL_ADDRESS = "${module.mysql.private_ip_address}:3306"
|
||||
FLEET_MYSQL_USERNAME = var.database_config.database_user
|
||||
@@ -77,7 +77,7 @@ module "fleet-service" {
|
||||
{
|
||||
container_image = local.fleet_image_tag
|
||||
ports = {
|
||||
name = "h2c"
|
||||
name = var.fleet_config.use_h2c ? "h2c" : "http1"
|
||||
container_port = 8080
|
||||
}
|
||||
# container_command = ["/bin/sh"]
|
||||
|
||||
@@ -99,6 +99,7 @@ variable "fleet_config" {
|
||||
min_instance_count = number
|
||||
max_instance_count = number
|
||||
exec_migration = bool
|
||||
use_h2c = bool
|
||||
extra_env_vars = optional(map(string))
|
||||
extra_secret_env_vars = optional(map(object({
|
||||
secret = string
|
||||
@@ -114,6 +115,7 @@ variable "fleet_config" {
|
||||
min_instance_count = 1
|
||||
max_instance_count = 5
|
||||
exec_migration = true
|
||||
use_h2c = false
|
||||
extra_env_vars = {}
|
||||
extra_secret_env_vars = {}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ variable "fleet_config" {
|
||||
min_instance_count = number
|
||||
max_instance_count = number
|
||||
exec_migration = bool
|
||||
use_h2c = bool
|
||||
extra_env_vars = optional(map(string))
|
||||
extra_secret_env_vars = optional(map(object({
|
||||
secret = string
|
||||
@@ -144,6 +145,7 @@ variable "fleet_config" {
|
||||
min_instance_count = 1
|
||||
max_instance_count = 5
|
||||
exec_migration = true
|
||||
use_h2c = false
|
||||
extra_env_vars = {}
|
||||
extra_secret_env_vars = {}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user