Skip to content

Commit 007fbca

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

File tree

6 files changed

+33
-13
lines changed

6 files changed

+33
-13
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.

examples/simple_zonal_with_asm/main.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ module "gke" {
5757
}
5858

5959
module "asm" {
60-
source = "../../modules/asm"
61-
project_id = var.project_id
62-
cluster_name = module.gke.name
63-
cluster_location = module.gke.location
64-
multicluster_mode = "connected"
65-
enable_cni = true
60+
source = "../../modules/asm"
61+
project_id = var.project_id
62+
cluster_name = module.gke.name
63+
cluster_location = module.gke.location
64+
multicluster_mode = "connected"
65+
enable_cni = true
66+
enable_fleet_registration = true
67+
enable_mesh_feature = true
6668
}

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 |

examples/simple_zonal_with_asm/hub.tf renamed to modules/asm/hub.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2022 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,18 +14,20 @@
1414
* limitations under the License.
1515
*/
1616

17-
resource "google_gke_hub_membership" "cluster_membership" {
17+
resource "google_gke_hub_membership" "membership" {
18+
count = var.enable_fleet_registration ? 1 : 0
1819
provider = google-beta
1920
project = var.project_id
20-
membership_id = "gke-asm-membership"
21+
membership_id = "${data.google_container_cluster.asm.name}-membership"
2122
endpoint {
2223
gke_cluster {
23-
resource_link = "//container.googleapis.com/${module.gke.cluster_id}"
24+
resource_link = "//container.googleapis.com/${data.google_container_cluster.asm.id}"
2425
}
2526
}
2627
}
2728

2829
resource "google_gke_hub_feature" "mesh" {
30+
count = var.enable_mesh_feature ? 1 : 0
2931
name = "servicemesh"
3032
project = var.project_id
3133
location = "global"

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)