-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created test for sandbox (Fix terraform-google-modules#252)
- Loading branch information
1 parent
7b699cc
commit a401a2e
Showing
12 changed files
with
271 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
module "example" { | ||
source = "../../../examples/simple_regional_beta" | ||
|
||
project_id = var.project_id | ||
cluster_name_suffix = "-${random_string.suffix.result}" | ||
region = var.region | ||
network = google_compute_network.main.name | ||
subnetwork = google_compute_subnetwork.main.name | ||
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name | ||
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name | ||
compute_engine_service_account = var.compute_engine_service_account | ||
istio = false | ||
cloudrun = false | ||
node_metadata = "UNSPECIFIED" | ||
sandbox_enabled = true | ||
remove_default_node_pool = true | ||
|
||
node_pools = [ | ||
{ | ||
name = "default-node-pool" | ||
image_type = "COS_CONTAINERD" | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
resource "random_string" "suffix" { | ||
length = 4 | ||
special = false | ||
upper = false | ||
} | ||
|
||
provider "google" { | ||
project = var.project_id | ||
} | ||
|
||
resource "google_compute_network" "main" { | ||
name = "cft-gke-test-${random_string.suffix.result}" | ||
auto_create_subnetworks = false | ||
} | ||
|
||
resource "google_compute_subnetwork" "main" { | ||
name = "cft-gke-test-${random_string.suffix.result}" | ||
ip_cidr_range = "10.0.0.0/17" | ||
region = var.region | ||
network = google_compute_network.main.self_link | ||
|
||
secondary_ip_range { | ||
range_name = "cft-gke-test-pods-${random_string.suffix.result}" | ||
ip_cidr_range = "192.168.0.0/18" | ||
} | ||
|
||
secondary_ip_range { | ||
range_name = "cft-gke-test-services-${random_string.suffix.result}" | ||
ip_cidr_range = "192.168.64.0/18" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../shared/outputs.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../shared/variables.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Copyright 2019 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
project_id = attribute('project_id') | ||
location = attribute('location') | ||
cluster_name = attribute('cluster_name') | ||
|
||
control "gcloud" do | ||
title "Google Compute Engine GKE configuration" | ||
describe command("gcloud --project=#{project_id} container clusters --zone=#{location} describe #{cluster_name} --format=json") do | ||
its(:exit_status) { should eq 0 } | ||
its(:stderr) { should eq '' } | ||
|
||
let!(:data) do | ||
if subject.exit_status == 0 | ||
JSON.parse(subject.stdout) | ||
else | ||
{} | ||
end | ||
end | ||
|
||
describe "cluster" do | ||
it "is running" do | ||
expect(data['status']).to eq 'RUNNING' | ||
end | ||
|
||
it "is regional" do | ||
expect(data['location']).to match(/^.*[1-9]$/) | ||
end | ||
|
||
it "uses public nodes and master endpoint" do | ||
expect(data['privateClusterConfig']).to eq nil | ||
end | ||
|
||
it "has the expected addon settings" do | ||
expect(data['addonsConfig']).to eq({ | ||
"horizontalPodAutoscaling" => {}, | ||
"httpLoadBalancing" => {}, | ||
"kubernetesDashboard" => { | ||
"disabled" => true, | ||
}, | ||
"networkPolicyConfig" => { | ||
"disabled" => true, | ||
}, | ||
}) | ||
end | ||
end | ||
|
||
describe "node pool" do | ||
let(:node_pools) { data['nodePools'].reject { |p| p['name'] == "default-pool" } } | ||
|
||
it "is the expected image type" do | ||
expect(node_pools).to include( | ||
including( | ||
"config" => including( | ||
"imageType" => "COS_CONTAINERD", | ||
), | ||
) | ||
) | ||
end | ||
|
||
it "has the expected labels" do | ||
expect(node_pools).to include( | ||
including( | ||
"config" => including( | ||
"labels" => including( | ||
"cluster_name" => cluster_name, | ||
"node_pool" => "default-node-pool", | ||
"sandbox.gke.io/runtime" => "gvisor", | ||
), | ||
), | ||
) | ||
) | ||
end | ||
|
||
it "has the expected network tags" do | ||
expect(node_pools).to include( | ||
including( | ||
"config" => including( | ||
"tags" => match_array([ | ||
"gke-#{cluster_name}", | ||
"gke-#{cluster_name}-default-node-pool", | ||
]), | ||
), | ||
) | ||
) | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: sandbox_enabled | ||
attributes: | ||
- name: project_id | ||
required: true | ||
type: string | ||
- name: location | ||
required: true | ||
type: string | ||
- name: cluster_name | ||
required: true | ||
type: string | ||
- name: kubernetes_endpoint | ||
required: true | ||
type: string | ||
- name: client_token | ||
required: true | ||
type: string |