Skip to content

Commit 5235884

Browse files
author
Sam Naser
committed
Revert changes to examples
1 parent 56240f1 commit 5235884

File tree

4 files changed

+133
-35
lines changed

4 files changed

+133
-35
lines changed

examples/simple_zonal_with_asm/hub.tf

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,10 @@
1717
resource "google_gke_hub_membership" "cluster_membership" {
1818
provider = google-beta
1919
project = var.project_id
20-
membership_id = "${google_container_cluster.primary.name}-membership"
20+
membership_id = "${module.gke.name}-membership"
2121
endpoint{
2222
gke_cluster {
23-
resource_link = "//container.googleapis.com/${google_container_cluster.primary.id}"
23+
resource_link = "//container.googleapis.com/${module.gke.cluster_id}"
2424
}
2525
}
2626
}
27-
# enable Anthos Configmanagement feature on the project.
28-
resource "google_gke_hub_feature" "mesh_feature" {
29-
name = "servicemesh"
30-
project = var.project_id
31-
location = "global"
32-
provider = google-beta
33-
}

examples/simple_zonal_with_asm/main.tf

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,45 @@ locals {
2121
data "google_client_config" "default" {}
2222

2323
provider "kubernetes" {
24-
host = "https://${google_container_cluster.primary.endpoint}"
24+
host = "https://${module.gke.endpoint}"
2525
token = data.google_client_config.default.access_token
26-
cluster_ca_certificate = base64decode(google_container_cluster.primary.master_auth[0].cluster_ca_certificate)
26+
cluster_ca_certificate = base64decode(module.gke.ca_certificate)
2727
}
2828

2929
data "google_project" "project" {
3030
project_id = var.project_id
3131
}
3232

33-
resource "google_container_cluster" "primary" {
34-
name = "drew-barrymore"
35-
project = var.project_id
36-
location = "us-central1-a"
37-
initial_node_count = 3
38-
workload_identity_config {
39-
identity_namespace = "${var.project_id}.svc.id.goog"
40-
}
41-
node_config {
42-
# Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles.
43-
oauth_scopes = [
44-
"https://www.googleapis.com/auth/cloud-platform"
45-
]
46-
labels = {
47-
foo = "bar"
48-
}
49-
tags = ["foo", "bar"]
50-
}
51-
timeouts {
52-
create = "30m"
53-
update = "40m"
54-
}
33+
module "gke" {
34+
source = "../../"
35+
project_id = var.project_id
36+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
37+
regional = false
38+
region = var.region
39+
zones = var.zones
40+
release_channel = "REGULAR"
41+
network = var.network
42+
subnetwork = var.subnetwork
43+
ip_range_pods = var.ip_range_pods
44+
ip_range_services = var.ip_range_services
45+
network_policy = false
46+
cluster_resource_labels = { "mesh_id" : "proj-${data.google_project.project.number}" }
47+
node_pools = [
48+
{
49+
name = "asm-node-pool"
50+
autoscaling = false
51+
auto_upgrade = true
52+
# ASM requires minimum 4 nodes and e2-standard-4
53+
node_count = 4
54+
machine_type = "e2-standard-4"
55+
},
56+
]
5557
}
5658

5759
module "asm" {
5860
source = "../../modules/asm"
61+
cluster_name = module.gke.name
62+
cluster_location = module.gke.location
5963
project_id = var.project_id
60-
cluster_name = google_container_cluster.primary.name
61-
cluster_location = google_container_cluster.primary.location
64+
location = module.gke.location
6265
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright 2018 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+
output "kubernetes_endpoint" {
18+
sensitive = true
19+
value = module.gke.endpoint
20+
}
21+
22+
output "client_token" {
23+
sensitive = true
24+
value = base64encode(data.google_client_config.default.access_token)
25+
}
26+
27+
output "ca_certificate" {
28+
sensitive = true
29+
value = module.gke.ca_certificate
30+
}
31+
32+
output "service_account" {
33+
description = "The default service account used for running nodes."
34+
value = module.gke.service_account
35+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Copyright 2018 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+
// These outputs are used to test the module with kitchen-terraform
18+
// They do not need to be included in real-world uses of this module
19+
20+
output "project_id" {
21+
value = var.project_id
22+
}
23+
24+
output "region" {
25+
value = module.gke.region
26+
}
27+
28+
output "cluster_name" {
29+
description = "Cluster name"
30+
value = module.gke.name
31+
}
32+
33+
output "network" {
34+
value = var.network
35+
}
36+
37+
output "subnetwork" {
38+
value = var.subnetwork
39+
}
40+
41+
output "location" {
42+
value = module.gke.location
43+
}
44+
45+
output "ip_range_pods" {
46+
description = "The secondary IP range used for pods"
47+
value = var.ip_range_pods
48+
}
49+
50+
output "ip_range_services" {
51+
description = "The secondary IP range used for services"
52+
value = var.ip_range_services
53+
}
54+
55+
output "zones" {
56+
description = "List of zones in which the cluster resides"
57+
value = module.gke.zones
58+
}
59+
60+
output "master_kubernetes_version" {
61+
description = "The master Kubernetes version"
62+
value = module.gke.master_version
63+
}
64+
65+
output "identity_namespace" {
66+
value = module.gke.identity_namespace
67+
}

0 commit comments

Comments
 (0)