Skip to content

Commit

Permalink
[WIP] Add initial node count, node metadata and min cpu platform to i…
Browse files Browse the repository at this point in the history
…gnore_changes block (#50)

* Add initial node count, node metadata and min cpu platform to ignore_changes block

* update docs

* Changelog
  • Loading branch information
katiekeel authored Oct 21, 2022
1 parent 0d8a051 commit 94f13f6
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 40 deletions.
3 changes: 3 additions & 0 deletions node_pool/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# node-pool-v3.8.0
- Added the following values to ignore_changes on the node pool, since they aren't commonly configured but instead set by GKE: `initial_node_count`, `node_config.0.metadata` and `node_config.0.min_cpu_platform`

# node-pool-v3.7.0
- Added the ability to use spot vms on a node pool. This can be enabled by setting the variable `spot_nodes` to true. This can only be enabled on new node pools and cannot be toggled after creation. Can only be used with GKE 1.22+.

Expand Down
36 changes: 32 additions & 4 deletions node_pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,38 @@ Type: `bool`

Default: `false`

## Future To-do Items
#### image_type

Description: The OS image to be used for the nodes.

Type: `string`

Default: none

#### spot_nodes

Description: Whether to use spot nodes in this pool.

Type: `bool`

Default: `false`

#### enable_secure_boot

* 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.
Description: If shielded nodes is enabled at the cluster level, you can optionally set this to enable secure boot on shielded nodes.

Type: `bool`

Default: `false`

#### taint

Description: Dictionary of effect, key and value to apply on nodes in pool. Only one is allowed.

Type: `map`

Default: `null`

## Future To-do Items
* 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?
73 changes: 37 additions & 36 deletions node_pool/inputs.tf
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
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 "kubernetes_version" {
description = "The kubernetes version for the nodes in the pool. This should match the Kubernetes version of the GKE cluster."
}

variable "initial_node_count" {
description = "The initial node count for the pool, per availability zone. Changing this will force recreation of the resource."
default = "1"
variable "max_node_count" {
description = "Maximum number of nodes for autoscaling, per availability zone."
}

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 "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 "kubernetes_version" {
description = "The kubernetes version for the nodes in the pool. This should match the Kubernetes version of the GKE cluster."
variable "region" {
description = "The region for the node pool."
}

variable "image_type" {
description = "The OS image to be used for the nodes."
default = "COS"
variable "disk_size_in_gb" {
description = "Disk size, in GB, for the nodes in the pool."
default = "100"
}

variable "machine_type" {
description = "The machine type of nodes in the pool."
default = "n1-standard-4"
variable "disk_type" {
description = "Type of the disk attached to each node"
default = "pd-standard"
}

variable "disk_size_in_gb" {
description = "Disk size, in GB, for the nodes in the pool."
default = "100"
variable "initial_node_count" {
description = "The initial node count for the pool, per availability zone. This has been ignored on the node pool module resource. Remove it from ignore_changes if you want to set it yourself, but 1 is usually sufficient."
default = "1"
}

variable "node_tags" {
type = list
description = "List of strings for tags on node pool VMs. These are generally used for firewall rules."
default = []
variable "machine_type" {
description = "The machine type of nodes in the pool."
default = "n1-standard-4"
}

variable "node_labels" {
Expand All @@ -54,9 +48,16 @@ variable "node_labels" {
default = {}
}

variable "disk_type" {
description = "Type of the disk attached to each node"
default = "pd-standard"
variable "node_metadata" {
description = "Specifies how node metadata is exposed to the workload running on the node. Set to `GKE_METADATA` to enable workload identity"
default = "UNSPECIFIED"
type = string
}

variable "node_tags" {
type = list
description = "List of strings for tags on node pool VMs. These are generally used for firewall rules."
default = []
}

variable "additional_oauth_scopes" {
Expand All @@ -80,25 +81,25 @@ variable "preemptible_nodes" {
default = false
}

variable "image_type" {
description = "The OS image to be used for the nodes."
default = "COS"
}

variable "spot_nodes"{
type = bool
description = "Whether to use spot nodes"
default = false
}

variable "node_metadata" {
description = "Specifies how node metadata is exposed to the workload running on the node. Set to `GKE_METADATA` to enable workload identity"
default = "UNSPECIFIED"
type = string
}

variable "enable_secure_boot" {
type = bool
description = "If shielded nodes is enabled at the cluster level, you can optionally set this to enable secure boot on shielded nodes."
default = false
}

variable "taint" {
description = "Key value pairs of taints to apply on nodes in the pool"
description = "Dictionary of effect, key and value to apply on nodes in pool"
type = map
default = null
}
5 changes: 5 additions & 0 deletions node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,10 @@ resource "google_container_node_pool" "node_pool" {

lifecycle {
create_before_destroy = true
ignore_changes = [
initial_node_count,
node_config.0.metadata,
node_config.0.min_cpu_platform
]
}
}

0 comments on commit 94f13f6

Please sign in to comment.