Skip to content

Commit bb41b94

Browse files
committed
change test
Signed-off-by: drfaust92 <[email protected]>
1 parent de81273 commit bb41b94

File tree

17 files changed

+910
-39
lines changed

17 files changed

+910
-39
lines changed

examples/node_pool/main.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ module "gke" {
6161
logging_variant = "MAX_THROUGHPUT"
6262
dns_allow_external_traffic = true
6363

64-
additional_ip_ranges_config = [
65-
{
66-
subnetwork = "projects/${var.project_id}/regions/${var.region}/subnetworks/${var.additional_ip_pod_range_subnetwork}"
67-
pod_ipv4_range_names = [var.additional_ip_pod_range]
68-
}
69-
]
70-
7164
resource_manager_tags = {
7265
"${var.project_id}/${google_tags_tag_key.key.short_name}" = google_tags_tag_value.value.short_name
7366
}

examples/node_pool/test_outputs.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ output "ip_range_services" {
5252
value = var.ip_range_services
5353
}
5454

55-
output "additional_ip_range_pods" {
56-
description = "The secondary IP range used for pods in the additional range"
57-
value = var.additional_ip_pod_range
58-
}
59-
6055
output "zones" {
6156
description = "List of zones in which the cluster resides"
6257
value = module.gke.zones

examples/node_pool/variables.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ variable "ip_range_services" {
4848
description = "The secondary ip range to use for services"
4949
}
5050

51-
variable "additional_ip_pod_range_subnetwork" {
52-
description = "The subnetwork to host the additional pod range in"
53-
}
54-
55-
variable "additional_ip_pod_range" {
56-
description = "The secondary ip range to use for pods in the additional range"
57-
}
58-
5951
variable "compute_engine_service_account" {
6052
description = "Service account to associate to the nodes in the cluster"
6153
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Simple Regional Cluster
2+
3+
This example illustrates how to create a simple cluster.
4+
5+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6+
## Inputs
7+
8+
| Name | Description | Type | Default | Required |
9+
|------|-------------|------|---------|:--------:|
10+
| cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no |
11+
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes |
12+
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
13+
| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes |
14+
| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes |
15+
| network | The VPC network to host the cluster in | `any` | n/a | yes |
16+
| project\_id | The project ID to host the cluster in | `any` | n/a | yes |
17+
| region | The region to host the cluster in | `any` | n/a | yes |
18+
| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes |
19+
20+
## Outputs
21+
22+
| Name | Description |
23+
|------|-------------|
24+
| ca\_certificate | n/a |
25+
| client\_token | n/a |
26+
| cluster\_name | Cluster name |
27+
| ip\_range\_pods | The secondary IP range used for pods |
28+
| ip\_range\_services | The secondary IP range used for services |
29+
| kubernetes\_endpoint | n/a |
30+
| location | n/a |
31+
| master\_kubernetes\_version | The master Kubernetes version |
32+
| network | n/a |
33+
| project\_id | n/a |
34+
| region | n/a |
35+
| service\_account | The default service account used for running nodes. |
36+
| subnetwork | n/a |
37+
| zones | List of zones in which the cluster resides |
38+
39+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
40+
41+
To provision this example, run the following from within this directory:
42+
- `terraform init` to get the plugins
43+
- `terraform plan` to see the infrastructure plan
44+
- `terraform apply` to apply the infrastructure build
45+
- `terraform destroy` to destroy the built infrastructure
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
locals {
18+
cluster_type = "simple-regional"
19+
}
20+
21+
data "google_client_config" "default" {}
22+
23+
provider "kubernetes" {
24+
host = "https://${module.gke.endpoint}"
25+
token = data.google_client_config.default.access_token
26+
cluster_ca_certificate = base64decode(module.gke.ca_certificate)
27+
}
28+
29+
module "gke" {
30+
source = "terraform-google-modules/kubernetes-engine/google"
31+
version = "~> 41.0"
32+
33+
project_id = var.project_id
34+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
35+
regional = true
36+
region = var.region
37+
network = var.network
38+
subnetwork = var.subnetwork
39+
ip_range_pods = var.ip_range_pods
40+
ip_range_services = var.ip_range_services
41+
create_service_account = false
42+
service_account = var.compute_engine_service_account
43+
enable_cost_allocation = true
44+
deletion_protection = false
45+
46+
additional_ip_ranges_config = [
47+
{
48+
subnetwork = "projects/${var.project_id}/regions/${var.region}/subnetworks/${var.additional_ip_pod_range_subnetwork}"
49+
pod_ipv4_range_names = [var.additional_ip_pod_range]
50+
}
51+
]
52+
}
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+
value = module.gke.ca_certificate
29+
}
30+
31+
output "service_account" {
32+
description = "The default service account used for running nodes."
33+
value = module.gke.service_account
34+
}
35+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
variable "project_id" {
18+
description = "The project ID to host the cluster in"
19+
}
20+
21+
variable "cluster_name_suffix" {
22+
description = "A suffix to append to the default cluster name"
23+
default = ""
24+
}
25+
26+
variable "region" {
27+
description = "The region to host the cluster in"
28+
}
29+
30+
variable "network" {
31+
description = "The VPC network to host the cluster in"
32+
}
33+
34+
variable "subnetwork" {
35+
description = "The subnetwork to host the cluster in"
36+
}
37+
38+
variable "ip_range_pods" {
39+
description = "The secondary ip range to use for pods"
40+
}
41+
42+
variable "ip_range_services" {
43+
description = "The secondary ip range to use for services"
44+
}
45+
46+
variable "compute_engine_service_account" {
47+
description = "Service account to associate to the nodes in the cluster"
48+
}
49+
50+
variable "additional_ip_pod_range_subnetwork" {
51+
description = "The subnetwork to host the additional pod range in"
52+
}
53+
54+
variable "additional_ip_pod_range" {
55+
description = "The secondary ip range to use for pods in the additional range"
56+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright 2021 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+
terraform {
18+
required_providers {
19+
google = {
20+
source = "hashicorp/google"
21+
}
22+
kubernetes = {
23+
source = "hashicorp/kubernetes"
24+
}
25+
}
26+
required_version = ">= 0.13"
27+
}

test/fixtures/node_pool/network.tf

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,4 @@ resource "google_compute_subnetwork" "main" {
5050
ip_cidr_range = "172.16.0.0/18"
5151
}
5252
}
53-
54-
resource "google_compute_subnetwork" "secondary" {
55-
name = "cft-gke-test-2-${random_string.suffix.result}"
56-
ip_cidr_range = "10.1.0.0/17"
57-
region = "europe-west4"
58-
network = google_compute_network.main.self_link
59-
60-
secondary_ip_range {
61-
range_name = "test2"
62-
ip_cidr_range = "172.18.0.0/18"
63-
}
64-
}
53+

0 commit comments

Comments
 (0)