Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use terraform resource to activate Anthos Service Mesh #1097

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,6 @@
set_fact:
context: "gke_{{ project_id }}_{{ region }}_{{ cluster }}"

- name: Install ASM in cluster
shell: >
gcloud container fleet mesh update \
--control-plane automatic \
--memberships {{ cluster }} \
--project {{ project_id }}

- name: Wait until MCP is provisioned
shell: >
for i in $(seq 12); do
result=$(gcloud container fleet mesh describe --project {{ project_id }} --format json \
| jq -r '.membershipStates | to_entries[] | select(.key | endswith("{{ cluster }}")) | .value.servicemesh.controlPlaneManagement.state')
if [ "$result" = "ACTIVE" ]; then
break
fi
echo "ASM control plane is not ready yet..."
sleep 60
done

- name: Get endpoint IP
shell: >
gcloud container clusters describe "{{ cluster }}" \
Expand Down
2 changes: 1 addition & 1 deletion blueprints/gke/multitenant-fleet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ module "gke" {
}
}

# tftest modules=8 resources=35
# tftest modules=8 resources=37
```

<!-- TFDOC OPTS files:1 -->
Expand Down
2 changes: 1 addition & 1 deletion modules/gke-hub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ module "hub" {
]
}

# tftest modules=8 resources=28
# tftest modules=8 resources=30
```
<!-- BEGIN TFDOC -->

Expand Down
14 changes: 14 additions & 0 deletions modules/gke-hub/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ resource "google_gke_hub_feature" "default" {
}
}

resource "google_gke_hub_feature_membership" "servicemesh" {
provider = google-beta
for_each = var.features.servicemesh ? var.clusters : {}
project = var.project_id
location = "global"
juliocc marked this conversation as resolved.
Show resolved Hide resolved
feature = google_gke_hub_feature.default["servicemesh"].name
membership = google_gke_hub_membership.default[each.key].membership_id

mesh {
management = "MANAGEMENT_AUTOMATIC"
control_plane = "AUTOMATIC"
}
}

resource "google_gke_hub_feature_membership" "default" {
provider = google-beta
for_each = local.cluster_cm_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_resources(e2e_plan_runner):
"Test that plan works and the numbers of resources is as expected."
modules, resources = e2e_plan_runner()
assert len(modules) == 12
assert len(resources) == 53
assert len(resources) == 55
2 changes: 1 addition & 1 deletion tests/modules/gke_hub/fixture/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ variable "features" {
configmanagement = true
identityservice = false
multiclusteringress = null
servicemesh = false
servicemesh = true
juliocc marked this conversation as resolved.
Show resolved Hide resolved
multiclusterservicediscovery = false
}
}
Expand Down
5 changes: 4 additions & 1 deletion tests/modules/gke_hub/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ def resources(plan_runner):

def test_resource_count(resources):
"Test number of resources created."
assert len(resources) == 5
assert len(resources) == 8
assert sorted(r['address'] for r in resources) == [
'module.hub.google_gke_hub_feature.default["configmanagement"]',
'module.hub.google_gke_hub_feature.default["servicemesh"]',
'module.hub.google_gke_hub_feature_membership.default["cluster-1"]',
'module.hub.google_gke_hub_feature_membership.default["cluster-2"]',
'module.hub.google_gke_hub_feature_membership.servicemesh["cluster-1"]',
'module.hub.google_gke_hub_feature_membership.servicemesh["cluster-2"]',
'module.hub.google_gke_hub_membership.default["cluster-1"]',
'module.hub.google_gke_hub_membership.default["cluster-2"]'
]
Expand Down