Skip to content

Feature/collapse regional and zonal clusters #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCK
all: check generate_docs

.PHONY: check
check: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace check_generate check_generate_docs
check: check_shell check_python check_golang check_terraform check_base_files test_check_headers check_headers check_trailing_whitespace check_generate check_generate_docs

# The .PHONY directive tells make that this isn't a real target and so
# the presence of a file named 'check_shell' won't cause this target to stop
Expand All @@ -47,10 +47,6 @@ check_golang:
check_terraform:
@source test/make.sh && check_terraform

.PHONY: check_docker
check_docker:
@source test/make.sh && docker

.PHONY: check_base_files
check_base_files:
@source test/make.sh && basefiles
Expand Down
32 changes: 13 additions & 19 deletions autogen/cluster_regional.tf → autogen/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{{ autogeneration_note }}

/******************************************
Create regional cluster
Create Container Cluster
*****************************************/
resource "google_container_cluster" "primary" {
{% if private_cluster or beta_cluster %}
Expand All @@ -26,18 +26,13 @@ resource "google_container_cluster" "primary" {
provider = google
{% endif %}

count = var.regional ? 1 : 0
name = var.name
description = var.description
project = var.project_id
resource_labels = var.cluster_resource_labels

region = var.region
node_locations = coalescelist(
compact(var.zones),
sort(random_shuffle.available_zones.result),
)

location = local.location
node_locations = local.node_locations
cluster_ipv4_cidr = var.cluster_ipv4_cidr
network = data.google_compute_network.gke_network.self_link

Expand All @@ -51,7 +46,7 @@ resource "google_container_cluster" "primary" {
}

subnetwork = data.google_compute_subnetwork.gke_subnetwork.self_link
min_master_version = local.kubernetes_version_regional
min_master_version = local.master_version

logging_service = var.logging_service
monitoring_service = var.monitoring_service
Expand Down Expand Up @@ -173,8 +168,8 @@ resource "google_container_cluster" "primary" {
enable_private_nodes = var.enable_private_nodes
master_ipv4_cidr_block = var.master_ipv4_cidr_block
}

{% endif %}

remove_default_node_pool = var.remove_default_node_pool
{% if beta_cluster %}

Expand All @@ -190,19 +185,19 @@ resource "google_container_cluster" "primary" {
}

/******************************************
Create regional node pools
Create Container Cluster node pools
*****************************************/
resource "google_container_node_pool" "pools" {
provider = google-beta
count = var.regional ? length(var.node_pools) : 0
count = length(var.node_pools)
name = var.node_pools[count.index]["name"]
project = var.project_id
region = var.region
cluster = google_container_cluster.primary[0].name
location = local.location
cluster = google_container_cluster.primary.name
version = lookup(var.node_pools[count.index], "auto_upgrade", false) ? "" : lookup(
var.node_pools[count.index],
"version",
local.node_version_regional,
local.node_version,
)
initial_node_count = lookup(
var.node_pools[count.index],
Expand All @@ -220,7 +215,7 @@ resource "google_container_node_pool" "pools" {

management {
auto_repair = lookup(var.node_pools[count.index], "auto_repair", true)
auto_upgrade = lookup(var.node_pools[count.index], "auto_upgrade", true)
auto_upgrade = lookup(var.node_pools[count.index], "auto_upgrade", local.default_auto_upgrade)
}

node_config {
Expand Down Expand Up @@ -278,7 +273,7 @@ resource "google_container_node_pool" "pools" {

oauth_scopes = concat(
var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[var.node_pools[count.index]["name"]]
var.node_pools_oauth_scopes[var.node_pools[count.index]["name"]],
)

guest_accelerator = [
Expand Down Expand Up @@ -313,8 +308,7 @@ resource "google_container_node_pool" "pools" {
}
}

resource "null_resource" "wait_for_regional_cluster" {
count = var.regional ? 1 : 0
resource "null_resource" "wait_for_cluster" {

provisioner "local-exec" {
command = "${path.module}/scripts/wait-for-cluster.sh ${var.project_id} ${var.name}"
Expand Down
Loading