civo / terraform-provider-civo

Terraform Civo provider
https://www.civo.com
Mozilla Public License 2.0
65 stars 51 forks source link

Unable to add node pools #134

Closed nlamirault closed 2 years ago

nlamirault commented 2 years ago

On an existing cluster created by Terraform, i can't add node pools:

resource "civo_kubernetes_node_pool" "this" {
  count = length(var.node_pools)

  cluster_id = civo_kubernetes_cluster.this.id
  region     = var.node_pools[count.index].region
  label      = var.node_pools[count.index].label
  node_count = var.node_pools[count.index].node_count
  size       = var.node_pools[count.index].size
}

Variables :

node_pools = [
  {
    label          = "core"
    node_count = 1
    size = "standard.medium"
    region = "LON1"
  },
  {
    label          = "addons"
    node_count = 0
    size = "standard.medium"
    region = "LON1"
  }
]

The execution:

Terraform will perform the following actions:

  # module.kubernetes.civo_kubernetes_cluster.this will be updated in-place
  ~ resource "civo_kubernetes_cluster" "this" {
        id                     = "7762ada3-66c8-457f-a7b9-1fc7f91a2760"
        name                   = "portefaix-dev-civo"
      + tags                   = "terraform dev kubernetes"
        # (15 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

  # module.kubernetes.civo_kubernetes_node_pool.this[0] will be created
  + resource "civo_kubernetes_node_pool" "this" {
      + cluster_id     = "7762ada3-66c8-457f-a7b9-1fc7f91a2760"
      + id             = (known after apply)
      + instance_names = (known after apply)
      + label          = "core"
      + node_count     = 1
      + region         = "LON1"
      + size           = "standard.medium"
    }

  # module.kubernetes.civo_kubernetes_node_pool.this[1] will be created
  + resource "civo_kubernetes_node_pool" "this" {
      + cluster_id     = "7762ada3-66c8-457f-a7b9-1fc7f91a2760"
      + id             = (known after apply)
      + instance_names = (known after apply)
      + label          = "addons"
      + node_count     = 0
      + region         = "LON1"
      + size           = "standard.medium"
    }

Plan: 2 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.kubernetes.civo_kubernetes_cluster.this: Modifying... [id=7762ada3-66c8-457f-a7b9-1fc7f91a2760]
module.kubernetes.civo_kubernetes_cluster.this: Modifications complete after 1s [id=7762ada3-66c8-457f-a7b9-1fc7f91a2760]
module.kubernetes.civo_kubernetes_node_pool.this[1]: Creating...
module.kubernetes.civo_kubernetes_node_pool.this[0]: Creating...
╷
│ Error: [ERR] failed to create the kubernetes cluster: DatabaseServiceNotFoundError: Failed to find the size within the internal database
│
│   with module.kubernetes.civo_kubernetes_node_pool.this[1],
│   on .terraform/modules/kubernetes/node_pools.tf line 15, in resource "civo_kubernetes_node_pool" "this":
│   15: resource "civo_kubernetes_node_pool" "this" {
│
╵
╷
│ Error: [ERR] failed to create the kubernetes cluster: DatabaseServiceNotFoundError: Failed to find the size within the internal database
│
│   with module.kubernetes.civo_kubernetes_node_pool.this[0],
│   on .terraform/modules/kubernetes/node_pools.tf line 15, in resource "civo_kubernetes_node_pool" "this":
│   15: resource "civo_kubernetes_node_pool" "this" {
│
╵
alejandrojnm commented 2 years ago

you need check the size, look here https://registry.terraform.io/providers/civo/civo/latest/docs/data-sources/size

example:

# Query xsmall instance size
data "civo_size" "xsmall" {
    filter {
        key = "type"
        values = ["kubernetes"]
    }

    sort {
        key = "ram"
        direction = "asc"
    }
}
nlamirault commented 2 years ago

Sure. I made a mistake on my size names :( Sorry for noise