Support multiple protocols (L3_DEFAULT) through net-ilb-int
This commit is contained in:
parent
d9ab23a19e
commit
20dd3df27c
|
@ -14,6 +14,7 @@ One other issue is a `Provider produced inconsistent final plan` error which is
|
||||||
|
|
||||||
- [Referencing existing MIGs](#referencing-existing-migs)
|
- [Referencing existing MIGs](#referencing-existing-migs)
|
||||||
- [Externally managed instances](#externally-managed-instances)
|
- [Externally managed instances](#externally-managed-instances)
|
||||||
|
- [Passing multiple protocols through the load balancers](#passing-multiple-protocols-through-the-load-balancers)
|
||||||
- [End to end example](#end-to-end-example)
|
- [End to end example](#end-to-end-example)
|
||||||
|
|
||||||
### Referencing existing MIGs
|
### Referencing existing MIGs
|
||||||
|
@ -108,6 +109,38 @@ module "ilb" {
|
||||||
# tftest modules=1 resources=4
|
# tftest modules=1 resources=4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Passing multiple protocols through the load balancers
|
||||||
|
|
||||||
|
The example shows how to send multiple protocols through the same internal network passthrough load balancer.
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "ilb" {
|
||||||
|
source = "./fabric/modules/net-lb-int"
|
||||||
|
project_id = var.project_id
|
||||||
|
region = "europe-west1"
|
||||||
|
name = "ilb-test"
|
||||||
|
protocol = "L3_DEFAULT"
|
||||||
|
service_label = "ilb-test"
|
||||||
|
vpc_config = {
|
||||||
|
network = var.vpc.self_link
|
||||||
|
subnetwork = var.subnet.self_link
|
||||||
|
}
|
||||||
|
group_configs = {
|
||||||
|
my-group = {
|
||||||
|
zone = "europe-west1-b"
|
||||||
|
instances = [
|
||||||
|
"instance-1-self-link",
|
||||||
|
"instance-2-self-link"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
backends = [{
|
||||||
|
group = module.ilb.groups.my-group.self_link
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
# tftest modules=1 resources=4
|
||||||
|
```
|
||||||
|
|
||||||
### End to end example
|
### End to end example
|
||||||
|
|
||||||
This example spins up a simple HTTP server and combines four modules:
|
This example spins up a simple HTTP server and combines four modules:
|
||||||
|
@ -179,22 +212,22 @@ module "ilb" {
|
||||||
|
|
||||||
| name | description | type | required | default |
|
| name | description | type | required | default |
|
||||||
|---|---|:---:|:---:|:---:|
|
|---|---|:---:|:---:|:---:|
|
||||||
| [name](variables.tf#L188) | Name used for all resources. | <code>string</code> | ✓ | |
|
| [name](variables.tf#L189) | Name used for all resources. | <code>string</code> | ✓ | |
|
||||||
| [project_id](variables.tf#L199) | Project id where resources will be created. | <code>string</code> | ✓ | |
|
| [project_id](variables.tf#L200) | Project id where resources will be created. | <code>string</code> | ✓ | |
|
||||||
| [region](variables.tf#L210) | GCP region. | <code>string</code> | ✓ | |
|
| [region](variables.tf#L211) | GCP region. | <code>string</code> | ✓ | |
|
||||||
| [vpc_config](variables.tf#L221) | VPC-level configuration. | <code title="object({ network = string subnetwork = string })">object({…})</code> | ✓ | |
|
| [vpc_config](variables.tf#L222) | VPC-level configuration. | <code title="object({ network = string subnetwork = string })">object({…})</code> | ✓ | |
|
||||||
| [address](variables.tf#L17) | Optional IP address used for the forwarding rule. | <code>string</code> | | <code>null</code> |
|
| [address](variables.tf#L17) | Optional IP address used for the forwarding rule. | <code>string</code> | | <code>null</code> |
|
||||||
| [backend_service_config](variables.tf#L23) | Backend service level configuration. | <code title="object({ connection_draining_timeout_sec = optional(number) connection_tracking = optional(object({ idle_timeout_sec = optional(number) persist_conn_on_unhealthy = optional(string) track_per_session = optional(bool) })) enable_subsetting = optional(bool) failover_config = optional(object({ disable_conn_drain = optional(bool) drop_traffic_if_unhealthy = optional(bool) ratio = optional(number) })) log_sample_rate = optional(number) session_affinity = optional(string) timeout_sec = optional(number) })">object({…})</code> | | <code>{}</code> |
|
| [backend_service_config](variables.tf#L23) | Backend service level configuration. | <code title="object({ connection_draining_timeout_sec = optional(number) connection_tracking = optional(object({ idle_timeout_sec = optional(number) persist_conn_on_unhealthy = optional(string) track_per_session = optional(bool) })) enable_subsetting = optional(bool) failover_config = optional(object({ disable_conn_drain = optional(bool) drop_traffic_if_unhealthy = optional(bool) ratio = optional(number) })) log_sample_rate = optional(number) protocol = optional(string, "UNSPECIFIED") session_affinity = optional(string) timeout_sec = optional(number) })">object({…})</code> | | <code>{}</code> |
|
||||||
| [backends](variables.tf#L56) | Load balancer backends, balancing mode is one of 'CONNECTION' or 'UTILIZATION'. | <code title="list(object({ group = string balancing_mode = optional(string, "CONNECTION") description = optional(string, "Terraform managed.") failover = optional(bool, false) }))">list(object({…}))</code> | | <code>[]</code> |
|
| [backends](variables.tf#L57) | Load balancer backends, balancing mode is one of 'CONNECTION' or 'UTILIZATION'. | <code title="list(object({ group = string balancing_mode = optional(string, "CONNECTION") description = optional(string, "Terraform managed.") failover = optional(bool, false) }))">list(object({…}))</code> | | <code>[]</code> |
|
||||||
| [description](variables.tf#L75) | Optional description used for resources. | <code>string</code> | | <code>"Terraform managed."</code> |
|
| [description](variables.tf#L76) | Optional description used for resources. | <code>string</code> | | <code>"Terraform managed."</code> |
|
||||||
| [global_access](variables.tf#L81) | Global access, defaults to false if not set. | <code>bool</code> | | <code>null</code> |
|
| [global_access](variables.tf#L82) | Global access, defaults to false if not set. | <code>bool</code> | | <code>null</code> |
|
||||||
| [group_configs](variables.tf#L87) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | <code title="map(object({ zone = string description = optional(string, "Terraform managed.") instances = optional(list(string)) named_ports = optional(map(number), {}) }))">map(object({…}))</code> | | <code>{}</code> |
|
| [group_configs](variables.tf#L88) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | <code title="map(object({ zone = string description = optional(string, "Terraform managed.") instances = optional(list(string)) named_ports = optional(map(number), {}) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||||
| [health_check](variables.tf#L99) | Name of existing health check to use, disables auto-created health check. | <code>string</code> | | <code>null</code> |
|
| [health_check](variables.tf#L100) | Name of existing health check to use, disables auto-created health check. | <code>string</code> | | <code>null</code> |
|
||||||
| [health_check_config](variables.tf#L105) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | <code title="object({ check_interval_sec = optional(number) description = optional(string, "Terraform managed.") enable_logging = optional(bool, false) healthy_threshold = optional(number) timeout_sec = optional(number) unhealthy_threshold = optional(number) grpc = optional(object({ port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT service_name = optional(string) })) http = optional(object({ host = optional(string) port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request_path = optional(string) response = optional(string) })) http2 = optional(object({ host = optional(string) port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request_path = optional(string) response = optional(string) })) https = optional(object({ host = optional(string) port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request_path = optional(string) response = optional(string) })) tcp = optional(object({ port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request = optional(string) response = optional(string) })) ssl = optional(object({ port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request = optional(string) response = optional(string) })) })">object({…})</code> | | <code title="{ tcp = { port_specification = "USE_SERVING_PORT" } }">{…}</code> |
|
| [health_check_config](variables.tf#L106) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | <code title="object({ check_interval_sec = optional(number) description = optional(string, "Terraform managed.") enable_logging = optional(bool, false) healthy_threshold = optional(number) timeout_sec = optional(number) unhealthy_threshold = optional(number) grpc = optional(object({ port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT service_name = optional(string) })) http = optional(object({ host = optional(string) port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request_path = optional(string) response = optional(string) })) http2 = optional(object({ host = optional(string) port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request_path = optional(string) response = optional(string) })) https = optional(object({ host = optional(string) port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request_path = optional(string) response = optional(string) })) tcp = optional(object({ port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request = optional(string) response = optional(string) })) ssl = optional(object({ port = optional(number) port_name = optional(string) port_specification = optional(string) # USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT proxy_header = optional(string) request = optional(string) response = optional(string) })) })">object({…})</code> | | <code title="{ tcp = { port_specification = "USE_SERVING_PORT" } }">{…}</code> |
|
||||||
| [labels](variables.tf#L182) | Labels set on resources. | <code>map(string)</code> | | <code>{}</code> |
|
| [labels](variables.tf#L183) | Labels set on resources. | <code>map(string)</code> | | <code>{}</code> |
|
||||||
| [ports](variables.tf#L193) | Comma-separated ports, leave null to use all ports. | <code>list(string)</code> | | <code>null</code> |
|
| [ports](variables.tf#L194) | Comma-separated ports, leave null to use all ports. | <code>list(string)</code> | | <code>null</code> |
|
||||||
| [protocol](variables.tf#L204) | IP protocol used, defaults to TCP. | <code>string</code> | | <code>"TCP"</code> |
|
| [protocol](variables.tf#L205) | Forwarding rule protocol used, defaults to TCP. | <code>string</code> | | <code>"TCP"</code> |
|
||||||
| [service_label](variables.tf#L215) | Optional prefix of the fully qualified forwarding rule name. | <code>string</code> | | <code>null</code> |
|
| [service_label](variables.tf#L216) | Optional prefix of the fully qualified forwarding rule name. | <code>string</code> | | <code>null</code> |
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ resource "google_compute_forwarding_rule" "default" {
|
||||||
name = var.name
|
name = var.name
|
||||||
description = var.description
|
description = var.description
|
||||||
ip_address = var.address
|
ip_address = var.address
|
||||||
ip_protocol = var.protocol # TCP | UDP
|
ip_protocol = var.protocol
|
||||||
backend_service = (
|
backend_service = (
|
||||||
google_compute_region_backend_service.default.self_link
|
google_compute_region_backend_service.default.self_link
|
||||||
)
|
)
|
||||||
|
@ -54,7 +54,7 @@ resource "google_compute_region_backend_service" "default" {
|
||||||
name = var.name
|
name = var.name
|
||||||
description = var.description
|
description = var.description
|
||||||
load_balancing_scheme = "INTERNAL"
|
load_balancing_scheme = "INTERNAL"
|
||||||
protocol = var.protocol
|
protocol = var.backend_service_config.protocol
|
||||||
network = var.vpc_config.network
|
network = var.vpc_config.network
|
||||||
health_checks = [local.health_check]
|
health_checks = [local.health_check]
|
||||||
connection_draining_timeout_sec = var.backend_service_config.connection_draining_timeout_sec
|
connection_draining_timeout_sec = var.backend_service_config.connection_draining_timeout_sec
|
||||||
|
|
|
@ -36,6 +36,7 @@ variable "backend_service_config" {
|
||||||
ratio = optional(number)
|
ratio = optional(number)
|
||||||
}))
|
}))
|
||||||
log_sample_rate = optional(number)
|
log_sample_rate = optional(number)
|
||||||
|
protocol = optional(string, "UNSPECIFIED")
|
||||||
session_affinity = optional(string)
|
session_affinity = optional(string)
|
||||||
timeout_sec = optional(number)
|
timeout_sec = optional(number)
|
||||||
})
|
})
|
||||||
|
@ -202,7 +203,7 @@ variable "project_id" {
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "protocol" {
|
variable "protocol" {
|
||||||
description = "IP protocol used, defaults to TCP."
|
description = "Forwarding rule protocol used, defaults to TCP."
|
||||||
type = string
|
type = string
|
||||||
default = "TCP"
|
default = "TCP"
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ values:
|
||||||
name: ilb-test
|
name: ilb-test
|
||||||
network: default
|
network: default
|
||||||
project: my-project
|
project: my-project
|
||||||
protocol: TCP
|
protocol: UNSPECIFIED
|
||||||
region: europe-west1
|
region: europe-west1
|
||||||
|
|
||||||
counts:
|
counts:
|
||||||
|
|
Loading…
Reference in New Issue