Skip to content

Commit a07548d

Browse files
authored
Merge branch 'master' into fix_ci_tests_node_pool_deploy_service
2 parents 3906c7b + 287eaa4 commit a07548d

File tree

29 files changed

+1059
-52
lines changed

29 files changed

+1059
-52
lines changed

.kitchen.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ suites:
5252
systems:
5353
- name: simple_regional
5454
backend: local
55+
- name: "simple_regional_with_networking"
56+
driver:
57+
root_module_directory: test/fixtures/simple_regional_with_networking
58+
verifier:
59+
systems:
60+
- name: simple_regional_with_networking
61+
backend: local
62+
controls:
63+
- gcloud
64+
- name: subnet
65+
backend: local
66+
controls:
67+
- subnet
68+
- name: network
69+
backend: gcp
70+
controls:
71+
- network
5572
- name: "simple_regional_private"
5673
driver:
5774
root_module_directory: test/fixtures/simple_regional_private
@@ -140,3 +157,10 @@ suites:
140157
controls:
141158
- gcloud
142159
- kubectl
160+
- name: "sandbox_enabled"
161+
driver:
162+
root_module_directory: test/fixtures/sandbox_enabled
163+
verifier:
164+
systems:
165+
- name: sandbox_enabled
166+
backend: local

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Extending the adopted spec, each change should have a link to its corresponding
88

99
## [Unreleased]
1010

