Skip to content

Commit f5898fd

Browse files
Fixes #180: Add tests for beta submodules/examples
#180 Tests for beta GKE features.
1 parent 1394bde commit f5898fd

File tree

11 files changed

+504
-1
lines changed

11 files changed

+504
-1
lines changed

.kitchen.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,16 @@ suites:
125125
systems:
126126
- name: workload_metadata_config
127127
backend: local
128+
- name: "beta_cluster"
129+
driver:
130+
root_module_directory: test/fixtures/beta_cluster
131+
verifier:
132+
systems:
133+
- name: gcloud
134+
backend: local
135+
controls:
136+
- gcloud
137+
- name: gcp
138+
backend: gcp
139+
controls:
140+
- gcp

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SHELL := /usr/bin/env bash
1818
# Docker build config variables
1919
CREDENTIALS_PATH ?= /cft/workdir/credentials.json
2020
DOCKER_ORG := gcr.io/cloud-foundation-cicd
21-
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 2.1.0
21+
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 2.3.0
2222
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}
2323

2424
# All is the first target in the file so it will get picked up when you just run 'make' on its own

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: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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.9.0"
20+
project = var.project_id
21+
region = var.region
22+
}
23+
24+
provider "google-beta" {
25+
version = "~> 2.9.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+
database_encryption = [{
61+
state = "ENCRYPTED"
62+
key_name = google_kms_crypto_key.db.self_link
63+
}]
64+
cloudrun = true
65+
enable_binary_authorization = true
66+
pod_security_policy_config = [{
67+
enabled = true
68+
}]
69+
node_metadata = "EXPOSE"
70+
}
71+
72+
data "google_client_config" "default" {
73+
}
74+

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/terraform.tfvars
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)