Skip to content

Commit 23dc5cf

Browse files
authored
Merge pull request #1 from terraform-google-modules/master
sync
2 parents ab02f24 + 5ea026b commit 23dc5cf

File tree

58 files changed

+892
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+892
-41
lines changed

.kitchen.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ suites:
6868
systems:
6969
- name: simple_regional
7070
backend: local
71+
- name: "simple_regional_with_networking"
72+
driver:
73+
root_module_directory: test/fixtures/simple_regional_with_networking
74+
verifier:
75+
systems:
76+
- name: simple_regional_with_networking
77+
backend: local
78+
controls:
79+
- gcloud
80+
- name: subnet
81+
backend: local
82+
controls:
83+
- subnet
84+
- name: network
85+
backend: gcp
86+
controls:
87+
- network
7188
- name: "simple_regional_private"
7289
driver:
7390
root_module_directory: test/fixtures/simple_regional_private

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Extending the adopted spec, each change should have a link to its corresponding
88

99
## [Unreleased]
1010

11+
### Added
12+
13+
* Support for Shielded Nodes beta feature via `enabled_shielded_nodes` variable. [#300]
14+
1115
## [v5.1.1] - 2019-10-25
1216

1317
### Fixed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Make will use bash instead of sh
1919
SHELL := /usr/bin/env bash
2020

21-
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.4.5
21+
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.4.6
2222
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2323
REGISTRY_URL := gcr.io/cloud-foundation-cicd
2424

@@ -27,7 +27,7 @@ REGISTRY_URL := gcr.io/cloud-foundation-cicd
2727
docker_run:
2828
docker run --rm -it \
2929
-e SERVICE_ACCOUNT_JSON \
30-
-v $(CURDIR):/workspace \
30+
-v "$(CURDIR)":/workspace \
3131
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
3232
/bin/bash
3333

@@ -39,7 +39,7 @@ docker_test_prepare:
3939
-e TF_VAR_org_id \
4040
-e TF_VAR_folder_id \
4141
-e TF_VAR_billing_account \
42-
-v $(CURDIR):/workspace \
42+
-v "$(CURDIR)":/workspace \
4343
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
4444
/usr/local/bin/execute_with_credentials.sh prepare_environment
4545

@@ -51,7 +51,7 @@ docker_test_cleanup:
5151
-e TF_VAR_org_id \
5252
-e TF_VAR_folder_id \
5353
-e TF_VAR_billing_account \
54-
-v $(CURDIR):/workspace \
54+
-v "$(CURDIR)":/workspace \
5555
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
5656
/usr/local/bin/execute_with_credentials.sh cleanup_environment
5757

@@ -60,31 +60,31 @@ docker_test_cleanup:
6060
docker_test_integration:
6161
docker run --rm -it \
6262
-e SERVICE_ACCOUNT_JSON \
63-
-v $(CURDIR):/workspace \
63+
-v "$(CURDIR)":/workspace \
6464
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
6565
/usr/local/bin/test_integration.sh
6666

6767
# Execute lint tests within the docker container
6868
.PHONY: docker_test_lint
6969
docker_test_lint:
7070
docker run --rm -it \
71-
-v $(CURDIR):/workspace \
71+
-v "$(CURDIR)":/workspace \
7272
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
7373
/usr/local/bin/test_lint.sh
7474

7575
# Generate documentation
7676
.PHONY: docker_generate_docs
7777
docker_generate_docs:
7878
docker run --rm -it \
79-
-v $(CURDIR):/workspace \
79+
-v "$(CURDIR)":/workspace \
8080
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
8181
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'
8282

8383
# Generate files from autogen
8484
.PHONY: docker_generate
8585
docker_generate:
8686
docker run --rm -it \
87-
-v $(CURDIR):/workspace \
87+
-v "$(CURDIR)":/workspace \
8888
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
8989
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate'
9090

autogen/cluster.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ resource "google_container_cluster" "primary" {
4545
}
4646
}
4747

