Skip to content

Commit dd6a519

Browse files
committed
feat!: migrate ASM
1 parent d18755a commit dd6a519

File tree

22 files changed

+160
-893
lines changed

22 files changed

+160
-893
lines changed

build/int.cloudbuild.yaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -430,26 +430,6 @@ steps:
430430
- verify safer-cluster-iap-bastion-local
431431
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
432432
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy safer-cluster-iap-bastion-local']
433-
- id: init simple-zonal-with-asm-local
434-
waitFor:
435-
- create-all
436-
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
437-
args: ['/bin/bash', '-c', 'cft test run TestSimpleZonalWithASM --stage init --verbose']
438-
- id: apply simple-zonal-with-asm-local
439-
waitFor:
440-
- init simple-zonal-with-asm-local
441-
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
442-
args: ['/bin/bash', '-c', 'cft test run TestSimpleZonalWithASM --stage apply --verbose']
443-
- id: verify simple-zonal-with-asm-local
444-
waitFor:
445-
- apply simple-zonal-with-asm-local
446-
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
447-
args: ['/bin/bash', '-c', 'cft test run TestSimpleZonalWithASM --stage verify --verbose']
448-
- id: destroy simple-zonal-with-asm-local
449-
waitFor:
450-
- verify simple-zonal-with-asm-local
451-
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
452-
args: ['/bin/bash', '-c', 'cft test run TestSimpleZonalWithASM --stage teardown --verbose']
453433
- id: init simple-autopilot-private-local
454434
waitFor:
455435
- create-all

docs/upgrading_to_v35.0.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,45 @@ The v35.0 release of *kubernetes-engine* is a backwards incompatible release.
33

