Skip to content

Commit d6f9969

Browse files
committed
* Fix #93
Moved cluster autos scaling config to node_pool fixture to fix project networks quota
1 parent 45e0063 commit d6f9969

File tree

13 files changed

+48
-310
lines changed

13 files changed

+48
-310
lines changed

.kitchen.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ suites:
5252
systems:
5353
- name: simple_regional
5454
backend: local
55-
- name: "simple_regional_beta"
56-
driver:
57-
root_module_directory: test/fixtures/simple_regional_beta
58-
verifier:
59-
systems:
60-
- name: simple_regional_beta
61-
backend: local
6255
- name: "simple_regional_with_networking"
6356
driver:
6457
root_module_directory: test/fixtures/simple_regional_with_networking

build/int.cloudbuild.yaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,6 @@ steps:
8181
- verify simple-regional-local
8282
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
8383
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-local']
84-
- id: create simple-regional-beta-local
85-
waitFor:
86-
- prepare
87-
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
88-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-regional-beta-local']
89-
- id: converge simple-regional-beta-local
90-
waitFor:
91-
- create simple-regional-beta-local
92-
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
93-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-regional-beta-local']
94-
- id: verify simple-regional-beta-local
95-
waitFor:
96-
- converge simple-regional-beta-local
97-
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
98-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-regional-beta-local']
99-
- id: destroy simple-regional-beta-local
100-
waitFor:
101-
- verify simple-regional-beta-local
102-
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
103-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-beta-local']
10484
- id: create simple-regional-private-local
10585
waitFor:
10686
- prepare

examples/node_pool/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This example illustrates how to create a cluster with multiple custom node-pool
77

88
| Name | Description | Type | Default | Required |
99
|------|-------------|:----:|:-----:|:-----:|
10+
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | object | `<map>` | no |
1011
| cluster\_name\_suffix | A suffix to append to the default cluster name | string | `""` | no |
1112
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | string | n/a | yes |
1213
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |

examples/node_pool/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ provider "google-beta" {
2626
module "gke" {
2727
source = "../../modules/beta-public-cluster/"
2828
project_id = var.project_id
29-
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
29+
name = join("", [local.cluster_type, "-cluster", var.cluster_name_suffix])
3030
region = var.region
3131
zones = var.zones
3232
network = var.network
@@ -36,6 +36,7 @@ module "gke" {
3636
create_service_account = false
3737
remove_default_node_pool = true
3838
disable_legacy_metadata_endpoints = false
39+
cluster_autoscaling = var.cluster_autoscaling
3940

4041
node_pools = [
4142
{

examples/node_pool/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,14 @@ variable "compute_engine_service_account" {
5252
description = "Service account to associate to the nodes in the cluster"
5353
}
5454

55+
variable "cluster_autoscaling" {
56+
type = object({
57+
enabled = bool
58+
resource_limits = map(number)
59+
})
60+
default = {
61+
enabled = false
62+
resource_limits = {}
63+
}
64+
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
65+
}

test/fixtures/node_pool/example.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,15 @@ module "example" {
2626
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
2727
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
2828
compute_engine_service_account = var.compute_engine_service_account
29+
30+
cluster_autoscaling = {
31+
enabled = true
32+
resource_limits = {
33+
max_cpu_cores = 20
34+
min_cpu_cores = 5
35+
max_memory_gb = 30
36+
min_memory_gb = 10
37+
}
38+
}
2939
}
3040

test/fixtures/simple_regional_beta/example.tf

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/fixtures/simple_regional_beta/network.tf

Lines changed: 0 additions & 48 deletions
This file was deleted.

test/fixtures/simple_regional_beta/outputs.tf

Lines changed: 0 additions & 84 deletions
This file was deleted.

test/fixtures/simple_regional_beta/variables.tf

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/integration/node_pool/controls/gcloud.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,30 @@
3333
end
3434
end
3535

36+
describe "cluster-autoscaling" do
37+
it "has the expected cluster autoscaling settings" do
38+
expect(data['autoscaling']).to eq({
39+
"autoprovisioningNodePoolDefaults" => {
40+
"oauthScopes" => %w(https://www.googleapis.com/auth/logging.write https://www.googleapis.com/auth/monitoring),
41+
"serviceAccount" => "default"
42+
},
43+
"enableNodeAutoprovisioning" => true,
44+
"resourceLimits" => [
45+
{
46+
"maximum" => "20",
47+
"minimum" => "5",
48+
"resourceType" => "cpu"
49+
},
50+
{
51+
"maximum" => "30",
52+
"minimum" => "10",
53+
"resourceType" => "memory"
54+
}
55+
]
56+
})
57+
end
58+
end
59+
3660
describe "node pools" do
3761
let(:node_pools) { data['nodePools'].reject { |p| p['name'] == "default-pool" } }
3862

test/integration/simple_regional_beta/controls/gcloud.rb

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)