vmware / terraform-provider-tanzu-mission-control

Terraform provider to manage resources of Tanzu Mission Control
Mozilla Public License 2.0
38 stars 31 forks source link

Cannot provision TKG workload clusters with TKG 2.2 #193

Closed adam-power closed 1 year ago

adam-power commented 1 year ago

Describe the bug

I am trying to create a workload cluster using TKGm 2.2 on vSphere. When I run terraform apply, I get the following error message:

tanzu-mission-control_cluster.tool: Creating...
╷
│ Error: Unable to create Tanzu Mission Control cluster entry, name : tool: POST request failed with status : 400 Bad Request, response: {"error":"Only support to provision clusters using ClusterClass on TKG 2.1.0+","code":9,"message":"Only support to provision clusters using ClusterClass on TKG 2.1.0+"}
│
│   with tanzu-mission-control_cluster.tool,
│   on tool-cluster.tf line 2, in resource "tanzu-mission-control_cluster" "tool":
│    2: resource "tanzu-mission-control_cluster" "tool" {

The error says it is only supported to provision clusters on TKG 2.1.0+, but I am on a newer version so this should not be an issue. I have verified that I can manually provision workload clusters using the TMC UI.

Reproduction steps

  1. Set up the Terraform provider file provider.tf with the following contents:
terraform {
  required_providers {
    tanzu-mission-control = {
      source = "vmware/tanzu-mission-control"
      version = "1.1.8"
    }
  }
}

provider "tanzu-mission-control" {
  endpoint            = "<REDACTED>"
  vmw_cloud_api_token = "<REDACTED>"
}
  1. Manually create a cluster group in TMC. Then create a file called cluster_group.tf to reference it:
data "tanzu-mission-control_cluster_group" "apower" {
  name = "apower"
}
  1. Manually create a TKG 2.2 management cluster in vSphere, and attach it to TMC.

  2. Create a workload cluster file called tool-cluster.tf with the following contents:

# Create a Tanzu Kubernetes Grid Vsphere workload cluster entry
resource "tanzu-mission-control_cluster" "tool" {
  management_cluster_name = "apower-h2o-mgmt"
  provisioner_name        = "default"
  name                    = "tool"

#   meta {
#     description = "description of the cluster"
#     labels      = { "key" : "value" }
#   }

  spec {
    cluster_group = data.tanzu-mission-control_cluster_group.apower.name
    tkg_vsphere {
#       advanced_configs {
#         key = "AVI_LABELS"
#         value = "test"
#       }
      settings {
        network {
          pods {
            cidr_blocks = [
              "172.20.0.0/16", # pods cidr block by default has the value `172.20.0.0/16`
            ]
          }

          services {
            cidr_blocks = [
              "10.96.0.0/16", # services cidr block by default has the value `10.96.0.0/16`
            ]
          }

          api_server_port = 6443
          control_plane_end_point = "10.220.55.100" # optional for AVI enabled option
        }

        security {
          ssh_key = "<REDACTED>"
        }
      }

      distribution {
        os_arch = "amd64"
        os_name = "photon"
        os_version = "3"
    version = "v1.25.7+vmware.2-tkg.1"

        workspace {
          datacenter        = "/vc01"
          datastore         = "/vc01/datastore/vsanDatastore"
          workspace_network = "/vc01/network/user-workload"
          folder            = "/vc01/vm/tkg"
          resource_pool     = "/vc01/host/vc01cl01/Resources"
        }
      }

      topology {
        control_plane {
          vm_config {
            cpu       = "8"
            disk_size = "256"
            memory    = "16384"
          }

          high_availability = false
        }

        node_pools {
          spec {
            worker_node_count = "3"

            tkg_vsphere {
              vm_config {
                cpu       = "4"
                disk_size = "256"
                memory    = "8192"
              }
            }
          }

          info {
            name        = "default-nodepool" # default node pool name `default-nodepool`
            description = "my nodepool"
          }
        }
      }
    }
  }
}
  1. Execute Terraform init and terraform apply:
terraform init
terraform apply

Expected behavior

I should be able to create a workload cluster with the TMC Terraform provider.

Additional context

No response

ramya-bangera commented 1 year ago

@adam-power - Yes currently the TMC terraform provider does support creation of cluster class based clusters , this is a work in progress. So it is a new feature request which we are already tracking.

ramya-bangera commented 1 year ago

Resolving this issue as duplicate of existing feature request issue #115

adam-power commented 1 year ago

Hi @ramya-bangera , thanks for the info. I can't see much info on that feature request #115 , is there somewhere I can track the feature better? I work for VMware, so if there are internal Jiras or something you can send them to me on Slack.