Skip to content

Commit ae268bd

Browse files
yliaogapeabody
andauthored
feat: added multiclusteringress hub feature for use by multiclustergateway (#24)
Co-authored-by: Andrew Peabody <[email protected]>
1 parent 2406aaa commit ae268bd

File tree

8 files changed

+47
-9
lines changed

8 files changed

+47
-9
lines changed

2-multitenant/modules/env_baseline/main.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ module "eab_fleet_project" {
6060
activate_apis = [
6161
"gkehub.googleapis.com",
6262
"anthos.googleapis.com",
63-
"compute.googleapis.com"
63+
"compute.googleapis.com",
64+
"multiclusteringress.googleapis.com",
65+
"multiclusterservicediscovery.googleapis.com"
6466
]
6567
}
6668

4-fleetscope/envs/development/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module "env" {
2525
source = "../../modules/env_baseline"
2626

2727
env = local.env
28-
project_id = var.fleet_project_id
28+
fleet_project_id = var.fleet_project_id
2929
scope_id = local.scope_id
3030
cluster_membership_ids = var.cluster_membership_ids
3131
namespace_id = local.namespace_id

4-fleetscope/envs/non-production/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module "env" {
2525
source = "../../modules/env_baseline"
2626

2727
env = local.env
28-
project_id = var.fleet_project_id
28+
fleet_project_id = var.fleet_project_id
2929
scope_id = local.scope_id
3030
cluster_membership_ids = var.cluster_membership_ids
3131
namespace_id = local.namespace_id

4-fleetscope/envs/production/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module "env" {
2525
source = "../../modules/env_baseline"
2626

2727
env = local.env
28-
project_id = var.fleet_project_id
28+
fleet_project_id = var.fleet_project_id
2929
scope_id = local.scope_id
3030
cluster_membership_ids = var.cluster_membership_ids
3131
namespace_id = local.namespace_id

4-fleetscope/modules/env_baseline/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ The following resources are created:
1313
|------|-------------|------|---------|:--------:|
1414
| cluster\_membership\_ids | The membership IDs in the scope | `list(string)` | n/a | yes |
1515
| env | The environment to prepare (ex. development) | `string` | n/a | yes |
16+
| fleet\_project\_id | The fleet project ID | `string` | n/a | yes |
1617
| namespace\_id | The fleet namespace ID | `string` | n/a | yes |
17-
| project\_id | The fleet project ID | `string` | n/a | yes |
1818
| scope\_id | The fleet scope ID | `string` | n/a | yes |
1919

2020
## Outputs

4-fleetscope/modules/env_baseline/main.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ resource "random_string" "suffix" {
2626

2727
resource "google_gke_hub_scope" "fleet-scope" {
2828
scope_id = "${var.scope_id}-${var.env}"
29-
project = var.project_id
29+
project = var.fleet_project_id
3030
}
3131

3232
resource "google_gke_hub_namespace" "fleet-ns" {
3333
scope_namespace_id = "${var.namespace_id}-${var.env}"
3434
scope_id = google_gke_hub_scope.fleet-scope.scope_id
3535
scope = google_gke_hub_scope.fleet-scope.name
36-
project = var.project_id
36+
project = var.fleet_project_id
3737
}
3838

3939
resource "google_gke_hub_membership_binding" "membership-binding" {
@@ -43,5 +43,5 @@ resource "google_gke_hub_membership_binding" "membership-binding" {
4343
scope = google_gke_hub_scope.fleet-scope.name
4444
membership_id = regex(local.membership_re, each.key)[2]
4545
location = regex(local.membership_re, each.key)[1]
46-
project = var.project_id
46+
project = var.fleet_project_id
4747
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright 2024 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+
fleet_membership_re = "//gkehub.googleapis.com/(.*)$"
19+
}
20+
21+
resource "google_gke_hub_feature" "mci" {
22+
name = "multiclusteringress"
23+
location = "global"
24+
project = var.fleet_project_id
25+
spec {
26+
multiclusteringress {
27+
config_membership = regex(local.fleet_membership_re, var.cluster_membership_ids[0])[0]
28+
}
29+
}
30+
}
31+
32+
resource "google_gke_hub_feature" "mcs" {
33+
name = "multiclusterservicediscovery"
34+
location = "global"
35+
project = var.fleet_project_id
36+
}

4-fleetscope/modules/env_baseline/variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ variable "env" {
1919
type = string
2020
}
2121

22-
variable "project_id" {
22+
variable "fleet_project_id" {
2323
description = "The fleet project ID"
2424
type = string
2525
}

0 commit comments

Comments
 (0)