From f82266ac8c436bc451690179673f092c2a351a48 Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Mon, 30 Sep 2019 22:04:35 -0700 Subject: [PATCH] Add stricter types for GCP modules * Review variables available in google-cloud kubernetes and workers modules and in documentation --- CHANGES.md | 1 + docs/advanced/worker-pools.md | 5 +- docs/cl/google-cloud.md | 7 ++- .../container-linux/kubernetes/variables.tf | 53 ++++++++++--------- .../kubernetes/workers/variables.tf | 32 ++++++----- 5 files changed, 47 insertions(+), 51 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6263277bb..b1b9cf9d0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,6 +26,7 @@ Notable changes between versions. #### Google Cloud +* Add Terraform v0.12 variables types ([#556](https://github.com/poseidon/typhoon/pull/556)) * Add `node_labels` variable to internal `workers` module ([#550](https://github.com/poseidon/typhoon/pull/550)) #### Addons diff --git a/docs/advanced/worker-pools.md b/docs/advanced/worker-pools.md index a689011e5..6512b6910 100644 --- a/docs/advanced/worker-pools.md +++ b/docs/advanced/worker-pools.md @@ -69,7 +69,6 @@ The AWS internal `workers` module supports a number of [variables](https://githu | spot_price | Spot price in USD for worker instances or 0 to use on-demand instances | 0 | 0.10 | | clc_snippets | Container Linux Config snippets | [] | [example](/advanced/customization/#usage) | | service_cidr | Must match `service_cidr` of cluster | "10.3.0.0/16" | "10.3.0.0/24" | -| cluster_domain_suffix | Must match `cluster_domain_suffix` of cluster | "cluster.local" | "k8s.example.com" | | node_labels | List of initial node labels | [] | ["worker-pool=foo"] | Check the list of valid [instance types](https://aws.amazon.com/ec2/instance-types/) or per-region and per-type [spot prices](https://aws.amazon.com/ec2/spot/pricing/). @@ -136,7 +135,6 @@ The Azure internal `workers` module supports a number of [variables](https://git | priority | Set priority to Low to use reduced cost surplus capacity, with the tradeoff that instances can be deallocated at any time | Regular | Low | | clc_snippets | Container Linux Config snippets | [] | [example](/advanced/customization/#usage) | | service_cidr | CIDR IPv4 range to assign to Kubernetes services | "10.3.0.0/16" | "10.3.0.0/24" | -| cluster_domain_suffix | FQDN suffix for Kubernetes services answered by coredns. | "cluster.local" | "k8s.example.com" | | node_labels | List of initial node labels | [] | ["worker-pool=foo"] | Check the list of valid [machine types](https://azure.microsoft.com/en-us/pricing/details/virtual-machines/linux/) and their [specs](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes-general). Use `az vm list-skus` to get the identifier. @@ -194,9 +192,9 @@ The Google Cloud internal `workers` module supports a number of [variables](http | Name | Description | Example | |:-----|:------------|:--------| | name | Unique name (distinct from cluster name) | "yavin-16x" | +| cluster_name | Must be set to `cluster_name` of cluster | "yavin" | | region | Region for the worker pool instances. May differ from the cluster's region | "europe-west2" | | network | Must be set to `network_name` output by cluster | module.cluster.network_name | -| cluster_name | Must be set to `cluster_name` of cluster | "yavin" | | kubeconfig | Must be set to `kubeconfig` output by cluster | module.cluster.kubeconfig | | ssh_authorized_key | SSH public key for user 'core' | "ssh-rsa AAAAB3NZ..." | @@ -213,7 +211,6 @@ Check the list of regions [docs](https://cloud.google.com/compute/docs/regions-z | preemptible | If true, Compute Engine will terminate instances randomly within 24 hours | false | true | | clc_snippets | Container Linux Config snippets | [] | [example](/advanced/customization/#usage) | | service_cidr | Must match `service_cidr` of cluster | "10.3.0.0/16" | "10.3.0.0/24" | -| cluster_domain_suffix | Must match `cluster_domain_suffix` of cluster | "cluster.local" | "k8s.example.com" | | node_labels | List of initial node labels | [] | ["worker-pool=foo"] | Check the list of valid [machine types](https://cloud.google.com/compute/docs/machine-types). diff --git a/docs/cl/google-cloud.md b/docs/cl/google-cloud.md index a33b4cd71..4c9e3e699 100644 --- a/docs/cl/google-cloud.md +++ b/docs/cl/google-cloud.md @@ -52,7 +52,7 @@ provider "google" { version = "2.15.0" project = "project-id" region = "us-central1" - credentials = "${file("~/.config/google-cloud/terraform.json")}" + credentials = file("~/.config/google-cloud/terraform.json") } provider "ct" { @@ -180,7 +180,7 @@ Check the [variables.tf](https://github.com/poseidon/typhoon/blob/master/google- | dns_zone | Google Cloud DNS zone | "google-cloud.example.com" | | dns_zone_name | Google Cloud DNS zone name | "example-zone" | | ssh_authorized_key | SSH public key for user 'core' | "ssh-rsa AAAAB3NZ..." | -| asset_dir | Path to a directory where generated assets should be placed (contains secrets) | "/home/user/.secrets/clusters/yavin" | +| asset_dir | Absolute path to a directory where generated assets should be placed (contains secrets) | "/home/user/.secrets/clusters/yavin" | Check the list of valid [regions](https://cloud.google.com/compute/docs/regions-zones/regions-zones) and list Container Linux [images](https://cloud.google.com/compute/docs/images) with `gcloud compute images list | grep coreos`. @@ -211,14 +211,13 @@ resource "google_dns_managed_zone" "zone-for-clusters" { | worker_type | Machine type for workers | "n1-standard-1" | See below | | os_image | Container Linux image for compute instances | "coreos-stable" | "coreos-stable-1632-3-0-v20180215" | | disk_size | Size of the disk in GB | 40 | 100 | -| worker_node_labels | List of initial worker node labels | [] | ["worker-pool=default"] | | worker_preemptible | If enabled, Compute Engine will terminate workers randomly within 24 hours | false | true | | controller_clc_snippets | Controller Container Linux Config snippets | [] | [example](/advanced/customization/) | | worker_clc_snippets | Worker Container Linux Config snippets | [] | [example](/advanced/customization/) | | networking | Choice of networking provider | "calico" | "calico" or "flannel" | | pod_cidr | CIDR IPv4 range to assign to Kubernetes pods | "10.2.0.0/16" | "10.22.0.0/16" | | service_cidr | CIDR IPv4 range to assign to Kubernetes services | "10.3.0.0/16" | "10.3.0.0/24" | -| cluster_domain_suffix | FQDN suffix for Kubernetes services answered by coredns. | "cluster.local" | "k8s.example.com" | +| worker_node_labels | List of initial worker node labels | [] | ["worker-pool=default"] | Check the list of valid [machine types](https://cloud.google.com/compute/docs/machine-types). diff --git a/google-cloud/container-linux/kubernetes/variables.tf b/google-cloud/container-linux/kubernetes/variables.tf index e767a8fdf..2425e1f88 100644 --- a/google-cloud/container-linux/kubernetes/variables.tf +++ b/google-cloud/container-linux/kubernetes/variables.tf @@ -23,45 +23,45 @@ variable "dns_zone_name" { # instances variable "controller_count" { - type = string - default = "1" + type = number description = "Number of controllers (i.e. masters)" + default = 1 } variable "worker_count" { - type = string - default = "1" + type = number description = "Number of workers" + default = 1 } variable "controller_type" { type = string - default = "n1-standard-1" description = "Machine type for controllers (see `gcloud compute machine-types list`)" + default = "n1-standard-1" } variable "worker_type" { type = string - default = "n1-standard-1" description = "Machine type for controllers (see `gcloud compute machine-types list`)" + default = "n1-standard-1" } variable "os_image" { type = string - default = "coreos-stable" description = "Container Linux image for compute instances (e.g. coreos-stable)" + default = "coreos-stable" } variable "disk_size" { - type = string - default = "40" + type = number description = "Size of the disk in GB" + default = 40 } variable "worker_preemptible" { - type = string - default = "false" + type = bool description = "If enabled, Compute Engine will terminate workers randomly within 24 hours" + default = false } variable "controller_clc_snippets" { @@ -84,49 +84,42 @@ variable "ssh_authorized_key" { } variable "asset_dir" { - description = "Path to a directory where generated assets should be placed (contains secrets)" type = string + description = "Absolute path to a directory where generated assets should be placed (contains secrets)" } variable "networking" { - description = "Choice of networking provider (flannel or calico)" type = string + description = "Choice of networking provider (flannel or calico)" default = "calico" } variable "pod_cidr" { - description = "CIDR IPv4 range to assign Kubernetes pods" type = string + description = "CIDR IPv4 range to assign Kubernetes pods" default = "10.2.0.0/16" } variable "service_cidr" { + type = string description = <