-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added network for INTERNAL_SELF_MANAGED load balancing schema (#…
…320)
- Loading branch information
1 parent
e9da266
commit 7226353
Showing
15 changed files
with
258 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# External HTTPS Load Balancer with dynamic backends | ||
|
||
[![button](http://gstatic.com/cloudssh/images/open-btn.png)](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/terraform-google-lb-http&working_dir=examples/dynamic-backend&page=shell&tutorial=README.md) | ||
|
||
This creates an external Envoy-based HTTPS Load Balancer using dynamic | ||
backends suitable for integrating with a Google Kubernetes Engine cluster | ||
running [gke-autoneg-controller](https://github.com/GoogleCloudPlatform/gke-autoneg-controller). | ||
The load balancer will not route traffic to any backend service or bucket; | ||
instead, it expects that an external user or service will register backends | ||
(such as Network Endpoint Groups) accordingly to serve traffic. The example | ||
will attempt to provision a Google-managed TLS certificate for the domain | ||
"example.com" by default and use `/api/health` as a health check endpoint. | ||
|
||
## Change to the example directory | ||
|
||
``` | ||
[[ `basename $PWD` != https-gke ]] && cd examples/dynamic-backend | ||
``` | ||
|
||
## Install Terraform | ||
|
||
1. Install Terraform if it is not already installed (visit [terraform.io](https://terraform.io) for other distributions): | ||
|
||
## Set up the environment | ||
|
||
1. Set the project, replace `YOUR_PROJECT` with your project ID: | ||
|
||
``` | ||
PROJECT=YOUR_PROJECT | ||
``` | ||
|
||
``` | ||
gcloud config set project ${PROJECT} | ||
``` | ||
|
||
2. Configure the environment for Terraform: | ||
|
||
``` | ||
[[ $CLOUD_SHELL ]] || gcloud auth application-default login | ||
export GOOGLE_PROJECT=$(gcloud config get-value project) | ||
``` | ||
|
||
3. Create the dynamic backend load balancer. | ||
|
||
``` | ||
( | ||
cd dynamic-backend/ | ||
terraform init | ||
terraform plan -out terraform.tfplan | ||
terraform apply terraform.tfplan | ||
) | ||
``` | ||
|
||
4. Deploy the `gke-autoneg-controller` into a GKE cluster and configure it according to the instructions. This will create a Network Endpoint Group for a service and bind it to this load balancer. | ||
|
||
|
||
## Cleanup | ||
|
||
1. Delete the load balancing resources created by terraform: | ||
|
||
``` | ||
terraform destroy | ||
``` | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| network\_name | n/a | `string` | `"traffic-director-lb"` | no | | ||
| project\_id | n/a | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
No output. | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
provider "google" { | ||
project = var.project_id | ||
} | ||
|
||
provider "google-beta" { | ||
project = var.project_id | ||
} | ||
|
||
resource "google_compute_network" "default" { | ||
name = var.network_name | ||
auto_create_subnetworks = true | ||
} | ||
|
||
module "load_balancer" { | ||
source = "../../" | ||
|
||
name = "traffic-director-lb" | ||
project = var.project_id | ||
create_address = false | ||
|
||
load_balancing_scheme = "INTERNAL_SELF_MANAGED" | ||
network = google_compute_network.default.self_link | ||
address = "0.0.0.0" | ||
firewall_networks = [] | ||
|
||
backends = { | ||
default = { | ||
description = null | ||
protocol = "HTTP" | ||
port = 80 | ||
port_name = "http" | ||
timeout_sec = 30 | ||
connection_draining_timeout_sec = 0 | ||
enable_cdn = false | ||
edge_security_policy = null | ||
security_policy = null | ||
session_affinity = null | ||
affinity_cookie_ttl_sec = null | ||
custom_request_headers = null | ||
custom_response_headers = null | ||
compression_mode = null | ||
|
||
health_check = { | ||
check_interval_sec = 15 | ||
timeout_sec = 15 | ||
healthy_threshold = 4 | ||
unhealthy_threshold = 4 | ||
request_path = "/api/health" | ||
port = 443 | ||
host = null | ||
logging = true | ||
} | ||
|
||
log_config = { | ||
enable = false | ||
sample_rate = null | ||
} | ||
|
||
# leave blank, NEGs are dynamically added to the lb via autoneg | ||
groups = [] | ||
|
||
iap_config = { | ||
enable = false | ||
oauth2_client_id = "" | ||
oauth2_client_secret = "" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "project_id" { | ||
type = string | ||
} | ||
|
||
variable "network_name" { | ||
default = "traffic-director-lb" | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.