|
| 1 | +--- |
| 2 | +Title: "Provisioning of a workload cluster" |
| 3 | +Description: |- |
| 4 | + An example of provisioning a TKGs and a TKGm workload cluster. |
| 5 | +--- |
| 6 | + |
| 7 | +# TKGs Workload Cluster |
| 8 | + |
| 9 | +The TKGs workload cluster can be provisioned through the terraform provider using the following example. For the |
| 10 | +provisioning, it is expected that the user already has a management cluster registered of the kind `vSphere with Tanzu` |
| 11 | +on their TMC instance. The following example demonstrates the resource of a TKG Service Vsphere workload cluster: |
| 12 | + |
| 13 | +```terraform |
| 14 | +// TMC Cluster Type: TKGServiceVsphere workload. |
| 15 | +// Operations supported : Read, Create, Update & Delete (except nodepools) |
| 16 | +
|
| 17 | +// Read TMC TKG Service Vsphere workload cluster : fetch cluster details |
| 18 | +data "tmc_cluster" "ready_only_cluster_view" { |
| 19 | + management_cluster_name = "<management-cluster>" // Required |
| 20 | + provisioner_name = "<prov-name>" // Required |
| 21 | + name = "<cluster-name>" // Required |
| 22 | +} |
| 23 | +
|
| 24 | +# Create TMC TKG Service Vsphere workload cluster entry |
| 25 | +resource "tmc_cluster" "create_tkgs_workload" { |
| 26 | + management_cluster_name = "<management-cluster>" |
| 27 | + provisioner_name = "<prov-name>" |
| 28 | + name = "<cluster-name>" |
| 29 | +
|
| 30 | + meta { |
| 31 | + labels = { "key" : "test" } |
| 32 | + } |
| 33 | +
|
| 34 | + spec { |
| 35 | + cluster_group = "<cluster-group>" // Default: default |
| 36 | + tkg_service_vsphere { |
| 37 | + settings { |
| 38 | + network { |
| 39 | + pods { |
| 40 | + cidr_blocks = [ |
| 41 | + "<pods-cidr-blocks>", // Required |
| 42 | + ] |
| 43 | + } |
| 44 | + services { |
| 45 | + cidr_blocks = [ |
| 46 | + "<services-cidr-blocks>", // Required |
| 47 | + ] |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | +
|
| 52 | + distribution { |
| 53 | + version = "<version>" // Required |
| 54 | + } |
| 55 | +
|
| 56 | + topology { |
| 57 | + control_plane { |
| 58 | + class = "<class>" // Required |
| 59 | + storage_class = "<storage-class" // Required |
| 60 | + high_availability = false // Default: false |
| 61 | + } |
| 62 | + node_pools { |
| 63 | + spec { |
| 64 | + worker_node_count = "<worker-node-count>" // Required |
| 65 | + cloud_label = { |
| 66 | + "<key>" : "<val>" |
| 67 | + } |
| 68 | + node_label = { |
| 69 | + "<key>" : "<val>" |
| 70 | + } |
| 71 | + tkg_service_vsphere { |
| 72 | + class = "<class>" // Required |
| 73 | + storage_class = "<storage-class>" // Required |
| 74 | + } |
| 75 | + } |
| 76 | + info { |
| 77 | + name = "<node-pool-name>" // Required |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +# TKGm Vsphere Workload Cluster |
| 87 | + |
| 88 | +The TKGm Vsphere workload cluster can be provisioned through the terraform provider using the following example. For the |
| 89 | +provisioning, it is expected that the user already has a management cluster registered of the kind `Tanzu Kubernetes Grid` |
| 90 | +on their TMC instance. The following example demonstrates the resource of a TKGm Vsphere workload cluster: |
| 91 | + |
| 92 | +```terraform |
| 93 | +// TMC Cluster Type: TKGVsphere workload. |
| 94 | +// Operations supported : Read, Create, Update & Delete (except nodepools) |
| 95 | +
|
| 96 | +// Read TMC TKG Vsphere workload cluster : fetch cluster details |
| 97 | +data "tmc_cluster" "ready_only_cluster_view" { |
| 98 | + management_cluster_name = "<management-cluster>" // Required |
| 99 | + provisioner_name = "<prov-name>" // Required |
| 100 | + name = "<cluster-name>" // Required |
| 101 | +} |
| 102 | +
|
| 103 | +// Create TMC TKG Vsphere workload cluster entry |
| 104 | +resource "tmc_cluster" "create_tkg_vsphere_cluster" { |
| 105 | + management_cluster_name = "<management-cluster>" // Default: attached |
| 106 | + provisioner_name = "<prov-name>" // Default: attached |
| 107 | + name = "<cluster-name>" // Required |
| 108 | +
|
| 109 | + meta { |
| 110 | + description = "description of the cluster" |
| 111 | + labels = { "key" : "value" } |
| 112 | + } |
| 113 | +
|
| 114 | + spec { |
| 115 | + cluster_group = "<cluster-group>" // Default: default |
| 116 | + tkg_vsphere { |
| 117 | + settings { |
| 118 | + network { |
| 119 | + pods { |
| 120 | + cidr_blocks = [ |
| 121 | + "<pods-cidr-blocks>", // Required |
| 122 | + ] |
| 123 | + } |
| 124 | +
|
| 125 | + services { |
| 126 | + cidr_blocks = [ |
| 127 | + "<services-cidr-blocks>", // Required |
| 128 | + ] |
| 129 | + } |
| 130 | +
|
| 131 | + control_plane_end_point = "<end-point>" // Required |
| 132 | + } |
| 133 | +
|
| 134 | + security { |
| 135 | + ssh_key = "<ssh-key>" // Required |
| 136 | + } |
| 137 | + } |
| 138 | +
|
| 139 | + distribution { |
| 140 | + version = "<version>" // Required |
| 141 | +
|
| 142 | + workspace { |
| 143 | + datacenter = "<datacenter>" // Required |
| 144 | + datastore = "<datastore>" // Required |
| 145 | + workspace_network = "<workspace_network>" // Required |
| 146 | + folder = "<folder>" // Required |
| 147 | + resource_pool = "<resource_pool>" // Required |
| 148 | + } |
| 149 | + } |
| 150 | +
|
| 151 | + topology { |
| 152 | + control_plane { |
| 153 | + vm_config { |
| 154 | + cpu = "<cpu>" // Required |
| 155 | + disk_size = "<disk_size>" // Required |
| 156 | + memory = "<memory>" // Required |
| 157 | + } |
| 158 | +
|
| 159 | + high_availability = false // Default: false |
| 160 | + } |
| 161 | +
|
| 162 | + node_pools { |
| 163 | + spec { |
| 164 | + worker_node_count = "<worker-node-count>" // Required |
| 165 | + cloud_label = { |
| 166 | + "<key>" : "<val>" |
| 167 | + } |
| 168 | + node_label = { |
| 169 | + "<key>" : "<val>" |
| 170 | + } |
| 171 | +
|
| 172 | + tkg_vsphere { |
| 173 | + vm_config { |
| 174 | + cpu = "<cpu>" // Required |
| 175 | + disk_size = "<disk_size>" // Required |
| 176 | + memory = "<memory>" // Required |
| 177 | + } |
| 178 | + } |
| 179 | + } |
| 180 | +
|
| 181 | + info { |
| 182 | + name = "<node-pool-name>" // Required |
| 183 | + description = "<node-pool-description>" |
| 184 | + } |
| 185 | + } |
| 186 | + } |
| 187 | + } |
| 188 | + } |
| 189 | +} |
| 190 | +``` |
| 191 | + |
| 192 | +When you apply these configurations it will create the respective workload cluster on the chosen management cluster. |
| 193 | +If you need to update the cluster, you simply make an update to the rule definition and Terraform will |
| 194 | +apply/update it across all the sites. If you add / or remove a site from the list, Terraform will also |
| 195 | +handle creating or removing the rule on the subsequent `terraform apply`. |
0 commit comments