Skip to content

Commit c5d1e0a

Browse files
Fixes #180: Add tests for beta submodules/examples
#180 Added tests for the beta private cluster.
1 parent 03f0931 commit c5d1e0a

File tree

12 files changed

+538
-4
lines changed

12 files changed

+538
-4
lines changed

.kitchen.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ suites:
137137
systems:
138138
- name: workload_metadata_config
139139
backend: local
140+
- name: "beta_cluster"
141+
driver:
142+
root_module_directory: test/fixtures/beta_cluster
143+
verifier:
144+
systems:
145+
- name: gcloud
146+
backend: local
147+
controls:
148+
- gcloud
149+
- name: gcp
150+
backend: gcp
151+
controls:
152+
- gcp
140153
- name: "deploy_service"
141154
driver:
142155
root_module_directory: test/fixtures/deploy_service

build/int.cloudbuild.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,26 @@ steps:
241241
- verify workload-metadata-config-local
242242
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
243243
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy workload-metadata-config-local']
244+
- id: create beta-cluster-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 beta-cluster-local']
249+
- id: converge beta-cluster-local
250+
waitFor:
251+
- create beta-cluster-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 beta-cluster-local']
254+
- id: verify beta-cluster-local
255+
waitFor:
256+
- converge beta-cluster-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 beta-cluster-local']
259+
#- id: destroy beta-cluster-local
260+
# waitFor:
261+
# - verify beta-cluster-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 beta-cluster-local']
244264
- id: create deploy-service-local
245265
waitFor:
246266
- prepare
@@ -304,8 +324,8 @@ steps:
304324
tags:
305325
- 'ci'
306326
- 'integration'
327+
options:
328+
machineType: 'N1_HIGHCPU_8'
307329
substitutions:
308330
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
309331
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.4.6'
310-
options:
311-
machineType: 'N1_HIGHCPU_8'

test/ci/beta-cluster.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
platform: linux
4+
5+
inputs:
6+
- name: pull-request
7+
path: terraform-google-kubernetes-engine
8+
9+
run:
10+
path: make
11+
args: ['test_integration']
12+
dir: terraform-google-kubernetes-engine
13+
14+
params:
15+
SUITE: "beta-cluster-local"
16+
COMPUTE_ENGINE_SERVICE_ACCOUNT: ""
17+
REGION: "us-east4"
18+
ZONES: '["us-east4-a", "us-east4-b", "us-east4-c"]'

test/fixtures/beta_cluster/main.tf

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
18+
provider "google" {
19+
version = "~> 2.18.0"
20+
project = var.project_id
21+
region = var.region
22+
}
23+
24+
provider "google-beta" {
25+
version = "~> 2.18.0"
26+
project = var.project_id
27+
region = var.region
28+
}
29+
30+
locals {
31+
name = "beta-cluster-${random_string.suffix.result}"
32+
}
33+
34+
resource "google_kms_key_ring" "db" {
35+
location = var.region
36+
name = "${local.name}-db"
37+
}
38+
39+
resource "google_kms_crypto_key" "db" {
40+
name = local.name
41+
key_ring = google_kms_key_ring.db.self_link
42+
}
43+
44+
module "this" {
45+
source = "../../../modules/beta-public-cluster"
46+
47+
name = local.name
48+
project_id = var.project_id
49+
regional = false
50+
region = var.region
51+
zones = slice(var.zones, 0, 1)
52+
network = google_compute_network.main.name
53+
subnetwork = google_compute_subnetwork.main.name
54+
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
55+
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
56+
service_account = "create"
57+
58+
// Beta features
59+
istio = true
60+
61+
database_encryption = [{
62+
state = "ENCRYPTED"
63+
key_name = google_kms_crypto_key.db.self_link
64+
}]
65+
66+
cloudrun = true
67+
68+
enable_binary_authorization = true
69+
70+
pod_security_policy_config = [{
71+
enabled = true
72+
}]
73+
74+
node_metadata = "EXPOSE"
75+
}
76+
77+
data "google_client_config" "default" {
78+
}

test/fixtures/beta_cluster/network.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
resource "random_string" "suffix" {
18+
length = 4
19+
special = false
20+
upper = false
21+
}
22+
23+
resource "google_compute_network" "main" {
24+
name = "cft-gke-test-${random_string.suffix.result}"
25+
auto_create_subnetworks = false
26+
}
27+
28+
resource "google_compute_subnetwork" "main" {
29+
name = "cft-gke-test-${random_string.suffix.result}"
30+
ip_cidr_range = "10.0.0.0/17"
31+
region = var.region
32+
network = google_compute_network.main.self_link
33+
34+
secondary_ip_range {
35+
range_name = "cft-gke-test-pods-${random_string.suffix.result}"
36+
ip_cidr_range = "192.168.0.0/18"
37+
}
38+
39+
secondary_ip_range {
40+
range_name = "cft-gke-test-services-${random_string.suffix.result}"
41+
ip_cidr_range = "192.168.64.0/18"
42+
}
43+
}
44+

test/fixtures/beta_cluster/outputs.tf

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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 "project_id" {
18+
value = var.project_id
19+
}
20+
21+
output "region" {
22+
value = module.this.region
23+
}
24+
25+
output "cluster_name" {
26+
description = "Cluster name"
27+
value = module.this.name
28+
}
29+
30+
output "network" {
31+
value = google_compute_network.main.name
32+
}
33+
34+
output "subnetwork" {
35+
value = google_compute_subnetwork.main.name
36+
}
37+
38+
output "location" {
39+
value = module.this.location
40+
}
41+
42+
output "ip_range_pods" {
43+
description = "The secondary IP range used for pods"
44+
value = google_compute_subnetwork.main.secondary_ip_range[0].range_name
45+
}
46+
47+
output "ip_range_services" {
48+
description = "The secondary IP range used for services"
49+
value = google_compute_subnetwork.main.secondary_ip_range[1].range_name
50+
}
51+
52+
output "zones" {
53+
description = "List of zones in which the cluster resides"
54+
value = module.this.zones
55+
}
56+
57+
output "master_kubernetes_version" {
58+
description = "The master Kubernetes version"
59+
value = module.this.master_version
60+
}
61+
62+
output "kubernetes_endpoint" {
63+
sensitive = true
64+
value = module.this.endpoint
65+
}
66+
67+
output "client_token" {
68+
sensitive = true
69+
value = base64encode(data.google_client_config.default.access_token)
70+
}
71+
72+
output "ca_certificate" {
73+
description = "The cluster CA certificate"
74+
value = module.this.ca_certificate
75+
}
76+
77+
output "service_account" {
78+
description = "The service account to default running nodes as if not overridden in `node_pools`."
79+
value = module.this.service_account
80+
}
81+
82+
output "database_encryption_key_name" {
83+
value = google_kms_crypto_key.db.self_link
84+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../deploy_service/variables.tf

0 commit comments

Comments
 (0)