Skip to content

Commit 4a97f90

Browse files
committed
add gateway api support
1 parent 1a79b7f commit 4a97f90

File tree

71 files changed

+612
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+612
-13
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ Then perform the following commands on the root folder:
155155
| filestore\_csi\_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | `bool` | `false` | no |
156156
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers. Either flag `add_master_webhook_firewall_rules` or `add_cluster_firewall_rules` (also adds egress rules) must be set to `true` for inbound-ports firewall rules to be applied. | `list(string)` | <pre>[<br> "8443",<br> "9443",<br> "15017"<br>]</pre> | no |
157157
| firewall\_priority | Priority rule for firewall rules | `number` | `1000` | no |
158+
| gateway\_api\_channel | The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`. | `string` | `null` | no |
158159
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer and artifactregistry.reader roles. | `bool` | `false` | no |
159160
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
160161
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
@@ -212,6 +213,7 @@ Then perform the following commands on the root folder:
212213
| ca\_certificate | Cluster ca certificate (base64 encoded) |
213214
| cluster\_id | Cluster ID |
214215
| endpoint | Cluster endpoint |
216+
| gateway\_api\_channel | The gateway api channel of this cluster. |
215217
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |
216218
| http\_load\_balancing\_enabled | Whether http load balancing enabled |
217219
| identity\_namespace | Workload Identity pool |

autogen/main/cluster.tf.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ resource "google_container_cluster" "primary" {
5353
channel = release_channel.value.channel
5454
}
5555
}
56+
57+
dynamic "release_channel" {
58+
for_each = local.gateway_api_channel
59+
60+
content {
61+
channel = gateway_api_channel.value.channel
62+
}
63+
}
64+
5665
dynamic "cost_management_config" {
5766
for_each = var.enable_cost_allocation ? [1] : []
5867
content {

autogen/main/main.tf.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ locals {
5757
{% endif %}
5858

5959
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
60+
gateway_api_channel = var.gateway_api_channel != null ? [{ channel : var.gateway_api_channel }] : []
6061

6162
{% if autopilot_cluster != true %}
6263
autoscaling_resource_limits = var.cluster_autoscaling.enabled ? concat([{

autogen/main/outputs.tf.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ output "release_channel" {
158158
value = var.release_channel
159159
}
160160

161+
output "gateway_api_channel" {
162+
description = "The gateway api channel of this cluster."
163+
value = var.gateway_api_channel
164+
}
165+
161166
output "identity_namespace" {
162167
description = "Workload Identity pool"
163168
value = length(local.cluster_workload_identity_config) > 0 ? local.cluster_workload_identity_config[0].workload_pool : null

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ variable "release_channel" {
444444
default = null
445445
}
446446

447+
variable "gateway_api_channel" {
448+
type = string
449+
description = "The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`."
450+
default = null
451+
}
452+
447453
variable "add_cluster_firewall_rules" {
448454
type = bool
449455
description = "Create additional firewall rules"

autogen/main/versions.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ terraform {
3838
required_providers {
3939
google = {
4040
source = "hashicorp/google"
41-
version = ">= 4.36.0, < 5.0"
41+
version = ">= 4.47.0, < 5.0"
4242
}
4343
kubernetes = {
4444
source = "hashicorp/kubernetes"

cluster.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ resource "google_container_cluster" "primary" {
4747
channel = release_channel.value.channel
4848
}
4949
}
50+
51+
dynamic "release_channel" {
52+
for_each = local.gateway_api_channel
53+
54+
content {
55+
channel = gateway_api_channel.value.channel
56+
}
57+
}
58+
5059
dynamic "cost_management_config" {
5160
for_each = var.enable_cost_allocation ? [1] : []
5261
content {

examples/deploy_service/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ It will:
2929
| ca\_certificate | n/a |
3030
| client\_token | n/a |
3131
| cluster\_name | Cluster name |
32+
| gateway\_api\_channel | The gateway api channel of this cluster |
3233
| ip\_range\_pods | The secondary IP range used for pods |
3334
| ip\_range\_services | The secondary IP range used for services |
3435
| kubernetes\_endpoint | n/a |

examples/disable_client_cert/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This example illustrates how to create a simple cluster and disable deprecated s
2727
| ca\_certificate | n/a |
2828
| client\_token | n/a |
2929
| cluster\_name | Cluster name |
30+
| gateway\_api\_channel | The gateway api channel of this cluster |
3031
| ip\_range\_pods | The secondary IP range used for pods |
3132
| ip\_range\_services | The secondary IP range used for services |
3233
| kubernetes\_endpoint | n/a |

examples/node_pool/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This example illustrates how to create a cluster with multiple custom node-pool
2525
| ca\_certificate | n/a |
2626
| client\_token | n/a |
2727
| cluster\_name | Cluster name |
28+
| gateway\_api\_channel | The gateway api channel of this cluster |
2829
| ip\_range\_pods | The secondary IP range used for pods |
2930
| ip\_range\_services | The secondary IP range used for services |
3031
| kubernetes\_endpoint | n/a |

examples/shared_vpc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This example illustrates how to create a simple cluster where the host network i
2424
| ca\_certificate | n/a |
2525
| client\_token | n/a |
2626
| cluster\_name | Cluster name |
27+
| gateway\_api\_channel | The gateway api channel of this cluster |
2728
| ip\_range\_pods | The secondary IP range used for pods |
2829
| ip\_range\_services | The secondary IP range used for services |
2930
| kubernetes\_endpoint | n/a |

examples/simple_regional/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This example illustrates how to create a simple cluster.
2525
| ca\_certificate | n/a |
2626
| client\_token | n/a |
2727
| cluster\_name | Cluster name |
28+
| gateway\_api\_channel | The gateway api channel of this cluster |
2829
| ip\_range\_pods | The secondary IP range used for pods |
2930
| ip\_range\_services | The secondary IP range used for services |
3031
| kubernetes\_endpoint | n/a |

examples/simple_regional_private/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This example illustrates how to create a simple private cluster.
2323
| ca\_certificate | n/a |
2424
| client\_token | n/a |
2525
| cluster\_name | Cluster name |
26+
| gateway\_api\_channel | The gateway api channel of this cluster |
2627
| ip\_range\_pods | The secondary IP range used for pods |
2728
| ip\_range\_services | The secondary IP range used for services |
2829
| kubernetes\_endpoint | n/a |
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Simple Regional Cluster
2+
3+
This example illustrates how to create a simple cluster.
4+
5+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6+
## Inputs
7+
8+
| Name | Description | Type | Default | Required |
9+
|------|-------------|------|---------|:--------:|
10+
| cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no |
11+
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes |
12+
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
13+
| gateway\_api\_channel | The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`. | `string` | n/a | yes |
14+
| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes |
15+
| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes |
16+
| network | The VPC network to host the cluster in | `any` | n/a | yes |
17+
| project\_id | The project ID to host the cluster in | `any` | n/a | yes |
18+
| region | The region to host the cluster in | `any` | n/a | yes |
19+
| skip\_provisioners | Flag to skip local-exec provisioners | `bool` | `false` | no |
20+
| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes |
21+
22+
## Outputs
23+
24+
| Name | Description |
25+
|------|-------------|
26+
| ca\_certificate | n/a |
27+
| client\_token | n/a |
28+
| cluster\_name | Cluster name |
29+
| gateway\_api\_channel | The gateway api channel of this cluster |
30+
| ip\_range\_pods | The secondary IP range used for pods |
31+
| ip\_range\_services | The secondary IP range used for services |
32+
| kubernetes\_endpoint | n/a |
33+
| location | n/a |
34+
| master\_kubernetes\_version | The master Kubernetes version |
35+
| network | n/a |
36+
| project\_id | n/a |
37+
| region | n/a |
38+
| service\_account | The default service account used for running nodes. |
39+
| subnetwork | n/a |
40+
| zones | List of zones in which the cluster resides |
41+
42+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
43+
44+
To provision this example, run the following from within this directory:
45+
- `terraform init` to get the plugins
46+
- `terraform plan` to see the infrastructure plan
47+
- `terraform apply` to apply the infrastructure build
48+
- `terraform destroy` to destroy the built infrastructure
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
locals {
18+
cluster_type = "simple-regional"
19+
}
20+
21+
data "google_client_config" "default" {}
22+
23+
provider "kubernetes" {
24+
host = "https://${module.gke.endpoint}"
25+
token = data.google_client_config.default.access_token
26+
cluster_ca_certificate = base64decode(module.gke.ca_certificate)
27+
}
28+
29+
module "gke" {
30+
source = "../../"
31+
project_id = var.project_id
32+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
33+
regional = true
34+
region = var.region
35+
network = var.network
36+
subnetwork = var.subnetwork
37+
ip_range_pods = var.ip_range_pods
38+
ip_range_services = var.ip_range_services
39+
create_service_account = false
40+
service_account = var.compute_engine_service_account
41+
enable_cost_allocation = true
42+
enable_binary_authorization = var.enable_binary_authorization
43+
skip_provisioners = var.skip_provisioners
44+
gateway_api_channel = var.gateway_api_channel
45+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
output "kubernetes_endpoint" {
18+
sensitive = true
19+
value = module.gke.endpoint
20+
}
21+
22+
output "client_token" {
23+
sensitive = true
24+
value = base64encode(data.google_client_config.default.access_token)
25+
}
26+
27+
output "ca_certificate" {
28+
value = module.gke.ca_certificate
29+
}
30+
31+
output "service_account" {
32+
description = "The default service account used for running nodes."
33+
value = module.gke.service_account
34+
}
35+
36+
output "gateway_api_channel" {
37+
description = "The gateway api channel of this cluster."
38+
value = module.gke.gateway_api_channel
39+
}
40+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test/fixtures/all_examples/test_outputs.tf
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
variable "project_id" {
18+
description = "The project ID to host the cluster in"
19+
}
20+
21+
variable "cluster_name_suffix" {
22+
description = "A suffix to append to the default cluster name"
23+
default = ""
24+
}
25+
26+
variable "region" {
27+
description = "The region to host the cluster in"
28+
}
29+
30+
variable "network" {
31+
description = "The VPC network to host the cluster in"
32+
}
33+
34+
variable "subnetwork" {
35+
description = "The subnetwork to host the cluster in"
36+
}
37+
38+
variable "ip_range_pods" {
39+
description = "The secondary ip range to use for pods"
40+
}
41+
42+
variable "ip_range_services" {
43+
description = "The secondary ip range to use for services"
44+
}
45+
46+
variable "compute_engine_service_account" {
47+
description = "Service account to associate to the nodes in the cluster"
48+
}
49+
50+
variable "skip_provisioners" {
51+
type = bool
52+
description = "Flag to skip local-exec provisioners"
53+
default = false
54+
}
55+
56+
variable "enable_binary_authorization" {
57+
description = "Enable BinAuthZ Admission controller"
58+
default = false
59+
}
60+
61+
variable "gateway_api_channel" {
62+
type = string
63+
description = "The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`."
64+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
terraform {
18+
required_providers {
19+
google = {
20+
source = "hashicorp/google"
21+
version = ">= 4.47.0"
22+
}
23+
kubernetes = {
24+
source = "hashicorp/kubernetes"
25+
}
26+
}
27+
required_version = ">= 0.13"
28+
}

examples/simple_zonal_private/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This example illustrates how to create a simple private cluster in a single zone
2424
| ca\_certificate | n/a |
2525
| client\_token | n/a |
2626
| cluster\_name | Cluster name |
27+
| gateway\_api\_channel | The gateway api channel of this cluster |
2728
| ip\_range\_pods | The secondary IP range used for pods |
2829
| ip\_range\_services | The secondary IP range used for services |
2930
| kubernetes\_endpoint | n/a |

examples/stub_domains/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ It will:
2828
| ca\_certificate | n/a |
2929
| client\_token | n/a |
3030
| cluster\_name | Cluster name |
31+
| gateway\_api\_channel | The gateway api channel of this cluster |
3132
| ip\_range\_pods | The secondary IP range used for pods |
3233
| ip\_range\_services | The secondary IP range used for services |
3334
| kubernetes\_endpoint | n/a |

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ locals {
5050
windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name]
5151
windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools)))
5252

53-
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
53+
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
54+
gateway_api_channel = var.gateway_api_channel != null ? [{ channel : var.gateway_api_channel }] : []
5455

5556
autoscaling_resource_limits = var.cluster_autoscaling.enabled ? concat([{
5657
resource_type = "cpu"

0 commit comments

Comments
 (0)