Skip to content

Commit 6b267bd

Browse files
authored
feat: add direct fleet registration option (#1878)
1 parent 2a39b0b commit 6b267bd

File tree

52 files changed

+225
-0
lines changed

Some content is hidden

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

52 files changed

+225
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Then perform the following commands on the root folder:
167167
| filestore\_csi\_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | `bool` | `false` | no |
168168
| 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 |
169169
| firewall\_priority | Priority rule for firewall rules | `number` | `1000` | no |
170+
| fleet\_project | (Optional) Register the cluster with the fleet in this project. | `string` | `null` | no |
170171
| gateway\_api\_channel | The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`. | `string` | `null` | no |
171172
| gce\_pd\_csi\_driver | Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | `bool` | `true` | no |
172173
| gcs\_fuse\_csi\_driver | Whether GCE FUSE CSI driver is enabled for this cluster. | `bool` | `false` | no |
@@ -239,6 +240,7 @@ Then perform the following commands on the root folder:
239240
| ca\_certificate | Cluster ca certificate (base64 encoded) |
240241
| cluster\_id | Cluster ID |
241242
| endpoint | Cluster endpoint |
243+
| fleet\_membership | Fleet membership (if registered) |
242244
| gateway\_api\_channel | The gateway api channel of this cluster. |
243245
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |
244246
| http\_load\_balancing\_enabled | Whether http load balancing enabled |

autogen/main/cluster.tf.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,13 @@ resource "google_container_cluster" "primary" {
347347
vulnerability_mode = var.security_posture_vulnerability_mode
348348
}
349349

350+
dynamic "fleet" {
351+
for_each = var.fleet_project != null ? [1] : []
352+
content {
353+
project = var.fleet_project
354+
}
355+
}
356+
350357
ip_allocation_policy {
351358
cluster_secondary_range_name = var.ip_range_pods
352359
services_secondary_range_name = var.ip_range_services

autogen/main/main.tf.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ locals {
6060
windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools)))
6161
{% endif %}
6262

63+
fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null
64+
6365
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
6466
gateway_api_config = var.gateway_api_channel != null ? [{ channel : var.gateway_api_channel }] : []
6567

autogen/main/outputs.tf.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,8 @@ output "identity_service_enabled" {
234234
value = local.cluster_pod_security_policy_enabled
235235
}
236236
{% endif %}
237+
238+
output "fleet_membership" {
239+
description = "Fleet membership (if registered)"
240+
value = local.fleet_membership
241+
}

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,3 +857,9 @@ variable "allow_net_admin" {
857857
default = null
858858
}
859859
{% endif %}
860+
861+
variable "fleet_project" {
862+
description = "(Optional) Register the cluster with the fleet in this project."
863+
type = string
864+
default = null
865+
}

cluster.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ resource "google_container_cluster" "primary" {
231231
vulnerability_mode = var.security_posture_vulnerability_mode
232232
}
233233

234+
dynamic "fleet" {
235+
for_each = var.fleet_project != null ? [1] : []
236+
content {
237+
project = var.fleet_project
238+
}
239+
}
240+
234241
ip_allocation_policy {
235242
cluster_secondary_range_name = var.ip_range_pods
236243
services_secondary_range_name = var.ip_range_services

examples/simple_regional/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ module "gke" {
4343
enable_cost_allocation = true
4444
enable_binary_authorization = var.enable_binary_authorization
4545
gcs_fuse_csi_driver = true
46+
fleet_project = var.project_id
4647
deletion_protection = false
4748
}

examples/simple_zonal_with_hub/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ It incorporates the standard cluster module, the [registration module](../../mod
2323
| ca\_certificate | n/a |
2424
| client\_token | n/a |
2525
| cluster\_name | Cluster name |
26+
| hub\_location | The location of the hub membership. |
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 |

examples/simple_zonal_with_hub/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,8 @@ output "master_kubernetes_version" {
7979
description = "The master Kubernetes version"
8080
value = module.gke.master_version
8181
}
82+
83+
output "hub_location" {
84+
description = "The location of the hub membership."
85+
value = module.hub.location
86+
}

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ locals {
5454
windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name]
5555
windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools)))
5656

57+
fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null
58+
5759
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
5860
gateway_api_config = var.gateway_api_channel != null ? [{ channel : var.gateway_api_channel }] : []
5961

0 commit comments

Comments
 (0)