11+
## [v5.1.1] - 2019-10-25
12+
13+
### Fixed
14+
15+
* Fixed bug with setting up sandboxing on nodes. [#286]
16+
1117
## [v5.1.0] - 2019-10-24
1218

1319
### Added
@@ -198,7 +204,8 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
198204

199205
* Initial release of module.
200206

201-
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v5.1.0...HEAD
207+
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v5.1.1...HEAD
208+
[v5.1.1]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v5.1.0...v5.1.1
202209
[v5.1.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v5.0.0...v5.1.0
203210
[v5.0.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v4.1.0...v5.0.0
204211
[v4.1.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v4.0.0...v4.1.0
@@ -214,6 +221,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
214221
[v0.3.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.2.0...v0.3.0
215222
[v0.2.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.1.0...v0.2.0
216223

224+
[#286]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/286
217225
[#285]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/285
218226
[#284]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/284
219227
[#282]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/282

autogen/cluster.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,6 @@ resource "google_container_cluster" "primary" {
167167
node_metadata = workload_metadata_config.value.node_metadata
168168
}
169169
}
170-
171-
dynamic "sandbox_config" {
172-
for_each = local.cluster_sandbox_enabled
173-
174-
content {
175-
sandbox_type = sandbox_config.value
176-
}
177-
}
178170
{% endif %}
179171
}
180172
}
@@ -407,6 +399,14 @@ resource "google_container_node_pool" "pools" {
407399
node_metadata = workload_metadata_config.value.node_metadata
408400
}
409401
}
402+
403+
dynamic "sandbox_config" {
404+
for_each = local.cluster_sandbox_enabled
405+
406+
content {
407+
sandbox_type = sandbox_config.value
408+
}
409+
}
410410
{% endif %}
411411
}
412412

build/int.cloudbuild.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,26 @@ steps:
101101
- verify simple-regional-private-local
102102
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
103103
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-private-local']
104+
- id: create simple-regional-with-networking-local
105+
waitFor:
106+
- prepare
107+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
108+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-regional-with-networking-local']
109+
- id: converge simple-regional-with-networking-local
110+
waitFor:
111+
- create simple-regional-with-networking-local
112+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
113+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-regional-with-networking-local']
114+
- id: verify simple-regional-with-networking-local
115+
waitFor:
116+
- converge simple-regional-with-networking-local
117+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
118+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-regional-with-networking-local']
119+
- id: destroy simple-regional-with-networking-local
120+
waitFor:
121+
- verify simple-regional-with-networking-local
122+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
123+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-with-networking-local']
104124
- id: create simple-zonal-local
105125
waitFor:
106126
- prepare
@@ -221,6 +241,26 @@ steps:
221241
- verify workload-metadata-config-local
222242
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
223243
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy workload-metadata-config-local']
244+
- id: create sandbox-enabled-local
245+
waitFor:
246+
- prepare
247+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
248+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create sandbox-enabled-local']
249+
- id: converge sandbox-enabled-local
250+
waitFor:
251+
- create sandbox-enabled-local
252+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
253+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge sandbox-enabled-local']
254+
- id: verify sandbox-enabled-local
255+
waitFor:
256+
- converge sandbox-enabled-local
257+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
258+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify sandbox-enabled-local']
259+
- id: destroy sandbox-enabled-local
260+
waitFor:
261+
- verify sandbox-enabled-local
262+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
263+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy sandbox-enabled-local']
224264
tags:
225265
- 'ci'
226266
- 'integration'

examples/simple_regional_beta/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22

33
This example illustrates how to create a simple cluster with beta features.
44

5-
[^]: (autogen_docs_start)
6-
5+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
76
## Inputs
87

98
| Name | Description | Type | Default | Required |
109
|------|-------------|:----:|:-----:|:-----:|
1110
| cloudrun | Boolean to enable / disable CloudRun | string | `"true"` | no |
1211
| cluster\_name\_suffix | A suffix to append to the default cluster name | string | `""` | no |
1312
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | string | n/a | yes |
14-
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
1513
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |
1614
| ip\_range\_services | The secondary ip range to use for pods | string | n/a | yes |
1715
| istio | Boolean to enable / disable Istio | string | `"true"` | no |
1816
| network | The VPC network to host the cluster in | string | n/a | yes |
17+
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | string | `"SECURE"` | no |
18+
| node\_pools | List of maps containing node pools | list(map(string)) | `<list>` | no |
1919
| project\_id | The project ID to host the cluster in | string | n/a | yes |
2020
| region | The region to host the cluster in | string | n/a | yes |
21+
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
22+
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it). | bool | `"false"` | no |
2123
| subnetwork | The subnetwork to host the cluster in | string | n/a | yes |
2224

2325
## Outputs
@@ -27,7 +29,6 @@ This example illustrates how to create a simple cluster with beta features.
2729
| ca\_certificate | |
2830
| client\_token | |
2931
| cluster\_name | Cluster name |
30-
| credentials\_path | |
3132
| ip\_range\_pods | The secondary IP range used for pods |
3233
| ip\_range\_services | The secondary IP range used for services |
3334
| kubernetes\_endpoint | |
@@ -36,11 +37,11 @@ This example illustrates how to create a simple cluster with beta features.
3637
| network | |
3738
| project\_id | |
3839
| region | |
39-
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
40+
| service\_account | The default service account used for running nodes. |
4041
| subnetwork | |
4142
| zones | List of zones in which the cluster resides |
4243

43-
[^]: (autogen_docs_end)
44+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4445

4546
To provision this example, run the following from within this directory:
4647
- `terraform init` to get the plugins

examples/simple_regional_beta/main.tf

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,23 @@ provider "google-beta" {
2424
}
2525

2626
module "gke" {
27-
source = "../../modules/beta-public-cluster/"
28-
project_id = var.project_id
29-
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
30-
regional = true
31-
region = var.region
32-
network = var.network
33-
subnetwork = var.subnetwork
34-
ip_range_pods = var.ip_range_pods
35-
ip_range_services = var.ip_range_services
36-
create_service_account = false
37-
service_account = var.compute_engine_service_account
38-
istio = var.istio
39-
cloudrun = var.cloudrun
27+
source = "../../modules/beta-public-cluster/"
28+
project_id = var.project_id
29+
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
30+
regional = true
31+
region = var.region
32+
network = var.network
33+
subnetwork = var.subnetwork
34+
ip_range_pods = var.ip_range_pods
35+
ip_range_services = var.ip_range_services
36+
create_service_account = false
37+
service_account = var.compute_engine_service_account
38+
istio = var.istio
39+
cloudrun = var.cloudrun
40+
node_metadata = var.node_metadata
41+
sandbox_enabled = var.sandbox_enabled
42+
remove_default_node_pool = var.remove_default_node_pool
43+
node_pools = var.node_pools
4044
}
4145

4246
data "google_client_config" "default" {

examples/simple_regional_beta/variables.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,32 @@ variable "cloudrun" {
5656
description = "Boolean to enable / disable CloudRun"
5757
default = true
5858
}
59+
60+
variable "node_metadata" {
61+
description = "Specifies how node metadata is exposed to the workload running on the node"
62+
default = "SECURE"
63+
type = string
64+
}
65+
66+
variable "sandbox_enabled" {
67+
type = bool
68+
description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it)."
69+
default = false
70+
}
71+
72+
variable "remove_default_node_pool" {
73+
type = bool
74+
description = "Remove default node pool while setting up the cluster"
75+
default = false
76+
}
77+
78+
variable "node_pools" {
79+
type = list(map(string))
80+
description = "List of maps containing node pools"
81+
82+
default = [
83+
{
84+
name = "default-node-pool"
85+
},
86+
]
87+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Simple Regional Cluster with Networking
2+
3+
This example illustrates how to create a VPC and 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 | The name for the GKE cluster | string | `"gke-on-vpc-cluster"` | no |
11+
| ip\_range\_pods\_name | The secondary ip range to use for pods | string | `"ip-range-pods"` | no |
12+
| ip\_range\_services\_name | The secondary ip range to use for pods | string | `"ip-range-scv"` | no |
13+
| network | The VPC network created to host the cluster in | string | `"gke-network"` | no |
14+
| project\_id | The project ID to host the cluster in | string | n/a | yes |
15+
| region | The region to host the cluster in | string | `"us-central1"` | no |
16+
| subnetwork | The subnetwork created to host the cluster in | string | `"gke-subnet"` | no |
17+
18+
## Outputs
19+
20+
| Name | Description |
21+
|------|-------------|
22+
| ca\_certificate | The cluster ca certificate (base64 encoded) |
23+
| client\_token | The bearer token for auth |
24+
| cluster\_name | Cluster name |
25+
| ip\_range\_pods\_name | The secondary IP range used for pods |
26+
| ip\_range\_services\_name | The secondary IP range used for services |
27+
| kubernetes\_endpoint | The cluster endpoint |
28+
| location | |
29+
| master\_kubernetes\_version | The master Kubernetes version |
30+
| network | |
31+
| network\_name | The name of the VPC being created |
32+
| project\_id | |
33+
| region | |
34+
| service\_account | The default service account used for running nodes. |
35+
| subnet\_name | The name of the subnet being created |
36+
| subnet\_secondary\_ranges | The secondary ranges associated with the subnet |
37+
| subnetwork | |
38+
| zones | List of zones in which the cluster resides |
39+
40+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
41+
42+
To provision this example, run the following from within this directory:
43+
- `terraform init` to get the plugins
44+
- `terraform plan` to see the infrastructure plan
45+
- `terraform apply` to apply the infrastructure build
46+
- `terraform destroy` to destroy the built infrastructure
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Copyright 2019 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+
module "gcp-network" {
18+
source = "terraform-google-modules/network/google"
19+
version = "~> 1.4.0"
20+
project_id = var.project_id
21+
network_name = var.network
22+
23+
subnets = [
24+
{
25+
subnet_name = var.subnetwork
26+
subnet_ip = "10.0.0.0/17"
27+
subnet_region = var.region
28+
},
29+
]
30+
31+
secondary_ranges = {
32+
"${var.subnetwork}" = [
33+
{
34+
range_name = var.ip_range_pods_name
35+
ip_cidr_range = "192.168.0.0/18"
36+
},
37+
{
38+
range_name = var.ip_range_services_name
39+
ip_cidr_range = "192.168.64.0/18"
40+
},
41+
]
42+
}
43+
}
44+
45+
module "gke" {
46+
source = "../../"
47+
project_id = var.project_id
48+
name = var.cluster_name
49+
regional = true
50+
region = var.region
51+
network = module.gcp-network.network_name
52+
subnetwork = module.gcp-network.subnets_names[0]
53+
ip_range_pods = var.ip_range_pods_name
54+
ip_range_services = var.ip_range_services_name
55+
create_service_account = true
56+
}
57+
58+
data "google_client_config" "default" {
59+
}

0 commit comments

Comments
 (0)