48+
{% if beta_cluster %}
49+
dynamic "release_channel" {
50+
for_each = local.release_channel
51+
52+
content {
53+
channel = release_channel.value.channel
54+
}
55+
}
56+
{% endif %}
57+
4858
subnetwork = data.google_compute_subnetwork.gke_subnetwork.self_link
4959
min_master_version = local.master_version
5060

@@ -55,6 +65,7 @@ resource "google_container_cluster" "primary" {
5565
enable_binary_authorization = var.enable_binary_authorization
5666
enable_intranode_visibility = var.enable_intranode_visibility
5767
default_max_pods_per_node = var.default_max_pods_per_node
68+
enable_shielded_nodes = var.enable_shielded_nodes
5869

5970
vertical_pod_autoscaling {
6071
enabled = var.enable_vertical_pod_autoscaling

autogen/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ locals {
4848
node_version_zonal = var.node_version != "" && ! var.regional ? var.node_version : local.master_version_zonal
4949
master_version = var.regional ? local.master_version_regional : local.master_version_zonal
5050
node_version = var.regional ? local.node_version_regional : local.node_version_zonal
51+
{% if beta_cluster %}
52+
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
53+
{% endif %}
54+
5155

5256
custom_kube_dns_config = length(keys(var.stub_domains)) > 0
5357
upstream_nameservers_config = length(var.upstream_nameservers) > 0

autogen/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,8 @@ output "vertical_pod_autoscaling_enabled" {
150150
value = local.cluster_vertical_pod_autoscaling_enabled
151151
}
152152

153+
output "release_channel" {
154+
description = "The release channel of this cluster"
155+
value = var.release_channel
156+
}
153157
{% endif %}

autogen/scripts/wait-for-cluster.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
set -e
1717

18+
# shellcheck disable=SC2034
1819
if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then
19-
export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${GOOGLE_APPLICATION_CREDENTIALS}
20+
export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE="${GOOGLE_APPLICATION_CREDENTIALS}"
2021
fi
2122

2223
PROJECT=$1

autogen/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,4 +422,15 @@ variable "authenticator_security_group" {
422422
default = null
423423
}
424424

425+
variable "release_channel" {
426+
type = string
427+
description = "(Beta) The release channel of this cluster. Accepted values are `UNSPECIFIED`, `RAPID`, `REGULAR` and `STABLE`. Defaults to `UNSPECIFIED`."
428+
default = null
429+
}
430+
431+
variable "enable_shielded_nodes" {
432+
type = bool
433+
description = "Enable Shielded Nodes features on all nodes in this cluster"
434+
default = false
435+
}
425436
{% endif %}

build/int.cloudbuild.yaml

Lines changed: 21 additions & 1 deletion
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
@@ -246,4 +266,4 @@ tags:
246266
- 'integration'
247267
substitutions:
248268
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
249-
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.4.5'
269+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.4.6'

build/lint.cloudbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ tags:
2424
- 'lint'
2525
substitutions:
2626
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
27-
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.4.5'
27+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.4.6'

cluster.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ resource "google_container_cluster" "primary" {
4141
}
4242
}
4343

44+
4445
subnetwork = data.google_compute_subnetwork.gke_subnetwork.self_link
4546
min_master_version = local.master_version
4647

examples/node_pool/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 2.12.0"
22+
version = "~> 2.18.0"
2323
region = var.region
2424
}
2525

examples/node_pool_update_variant_beta/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 2.12.0"
22+
version = "~> 2.18.0"
2323
credentials = file(var.credentials_path)
2424
region = var.region
2525
}

examples/simple_regional_beta/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 2.12.0"
22+
version = "~> 2.18.0"
2323
region = var.region
2424
}
2525

@@ -45,4 +45,3 @@ module "gke" {
4545

4646
data "google_client_config" "default" {
4747
}
48-

examples/simple_regional_private_beta/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 2.12.0"
22+
version = "~> 2.18.0"
2323
credentials = file(var.credentials_path)
2424
region = var.region
2525
}
@@ -62,4 +62,3 @@ module "gke" {
6262

6363
data "google_client_config" "default" {
6464
}
65-
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)