From e7d7508b8f0f13732f6d4281b7cd90bd60eb1abc Mon Sep 17 00:00:00 2001 From: GitHub Actions <> Date: Wed, 4 Oct 2023 13:15:35 +0000 Subject: [PATCH] Update docs and CHANGELOG.md --- CHANGELOG.md | 8 +++ docs/resources/kubernetes_node_pool.md | 82 ++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4d377d..2db6065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ +## [v1.0.38](https://github.com/civo/terraform-provider-civo/releases/tag/v1.0.38) (4 October 2023) + +### Merged +- [#189](https://github.com/civo/terraform-provider-civo/pull/189) - Feature/cluster pool update + +### Commits +- [6b380ba](https://github.com/civo/terraform-provider-civo/commit/6b380ba79c3e0f75914ef775a05e4401b8b1181c) - Remove comments from the node pool file that were not used + ## [v1.0.37](https://github.com/civo/terraform-provider-civo/releases/tag/v1.0.37) (1 October 2023) ### Merged diff --git a/docs/resources/kubernetes_node_pool.md b/docs/resources/kubernetes_node_pool.md index 19abb63..604fb8a 100644 --- a/docs/resources/kubernetes_node_pool.md +++ b/docs/resources/kubernetes_node_pool.md @@ -1,5 +1,4 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "civo_kubernetes_node_pool Resource - terraform-provider-civo" subcategory: "" description: |- @@ -58,11 +57,11 @@ resource "civo_kubernetes_node_pool" "back-end" { ### Optional - `label` (String) Node pool label, if you don't provide one, we will generate one for you +- `labels` (Map of String) - `node_count` (Number) the number of instances to create (optional, the default at the time of writing is 3) -- `num_target_nodes` (Number, Deprecated) the number of instances to create (optional, the default at the time of writing is 3) - `public_ip_node_pool` (Boolean) Node pool belongs to the public ip node pool - `size` (String) the size of each node (optional, the default is currently g4s.kube.medium) -- `target_nodes_size` (String, Deprecated) the size of each node (optional, the default is currently g4s.kube.medium) +- `taint` (Block Set) (see [below for nested schema](#nestedblock--taint)) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) ### Read-Only @@ -70,6 +69,16 @@ resource "civo_kubernetes_node_pool" "back-end" { - `id` (String) The ID of this resource. - `instance_names` (List of String) Instance names in the nodepool + +### Nested Schema for `taint` + +Required: + +- `effect` (String) +- `key` (String) +- `value` (String) + + ### Nested Schema for `timeouts` @@ -84,6 +93,71 @@ Optional: Import is supported using the following syntax: ```shell -# using cluster_id:node_pool_id terraform import civo_kubernetes_node_pool.my-pool 1b8b2100-0e9f-4e8f-ad78-9eb578c2a0af:502c1130-cb9b-4a88-b6d2-307bd96d946a ``` +## Taint and Labels + +The Kubernetes node pool resource supports taints and labels. These can be specified as a map of key/value pairs. For example: + +```terraform +# Query xsmall instance size +data "civo_size" "xsmall" { + filter { + key = "type" + values = ["kubernetes"] + } + + sort { + key = "ram" + direction = "asc" + } +} + +# Create a cluster +resource "civo_kubernetes_cluster" "my-cluster" { + name = "my-cluster" + applications = "Portainer,Linkerd:Linkerd & Jaeger" + firewall_id = civo_firewall.my-firewall.id + + node_pool { + size = element(data.civo_size.xsmall.sizes, 0).name + node_count = 3 + } +} + +# Add a node pool +resource "civo_kubernetes_node_pool" "back-end" { + cluster_id = civo_kubernetes_cluster.my-cluster.id + label = "back-end" // Optional + node_count = 1 // Optional + size = element(data.civo_size.xsmall.sizes, 0).name // Optional + region = "LON1" + + labels = { + service = "backend" + priority = "high" + } + + taint { + key = "workloadKind" + value = "database" + effect = "NoSchedule" + } + + taint { + key = "workloadKind" + value = "frontend" + effect = "NoSchedule" + } +} +``` + +### Taints + +Taints are used to repel pods from nodes. They can be used to repel pods from nodes with certain hardware, or to repel pods from nodes that are running certain services. For example, you may want to repel pods from nodes that are running a database, or from nodes that are running a monitoring agent. +Taints have to currently be removed from nodes using the kubectl command in addition to being removed from a Terraform configuration. For example: + +```shell +kubectl taint nodes node-1 key=value:NoSchedule- +``` +This will be automated in a future release of the provider. Removing a taint from Terraform will prevent the node from being tainted again if node pools with the taints are altered or scaled.