Skip to content

Commit 5c1b682

Browse files
author
Sam Naser
committed
add options for fleet registration and feature enablement
1 parent ca76162 commit 5c1b682

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
lines changed

docs/upgrading_to_v20.0.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ an installation performed with the old module to using the new module. **NOTE:**
1717
There should be two ASM revisions present at this point (in-cluster or managed, depending on whether the previous installation was managed). Now,
1818
we must perform a canary upgrade to move workloads onto the new ASM revision. To do this:
1919

20-
1. Relabel namespaces to use the revision label from the managed revision (either `asm-managed`, `asm-managed-stable`, or `asm-managed-rapid`)
20+
1. Relabel namespaces to use the revision label from the managed revision (`asm-managed`, `asm-managed-stable`, or `asm-managed-rapid`)
2121
2. Rollout workloads in those namespaces to get them onto the new ASM version
2222
3. [Optional] Remove the previous revision with `istioctl x uninstall --revision ...` (if the previous installation was in-cluster)
2323

2424

2525
#### Migrating options
2626

27-
Another difference from the previous module is that the new ASM module does not provide variables option configuration (i.e. `custom_overlay`, `options`). These should be managed separately
27+
Another difference from the previous module is that the new ASM module does not provide variables for option configuration (e.g. `custom_overlay`, `options`). For the new version these should be managed separately
2828
outside the module. This is because those options were tightly coupled to pulling down an installer which the new module does not do. To use options specified in the previous module with the new module find the corresponding configuration [here](https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages/tree/main/asm/istio/options) and move the
29-
config to the mesh configuration for the revision.
29+
config to the mesh configuration for the managed revision.

modules/asm/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ To deploy this config:
3535
| cluster\_location | The cluster location for this ASM installation. | `string` | n/a | yes |
3636
| cluster\_name | The unique name to identify the cluster in ASM. | `string` | n/a | yes |
3737
| enable\_cni | Determines whether to enable CNI for this ASM installation. Required to use Managed Data Plane (MDP). | `bool` | `false` | no |
38+
| enable\_fleet\_registration | Determines whether the module enables the mesh feature on the fleet. | `bool` | `false` | no |
39+
| enable\_mesh\_feature | Determines whether the module registers the cluster to the fleet. | `bool` | `false` | no |
3840
| enable\_vpc\_sc | Determines whether to enable VPC-SC for this ASM installation. For more information read https://cloud.google.com/service-mesh/docs/managed/vpc-sc | `bool` | `false` | no |
3941
| fleet\_id | The fleet to use for this ASM installation. | `string` | `""` | no |
4042
| multicluster\_mode | [Preview] Determines whether remote secrets should be autogenerated across fleet cluster. | `string` | `"manual"` | no |

modules/asm/hub.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright 2022 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+
resource "google_gke_hub_membership" "membership" {
18+
count = var.enable_fleet_registration ? 1 : 0
19+
provider = google-beta
20+
project = var.project_id
21+
membership_id = "${data.google_container_cluster.asm.name}-membership"
22+
endpoint {
23+
gke_cluster {
24+
resource_link = "//container.googleapis.com/${data.google_container_cluster.asm.id}"
25+
}
26+
}
27+
}
28+
29+
resource "google_gke_hub_feature" "mesh" {
30+
count = var.enable_mesh_feature ? 1 : 0
31+
name = "servicemesh"
32+
project = var.project_id
33+
location = "global"
34+
provider = google-beta
35+
}

modules/asm/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ resource "kubernetes_config_map" "asm_options" {
4646
data = {
4747
multicluster_mode = var.multicluster_mode
4848
}
49+
50+
depends_on = [google_gke_hub_membership.membership, google_gke_hub_feature.mesh]
4951
}
5052

5153
module "cpr" {

modules/asm/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,15 @@ variable "enable_vpc_sc" {
7474
type = bool
7575
default = false
7676
}
77+
78+
variable "enable_fleet_registration" {
79+
description = "Determines whether the module enables the mesh feature on the fleet."
80+
type = bool
81+
default = false
82+
}
83+
84+
variable "enable_mesh_feature" {
85+
description = "Determines whether the module registers the cluster to the fleet."
86+
type = bool
87+
default = false
88+
}

0 commit comments

Comments
 (0)