-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from reactiveops/if/public-vpc-native
Add public VPC Native GKE and node pool modules
- Loading branch information
Showing
23 changed files
with
531 additions
and
1 deletion.
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
Empty file.
Empty file.
File renamed without changes.
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,15 @@ | ||
# This constructs README.md, including Terraform documentation in its middle. | ||
# THIs requires `terraform-docs` to be installed from: https://github.com/segmentio/terraform-docs | ||
|
||
# The sed command below increases the markdown heading level of Terraform docs. | ||
README.md:README.pre_terraform_inputs.md README.post_terraform_inputs.md | ||
@echo Creating ReadMe with Terraform docs. . . | ||
cat README.pre_tf_inputs.md >README.md | ||
echo >>README.md | ||
terraform-docs --with-aggregate-type-defaults md document . |sed 's/^#/##/g' >>README.md | ||
echo >>README.md | ||
cat README.post_tf_inputs.md >>README.md | ||
|
||
README.pre_terraform_inputs.md: | ||
README.post_terraform_inputs.md: | ||
|
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,78 @@ | ||
# Terraform GKE Node Pool Module | ||
|
||
This module manages a node pool attached to a Google Kubernetes Engine (GKE) cluster. | ||
|
||
## Using The Terraform Module | ||
|
||
This module requires version 2.0.0 or above of the Google Terraform provider. | ||
|
||
See the file [example-usage](./example-usage) for an example of how to use this module. Below are the available module inputs: | ||
|
||
### Required Inputs | ||
|
||
The following input variables are required: | ||
|
||
#### gke\_cluster\_name | ||
|
||
Description: The name of the GKE cluster to bind this node pool. | ||
|
||
Type: `string` | ||
|
||
#### kubernetes\_version | ||
|
||
Description: The kubernetes version for the nodes in the pool. This should match the Kubernetes version of the GKE cluster. | ||
|
||
Type: `string` | ||
|
||
#### max\_node\_count | ||
|
||
Description: Maximum number of nodes for autoscaling, per availability zone. | ||
|
||
Type: `string` | ||
|
||
#### min\_node\_count | ||
|
||
Description: Minimum number of nodes for autoscaling, per availability zone. | ||
|
||
Type: `string` | ||
|
||
#### name | ||
|
||
Description: The name of the node pool. A random string will be appended to this name, to allow replacement node pools to be created before destroying the current pool. | ||
|
||
Type: `string` | ||
|
||
#### region | ||
|
||
Description: The region for the node pool. | ||
|
||
Type: `string` | ||
|
||
### Optional Inputs | ||
|
||
The following input variables are optional (have default values): | ||
|
||
#### disk\_size\_in\_gb | ||
|
||
Description: Disk size, in GB, for the nodes in the pool. | ||
|
||
Type: `string` | ||
|
||
Default: `"100"` | ||
|
||
#### machine\_type | ||
|
||
Description: The machine type of nodes in the pool. | ||
|
||
Type: `string` | ||
|
||
Default: `"n1-standard-4"` | ||
|
||
|
||
## Future To-do Items | ||
|
||
* Perform additional testing of conditions that will cause Terraform to recreate the node pool, based on the `keeper`s defined in the `random_id` resource. | ||
* Determine whether, depending on results from the above testing, the node pool should have a `create_before_destroy` lifecycle. | ||
* Do we want to be able to enable auto-upgrade on node pools? | ||
* Do we want to be able to set taints on node pools? | ||
* Do we want to enable auto-repair always on node pools? |
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,7 @@ | ||
## Future To-do Items | ||
|
||
* Perform additional testing of conditions that will cause Terraform to recreate the node pool, based on the `keeper`s defined in the `random_id` resource. | ||
* Determine whether, depending on results from the above testing, the node pool should have a `create_before_destroy` lifecycle. | ||
* Do we want to be able to enable auto-upgrade on node pools? | ||
* Do we want to be able to set taints on node pools? | ||
* Do we want to enable auto-repair always on node pools? |
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,9 @@ | ||
# Terraform GKE Node Pool Module | ||
|
||
This module manages a node pool attached to a Google Kubernetes Engine (GKE) cluster. | ||
|
||
## Using The Terraform Module | ||
|
||
This module requires version 2.0.0 or above of the Google Terraform provider. | ||
|
||
See the file [example-usage](./example-usage) for an example of how to use this module. Below are the available module inputs: |
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,16 @@ | ||
# In the below example, `module.customername_cluster` is an instance of | ||
# one of the GKE modules from this repository. | ||
|
||
module "customername_cluster_node_pool" { | ||
source = "[email protected]:/reactiveops/terraform-gke//node_pool" | ||
|
||
name = "node-pool-1" | ||
region = "${module.customername_cluster.region}" | ||
gke_cluster_name = "${module.customername_cluster.name}" | ||
machine_type = "n1-standard-2" | ||
min_node_count = "1" | ||
max_node_count = "1" | ||
|
||
# Match the Kubernetes version from the GKE cluster! | ||
kubernetes_version = "${module.customername_cluster.kubernetes_version}" | ||
} |
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,33 @@ | ||
variable "name" { | ||
description = "The name of the node pool. A random string will be appended to this name, to allow replacement node pools to be created before destroying the current pool." | ||
} | ||
|
||
variable "gke_cluster_name" { | ||
description = "The name of the GKE cluster to bind this node pool." | ||
} | ||
|
||
variable "region" { | ||
description = "The region for the node pool." | ||
} | ||
|
||
variable "min_node_count" { | ||
description = "Minimum number of nodes for autoscaling, per availability zone." | ||
} | ||
|
||
variable "max_node_count" { | ||
description = "Maximum number of nodes for autoscaling, per availability zone." | ||
} | ||
|
||
variable "kubernetes_version" { | ||
description = "The kubernetes version for the nodes in the pool. This should match the Kubernetes version of the GKE cluster." | ||
} | ||
|
||
variable "machine_type" { | ||
description = "The machine type of nodes in the pool." | ||
default = "n1-standard-4" | ||
} | ||
|
||
variable "disk_size_in_gb" { | ||
description = "Disk size, in GB, for the nodes in the pool." | ||
default = "100" | ||
} |
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,54 @@ | ||
# IMPORTANT | ||
## Please BE CAREFUL when changing `keepers`. If you add a keeper | ||
## then this will cause a CREATION CASCADE! Since a new keeper | ||
## triggers a new `random_id` resource to generate then it will change | ||
## the name of the node pool, which will recreate that resource! | ||
## This is the preferred method for random naming now that | ||
## name-prefix is being deprecated! | ||
## IF YOU ADD A KEEPER YOU WILL NEED TO WARN DOWNSTREAM USERS THAT | ||
## IT WILL TRIGGER A CASCADING NODEPOOL REPLACEMENT. | ||
## The replacement should be safe because of the create_before_destroy | ||
## but will cause some questions and confusion. | ||
## All the current keepers are bound to params that will already cause | ||
## a -/+ operation for the nodepool. | ||
# https://github.com/terraform-providers/terraform-provider-google/issues/1054 | ||
resource "random_id" "entropy" { | ||
keepers { | ||
machine_type = "${var.machine_type}" | ||
name = "${var.name}" | ||
region = "${var.region}" | ||
disk_size = "${var.disk_size_in_gb}" | ||
} | ||
|
||
byte_length = 2 | ||
} | ||
|
||
resource "google_container_node_pool" "node_pool" { | ||
name = "${var.name}-${random_id.entropy.hex}" | ||
cluster = "${var.gke_cluster_name}" | ||
region = "${var.region}" | ||
version = "${var.kubernetes_version}" | ||
initial_node_count = 1 | ||
|
||
autoscaling { | ||
min_node_count = "${var.min_node_count}" | ||
max_node_count = "${var.max_node_count}" | ||
} | ||
|
||
node_config { | ||
image_type = "COS" | ||
disk_size_gb = "${var.disk_size_in_gb}" | ||
machine_type = "${var.machine_type}" | ||
|
||
oauth_scopes = [ | ||
"https://www.googleapis.com/auth/devstorage.read_only", | ||
"https://www.googleapis.com/auth/logging.write", | ||
"https://www.googleapis.com/auth/monitoring", | ||
"https://www.googleapis.com/auth/compute", | ||
] | ||
} | ||
|
||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} |
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,2 @@ | ||
# No known outputs needed | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,15 @@ | ||
# This constructs README.md, including Terraform documentation in its middle. | ||
# THIs requires `terraform-docs` to be installed from: https://github.com/segmentio/terraform-docs | ||
|
||
# The sed command below increases the markdown heading level of Terraform docs. | ||
README.md:README.pre_terraform_inputs.md README.post_terraform_inputs.md | ||
@echo Creating ReadMe with Terraform docs. . . | ||
cat README.pre_tf_inputs.md >README.md | ||
echo >>README.md | ||
terraform-docs --with-aggregate-type-defaults md document . |sed 's/^#/##/g' >>README.md | ||
echo >>README.md | ||
cat README.post_tf_inputs.md >>README.md | ||
|
||
README.pre_terraform_inputs.md: | ||
README.post_terraform_inputs.md: | ||
|
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,121 @@ | ||
# Terraform Public VPC Native GKE Cluster Module | ||
|
||
This module manages a public Google Kubernetes Engine (GKE) VPC Native cluster. The subnet CIDRs used for cluster nodes, pods, and services, are specified in the form of existing Google Compute secondary IP ranges. Use a separate Terraform module, such as [this `terraform-gcp-vpc-native` one](https://github.com/reactiveops/terraform-gcp-vpc-native), to create these network resources in advance. | ||
|
||
## Using The Terraform Module | ||
|
||
This module requires version 2.0.0 or above of the Google Terraform provider. | ||
|
||
See the file [example-usage](./example-usage) for an example of how to use this module. Below are the available module inputs: | ||
|
||
### Required Inputs | ||
|
||
The following input variables are required: | ||
|
||
#### kubernetes\_version | ||
|
||
Description: The minimum version of master nodes. This can be changed to upgrade the cluster - remember to upgrade the Kubernetes version for node pools (managed separately). | ||
|
||
Type: `string` | ||
|
||
#### name | ||
|
||
Description: The name of the GKE cluster | ||
|
||
Type: `string` | ||
|
||
#### network\_name | ||
|
||
Description: The name of an existing google_compute_network resource to which the cluster will be connected. | ||
|
||
Type: `string` | ||
|
||
#### nodes\_subnetwork\_name | ||
|
||
Description: The name of an existing google_compute_subnetwork resource where cluster compute instances are launched. | ||
|
||
Type: `string` | ||
|
||
#### pods\_secondary\_ip\_range\_name | ||
|
||
Description: The name of an existing network secondary IP range to be used for pods. | ||
|
||
Type: `string` | ||
|
||
#### region | ||
|
||
Description: The region where the GKE cluster will be created. | ||
|
||
Type: `string` | ||
|
||
#### services\_secondary\_ip\_range\_name | ||
|
||
Description: The name of an existing network secondary IP range to be used for services. | ||
|
||
Type: `string` | ||
|
||
### Optional Inputs | ||
|
||
The following input variables are optional (have default values): | ||
|
||
#### maintenance\_policy\_start\_time | ||
|
||
Description: The time (in GMT) when the cluster maintenance window will start. | ||
|
||
Type: `string` | ||
|
||
Default: `"06:00"` | ||
|
||
#### master\_authorized\_network\_cidrs | ||
|
||
Description: A list of up to 20 maps containing `master_authorized_network_cidrs` and `display_name` keys, representing source network CIDRs that are allowed to connect master nodes over HTTPS. | ||
|
||
Type: `list` | ||
|
||
Default: | ||
|
||
```json | ||
[ | ||
{ | ||
"cidr_block": "0.0.0.0/0", | ||
"display_name": "everywhere" | ||
} | ||
] | ||
``` | ||
|
||
#### project | ||
|
||
Description: The project where the GKE cluster will be created. Leave unspecified to use the project from the provider. | ||
|
||
Type: `string` | ||
|
||
Default: `""` | ||
|
||
### Outputs | ||
|
||
The following outputs are exported: | ||
|
||
#### endpoint | ||
|
||
Description: The GKE Cluster Endpoints IP | ||
|
||
#### kubernetes\_version | ||
|
||
Description: The Kubernetes version used when creating or upgrading this cluster. This does not reflect the current version of master or worker nodes. | ||
|
||
#### master\_version | ||
|
||
Description: The current version of the Kubernetes master nodes, which will differ from the kubernetes_version output if GKE upgrades masters automatically. | ||
|
||
#### name | ||
|
||
Description: The static name of the GKE cluster | ||
|
||
#### region | ||
|
||
Description: The region in which this cluster exists | ||
|
||
|
||
## Future To-do Items | ||
|
||
* Add inputs related to private VPC Native clusters, that default to false. These can be supplied by the private cluster Terraform module, which will call **this** module. |
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,3 @@ | ||
## Future To-do Items | ||
|
||
* Add inputs related to private VPC Native clusters, that default to false. These can be supplied by the private cluster Terraform module, which will call **this** module. |
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,9 @@ | ||
# Terraform Public VPC Native GKE Cluster Module | ||
|
||
This module manages a public Google Kubernetes Engine (GKE) VPC Native cluster. The subnet CIDRs used for cluster nodes, pods, and services, are specified in the form of existing Google Compute secondary IP ranges. Use a separate Terraform module, such as [this `terraform-gcp-vpc-native` one](https://github.com/reactiveops/terraform-gcp-vpc-native), to create these network resources in advance. | ||
|
||
## Using The Terraform Module | ||
|
||
This module requires version 2.0.0 or above of the Google Terraform provider. | ||
|
||
See the file [example-usage](./example-usage) for an example of how to use this module. Below are the available module inputs: |
Oops, something went wrong.