├── .gitignore ├── versions.tf ├── nodepool.tf ├── variables.tf └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .terraform* 2 | -------------------------------------------------------------------------------- /versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0.0" 3 | 4 | required_providers { 5 | ovh = { 6 | source = "ovh/ovh" 7 | version = "~> 2.5.0" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /nodepool.tf: -------------------------------------------------------------------------------- 1 | resource "ovh_cloud_project_kube_nodepool" "node_pool" { 2 | service_name = var.project_id 3 | kube_id = var.cluster_id 4 | name = var.name 5 | flavor_name = var.flavor_name 6 | desired_nodes = var.nodes 7 | max_nodes = var.max_nodes < 1 ? var.nodes : var.max_nodes 8 | min_nodes = var.min_nodes < 1 ? var.nodes : var.min_nodes 9 | monthly_billed = var.monthly_billed 10 | availability_zones = var.availability_zones 11 | 12 | dynamic "template" { 13 | for_each = var.template != null ? [1] : [] 14 | 15 | content { 16 | metadata { 17 | annotations = var.template["annotations"] 18 | finalizers = var.template["finalizers"] 19 | labels = var.template["labels"] 20 | } 21 | spec { 22 | unschedulable = var.template["unschedulable"] 23 | taints = var.template["taints"] 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "project_id" { 2 | description = "The ID of the Public Cloud project the resources will be created in." 3 | type = string 4 | } 5 | 6 | variable "cluster_id" { 7 | description = "ID of the cluster for the nodepool." 8 | type = string 9 | } 10 | 11 | variable "name" { 12 | description = "Name to give the nodepool." 13 | type = string 14 | } 15 | 16 | variable "flavor_name" { 17 | description = "The type of nodes to use for this nodepool." 18 | type = string 19 | } 20 | 21 | variable "nodes" { 22 | description = "Number of nodes in this nodepool." 23 | type = number 24 | } 25 | 26 | variable "min_nodes" { 27 | description = "Maximum number of nodes this nodepool can have." 28 | type = number 29 | default = 0 30 | } 31 | 32 | variable "max_nodes" { 33 | description = "Minimum number of nodes this nodepool can have." 34 | type = number 35 | default = 0 36 | } 37 | 38 | variable "availability_zones" { 39 | description = "Availability zones to create the nodes in (for multi-AZ clusters)." 40 | type = list(string) 41 | default = [] 42 | } 43 | 44 | variable "monthly_billed" { 45 | description = "Should the nodes be billed on a monthly basis." 46 | type = bool 47 | default = false 48 | } 49 | 50 | variable "template" { 51 | description = "Nodepool template for applying metadata." 52 | type = object({ 53 | annotations = optional(map(any), {}) 54 | labels = optional(map(any), {}) 55 | finalizers = optional(list(string), []) 56 | unschedulable = optional(bool, false) 57 | taints = optional(list(object({ 58 | effect = string 59 | key = string 60 | value = string 61 | })), []) 62 | }) 63 | default = null 64 | } 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mastodon Terraform - OVHCloud Kubernetes Nodepool 2 | 3 | Creates a nodepool for a Managed Kubernetes cluster in OVH. 4 | 5 | While the [full kubernetes module](https://github.com/mastodon/terraform-ovh-k8s) also supports nodepools, there are some situations where nodepools need to be created and deleted ad-hoc. This makes that situation easier to manage by allowing the management of each nodepool separately. 6 | 7 | ## Requirements 8 | 9 | | Name | Version | 10 | |------|---------| 11 | | [terraform](#requirement\_terraform) | >= 1.0.0 | 12 | | [ovh](#requirement\_ovh) | ~> 2.5.0 | 13 | 14 | ## Providers 15 | 16 | | Name | Version | 17 | |------|---------| 18 | | [ovh](#provider\_ovh) | 2.5.0 | 19 | 20 | ## Modules 21 | 22 | No modules. 23 | 24 | ## Resources 25 | 26 | | Name | Type | 27 | |------|------| 28 | | [ovh_cloud_project_kube_nodepool.node_pool](https://registry.terraform.io/providers/ovh/ovh/latest/docs/resources/cloud_project_kube_nodepool) | resource | 29 | 30 | ## Inputs 31 | 32 | | Name | Description | Type | Default | Required | 33 | |------|-------------|------|---------|:--------:| 34 | | [availability\_zones](#input\_availability\_zones) | Availability zones to create the nodes in (for multi-AZ clusters). | `list(string)` | `[]` | no | 35 | | [cluster\_id](#input\_cluster\_id) | ID of the cluster for the nodepool. | `string` | n/a | yes | 36 | | [flavor\_name](#input\_flavor\_name) | The type of nodes to use for this nodepool. | `string` | n/a | yes | 37 | | [max\_nodes](#input\_max\_nodes) | Minimum number of nodes this nodepool can have. | `number` | `0` | no | 38 | | [min\_nodes](#input\_min\_nodes) | Maximum number of nodes this nodepool can have. | `number` | `0` | no | 39 | | [monthly\_billed](#input\_monthly\_billed) | Should the nodes be billed on a monthly basis. | `bool` | `false` | no | 40 | | [name](#input\_name) | Name to give the nodepool. | `string` | n/a | yes | 41 | | [nodes](#input\_nodes) | Number of nodes in this nodepool. | `number` | n/a | yes | 42 | | [project\_id](#input\_project\_id) | The ID of the Public Cloud project the resources will be created in. | `string` | n/a | yes | 43 | | [template](#input\_template) | Nodepool template for applying metadata. |
object({
annotations = optional(map(any), {})
labels = optional(map(any), {})
finalizers = optional(list(string), [])
unschedulable = optional(bool, false)
taints = optional(list(object({
effect = string
key = string
value = string
})), [])
})
| `null` | no | 44 | 45 | ## Outputs 46 | 47 | No outputs. 48 | --------------------------------------------------------------------------------