44
### Google Cloud Platform Provider upgrade
55
The Terraform Kubernetes Engine Module now requires version 6 of the Google Cloud Platform Providers. See the [Terraform Google Provider 6.0.0 Upgrade Guide](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/version_6_upgrade) for more details.
6+
7+
### ASM Sub-Module Removal
8+
The ASM Sub-Module has been removed in v35.0. Please use the [google_gke_hub_feature](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/gke_hub_feature#example-usage---enable-fleet-default-member-config-service-mesh) and [google_gke_hub_feature_membership](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/gke_hub_feature_membership#example-usage---service-mesh) resources.
9+
10+
11+
```
12+
- module "asm" {
13+
- source = "terraform-google-modules/kubernetes-engine/google//modules/asm"
14+
- version = "~> 34.0"
15+
16+
- project_id = var.project_id
17+
- cluster_name = module.gke.name
18+
- cluster_location = module.gke.location
19+
- multicluster_mode = "connected"
20+
- enable_cni = true
21+
- enable_fleet_registration = true
22+
- enable_mesh_feature = true
23+
- }
24+
25+
+ resource "google_gke_hub_feature" "mesh_feature" {
26+
+ project = var.project_id
27+
+ location = "global"
28+
+ name = "servicemesh"
29+
+ }
30+
31+
+ resource "google_gke_hub_feature_membership" "mesh_feature_membership" {
32+
+ project = var.project_id
33+
+ location = "global"
34+
35+
+ feature = "servicemesh"
36+
+ membership = module.gke.fleet_membership
37+
+ membership_location = module.gke.region
38+
39+
+ mesh {
40+
+ management = "MANAGEMENT_AUTOMATIC"
41+
+ }
42+
43+
+ depends_on = [
44+
+ google_gke_hub_feature.mesh_feature
45+
+ ]
46+
+ }
47+
```

examples/simple_zonal_with_asm/README.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,25 @@ This example illustrates how to create a simple zonal cluster with ASM.
77

88
| Name | Description | Type | Default | Required |
99
|------|-------------|------|---------|:--------:|
10-
| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes |
11-
| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes |
12-
| network | The VPC network to host the cluster in | `any` | n/a | yes |
13-
| project\_id | The project ID to host the cluster in | `any` | n/a | yes |
14-
| region | The region to host the cluster in | `any` | n/a | yes |
15-
| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes |
16-
| zones | The zone to host the cluster in (required if is a zonal cluster) | `list(string)` | n/a | yes |
10+
| enable\_fleet\_feature | Whether to enable the Mesh feature on the fleet. | `bool` | `true` | no |
11+
| mesh\_management | ASM Management mode. For more information, see the [gke\_hub\_feature\_membership resource documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/gke_hub_feature_membership#nested_mesh) | `string` | `"MANAGEMENT_AUTOMATIC"` | no |
12+
| project\_id | The project ID to host the cluster in | `string` | n/a | yes |
13+
| region | The region to host the cluster in | `string` | `"us-central1"` | no |
14+
| zone | The zone to host the cluster in (required if is a zonal cluster) | `string` | `"us-central1-a"` | no |
1715

1816
## Outputs
1917

2018
| Name | Description |
2119
|------|-------------|
22-
| ca\_certificate | n/a |
23-
| client\_token | n/a |
2420
| cluster\_name | Cluster name |
25-
| identity\_namespace | n/a |
2621
| ip\_range\_pods | The secondary IP range used for pods |
2722
| ip\_range\_services | The secondary IP range used for services |
28-
| kubernetes\_endpoint | n/a |
29-
| location | n/a |
30-
| master\_kubernetes\_version | The master Kubernetes version |
31-
| network | n/a |
32-
| project\_id | n/a |
33-
| region | n/a |
23+
| location | Cluster Location |
24+
| network | Network name |
25+
| project\_id | Project ID |
26+
| region | Cluster Region |
3427
| service\_account | The default service account used for running nodes. |
35-
| subnetwork | n/a |
28+
| subnetwork | Subnetwork name |
3629
| zones | List of zones in which the cluster resides |
3730

3831
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2024 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,19 +14,27 @@
1414
* limitations under the License.
1515
*/
1616

17-
variable "project_ids" {
18-
type = list(string)
19-
description = "The GCP projects to use for integration tests"
20-
}
17+
resource "google_gke_hub_feature" "mesh_feature" {
18+
name = "servicemesh"
19+
project = var.project_id
20+
location = "global"
2121

22-
variable "region" {
23-
description = "The GCP region to create and test resources in"
24-
default = "us-central1"
22+
count = var.enable_fleet_feature ? 1 : 0
2523
}
2624

27-
variable "zones" {
28-
type = list(string)
29-
description = "The GCP zones to create and test resources in, for applicable tests"
30-
default = ["us-central1-a", "us-central1-b", "us-central1-c"]
31-
}
25+
resource "google_gke_hub_feature_membership" "mesh_feature_membership" {
26+
project = var.project_id
27+
location = "global"
28+
29+
feature = "servicemesh"
30+
membership = module.gke.fleet_membership
31+
membership_location = module.gke.region
3232

33+
mesh {
34+
management = var.mesh_management
35+
}
36+
37+
depends_on = [
38+
google_gke_hub_feature.mesh_feature
39+
]
40+
}
Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2024 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,32 +14,23 @@
1414
* limitations under the License.
1515
*/
1616

17-
data "google_client_config" "default" {}
18-
19-
provider "kubernetes" {
20-
host = "https://${module.gke.endpoint}"
21-
token = data.google_client_config.default.access_token
22-
cluster_ca_certificate = base64decode(module.gke.ca_certificate)
23-
}
24-
25-
data "google_project" "project" {
26-
project_id = var.project_id
27-
}
28-
2917
module "gke" {
3018
source = "terraform-google-modules/kubernetes-engine/google"
3119
version = "~> 34.0"
3220

33-
project_id = var.project_id
34-
name = "test-prefix-cluster-test-suffix"
35-
regional = false
36-
region = var.region
37-
zones = var.zones
38-
release_channel = "REGULAR"
39-
network = var.network
40-
subnetwork = var.subnetwork
41-
ip_range_pods = var.ip_range_pods
42-
ip_range_services = var.ip_range_services
21+
project_id = var.project_id
22+
fleet_project = var.project_id
23+
name = "test-prefix-cluster-test-suffix"
24+
regional = false
25+
region = var.region
26+
zones = [var.zone]
27+
release_channel = "REGULAR"
28+
29+
network = google_compute_network.main.name
30+
subnetwork = google_compute_subnetwork.main.name
31+
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
32+
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
33+
4334
network_policy = false
4435
cluster_resource_labels = { "mesh_id" : "proj-${data.google_project.project.number}" }
4536
identity_namespace = "${var.project_id}.svc.id.goog"
@@ -54,17 +45,3 @@ module "gke" {
5445
},
5546
]
5647
}
57-
58-
module "asm" {
59-
source = "terraform-google-modules/kubernetes-engine/google//modules/asm"
60-
version = "~> 34.0"
61-
62-
project_id = var.project_id
63-
cluster_name = module.gke.name
64-
cluster_location = module.gke.location
65-
multicluster_mode = "connected"
66-
enable_cni = true
67-
enable_fleet_registration = true
68-
enable_mesh_feature = true
69-
70-
}

test/fixtures/simple_zonal_with_asm/network.tf renamed to examples/simple_zonal_with_asm/network.tf

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2021-2024 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.
@@ -20,16 +20,14 @@ resource "random_string" "suffix" {
2020
upper = false
2121
}
2222

23-
provider "google" {
24-
project = var.project_ids[2]
25-
}
26-
2723
resource "google_compute_network" "main" {
24+
project = var.project_id
2825
name = "cft-gke-test-${random_string.suffix.result}"
2926
auto_create_subnetworks = false
3027
}
3128

3229
resource "google_compute_subnetwork" "main" {
30+
project = var.project_id
3331
name = "cft-gke-test-${random_string.suffix.result}"
3432
ip_cidr_range = "10.0.0.0/17"
3533
region = var.region
Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2024 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,22 +14,53 @@
1414
* limitations under the License.
1515
*/
1616

17-
output "kubernetes_endpoint" {
18-
sensitive = true
19-
value = module.gke.endpoint
17+
output "service_account" {
18+
description = "The default service account used for running nodes."
19+
value = module.gke.service_account
2020
}
2121

22-
output "client_token" {
23-
sensitive = true
24-
value = base64encode(data.google_client_config.default.access_token)
22+
# Standard test outputs
23+
output "project_id" {
24+
description = "Project ID"
25+
value = var.project_id
2526
}
2627

27-
output "ca_certificate" {
28-
sensitive = true
29-
value = module.gke.ca_certificate
28+
output "region" {
29+
description = " Cluster Region"
30+
value = module.gke.region
3031
}
3132

32-
output "service_account" {
33-
description = "The default service account used for running nodes."
34-
value = module.gke.service_account
33+
output "cluster_name" {
34+
description = "Cluster name"
35+
value = module.gke.name
36+
}
37+
38+
output "network" {
39+
description = "Network name"
40+
value = google_compute_network.main.name
41+
}
42+
43+
output "subnetwork" {
44+
description = "Subnetwork name"
45+
value = google_compute_subnetwork.main.name
46+
}
47+
48+
output "location" {
49+
description = "Cluster Location"
50+
value = module.gke.location
51+
}
52+
53+
output "ip_range_pods" {
54+
description = "The secondary IP range used for pods"
55+
value = google_compute_subnetwork.main.secondary_ip_range[0].range_name
56+
}
57+
58+
output "ip_range_services" {
59+
description = "The secondary IP range used for services"
60+
value = google_compute_subnetwork.main.secondary_ip_range[1].range_name
61+
}
62+
63+
output "zones" {
64+
description = "List of zones in which the cluster resides"
65+
value = module.gke.zones
3566
}

0 commit comments

Comments
 (0)