Skip to content

Commit

Permalink
Add an option to create regional clusters on GKE
Browse files Browse the repository at this point in the history
Less prone to k8s API failure this way, although it costs about
70$ a month

Ref 2i2c-org#1248
Ref 2i2c-org#1102
  • Loading branch information
yuvipanda committed Apr 27, 2022
1 parent f7adab2 commit 4b4f457
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/clusters/leap/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gcp:
key: enc-deployer-credentials.secret.json
project: leap-pangeo
cluster: leap-cluster
zone: us-central1-c
zone: us-central1
support:
helm_chart_values_files:
- support.values.yaml
Expand Down
9 changes: 9 additions & 0 deletions docs/howto/operate/new-cluster/new-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ The _minimum_ inputs this file requires are:
Primary identifier to 'group' together resources.
- `project_id`: GCP Project ID to create resources in.
Should be the id, rather than display name of the project.
- `regional_cluster`: Set to true to provision a [GKE Regional
Highly Available cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/regional-clusters).
Costs ~70$ a month, but worth it for the added reliability for most
cases except when cost saving is an absolute requirement.
- `zone`: Zone where cluster nodes and filestore for home directory
are created.
- `region`: Region where cluster master (if `regional_cluster` is
`true`) is run, as well as any storage buckets created with
`user_buckets`.
See the [variables file](https://github.com/2i2c-org/infrastructure/tree/HEAD/terraform/gcp/variables.tf) for other inputs this file can take and their descriptions.
Expand Down
7 changes: 4 additions & 3 deletions terraform/gcp/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ resource "google_container_cluster" "cluster" {
# Setting cluster autoscaling profile is in google-beta
provider = google-beta

name = "${var.prefix}-cluster"
location = var.zone
project = var.project_id
name = "${var.prefix}-cluster"
location = var.regional_cluster ? var.region : var.zone
node_locations = [var.zone]
project = var.project_id

initial_node_count = 1
remove_default_node_pool = true
Expand Down
2 changes: 2 additions & 0 deletions terraform/gcp/projects/leap.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ enable_private_cluster = false

# GPUs not available in us-central1-b
zone = "us-central1-c"
region = "us-central1"
regional_cluster = true

# Multi-tenant cluster, network policy is required to enforce separation between hubs
enable_network_policy = true
Expand Down
2 changes: 2 additions & 0 deletions terraform/gcp/projects/m2lines.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ enable_network_policy = true

# GPUs not available in us-central1-b
zone = "us-central1-c"
region = "us-central1"
regional_cluster = true

# Setup a filestore for in-cluster NFS
enable_filestore = true
Expand Down
16 changes: 16 additions & 0 deletions terraform/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ variable "region" {

}

variable "regional_cluster" {
type = bool
default = false
description = <<-EOT
Enable to have a highly available cluster with multi zonal masters
These are more reliable, as otherwise the k8s API might have small
outages now and then - with this set to false, the nodes serving
the k8s API can go down periodically for upgrades.
See https://cloud.google.com/kubernetes-engine/docs/concepts/regional-clusters
for more information
EOT
}


variable "zone" {
type = string
default = "us-central1-b"
Expand Down

0 comments on commit 4b4f457

Please sign in to comment.