Setting boot disk size for autoscaling kubernetes cluster through Terraform

9/29/2021

I am trying to add the boot disk size to the node auto-provisioned Kubernetes cluster as follows:

resource "google_container_cluster" "gc-dev-kube-ds0" {
        .
        .
        .

      cluster_autoscaling {
    enabled = true

    resource_limits {
      resource_type = "cpu"
      minimum       = 4
      maximum       = 150
    }

    resource_limits {
      resource_type = "memory"
      minimum       = 4
      maximum       = 600
    }

    resource_limits {
      resource_type = "nvidia-tesla-v100"
      minimum       = 0
      maximum       = 4
    }

  }

  disk_size_gb = 200
}

but I am getting the following error:

Error: Unsupported argument

  on kubernetes.tf line 65, in resource "google_container_cluster" "gc-dev-kube-ds0":
  65:   disk_size_gb = 200

An argument named "disk_size_gb" is not expected here.

Also checked the terraform documentation but nothing is mentioned on this.

-- Ajit K'sagar
google-cloud-platform
kubernetes
terraform

1 Answer

9/29/2021

The error is getting because the disk_size_gb module must be in the node_config block, as the following.

node_config {
      disk_size_gb = 200
}

The TerraForm documentation about google_container_cluster the module needs to be under the block.

enter image description here

-- Nadia Espinosa
Source: StackOverflow