diff --git a/examples/gcve-cluster/main.tf b/examples/gcve-cluster/main.tf new file mode 100644 index 0000000..2941901 --- /dev/null +++ b/examples/gcve-cluster/main.tf @@ -0,0 +1,25 @@ +/** + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module "gcve-cluster" { + source = "../../modules/gcve-cluster" + project = var.project + gcve_zone = var.gcve_zone + pc_name = var.pc_name + cluster_name = var.cluster_name + cluster_node_type = var.cluster_node_type + cluster_node_count = var.cluster_node_count +} diff --git a/examples/gcve-cluster/outputs.tf b/examples/gcve-cluster/outputs.tf new file mode 100644 index 0000000..852f1c6 --- /dev/null +++ b/examples/gcve-cluster/outputs.tf @@ -0,0 +1,20 @@ +/** + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +output "cluster" { + description = "The cluster resource" + value = module.gcve-cluster.cluster +} diff --git a/examples/gcve-cluster/variables.tf b/examples/gcve-cluster/variables.tf new file mode 100644 index 0000000..25af9a0 --- /dev/null +++ b/examples/gcve-cluster/variables.tf @@ -0,0 +1,53 @@ +/** + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +variable "project" { + type = string + description = "Project where private cloud will be deployed" +} + +variable "cluster_name" { + type = string + description = "Name of the ESXi cluster." +} + +variable "gcve_zone" { + type = string + description = "Zone of the private cloud" +} + +variable "pc_name" { + type = string + description = "Name of the private cloud that will be deployed" +} + +variable "cluster_node_type" { + type = string + description = "Specify the node type for the management cluster in the private cloud" + default = "standard-72" +} + +variable "cluster_node_count" { + type = number + description = "Specify the number of nodes for the management cluster in the private cloud" + default = 3 +} + +variable "custom_core_count" { + type = number + description = "Specify the number of cores available to each node of the cluster. The value 0 will use the largest amount of available cores on each node in the cluster." + default = 0 +} diff --git a/examples/gcve-cluster/versions.tf b/examples/gcve-cluster/versions.tf new file mode 100644 index 0000000..68ee22a --- /dev/null +++ b/examples/gcve-cluster/versions.tf @@ -0,0 +1,27 @@ +/** + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +terraform { + required_version = ">= 1.3.0" + + required_providers { + google-beta = { + source = "hashicorp/google-beta" + version = ">= 4.71.0" + } + } +} + diff --git a/modules/gcve-cluster/README.md b/modules/gcve-cluster/README.md new file mode 100644 index 0000000..d4d03f7 --- /dev/null +++ b/modules/gcve-cluster/README.md @@ -0,0 +1,58 @@ +# GCVE ESXi Cluster module + +This module contains the terraform to deploy an ESXi cluster into a private cloud + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.3.0 | +| [google-beta](#requirement\_google-beta) | >= 4.71.0 | + +## Usage +Basic usage of this module is as follows: + +```hcl +module "example" { + source = "" + + # Required variables + cluster_name = + gcve_zone = + pc_name = + project = + + # Optional variables + cluster_node_count = 3 + cluster_node_type = "standard-72" + custom_core_count = 0 +} +``` + +## Resources + +| Name | Type | +|------|------| +| [google-beta_google_vmwareengine_cluster.esxi-cluster](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/google_vmwareengine_cluster) | resource | +| [google-beta_google_vmwareengine_private_cloud.private_cloud](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/data-sources/google_vmwareengine_private_cloud) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [cluster\_name](#input\_cluster\_name) | Name of the ESXi cluster. | `string` | n/a | yes | +| [cluster\_node\_count](#input\_cluster\_node\_count) | Specify the number of nodes for the management cluster in the private cloud | `number` | `3` | no | +| [cluster\_node\_type](#input\_cluster\_node\_type) | Specify the node type for the management cluster in the private cloud | `string` | `"standard-72"` | no | +| [custom\_core\_count](#input\_custom\_core\_count) | Specify the number of cores available to each node of the cluster. The value 0 will use the largest amount of available cores on each node in the cluster. | `number` | `0` | no | +| [gcve\_zone](#input\_gcve\_zone) | Zone of the private cloud | `string` | n/a | yes | +| [pc\_name](#input\_pc\_name) | Name of the private cloud that will be deployed | `string` | n/a | yes | +| [project](#input\_project) | Project where private cloud will be deployed | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [cluster](#output\_cluster) | The cluster resource | + + \ No newline at end of file diff --git a/modules/gcve-cluster/main.tf b/modules/gcve-cluster/main.tf new file mode 100644 index 0000000..a627b07 --- /dev/null +++ b/modules/gcve-cluster/main.tf @@ -0,0 +1,33 @@ +/** + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +data "google_vmwareengine_private_cloud" "private_cloud" { + provider = google-beta + project = var.project + name = var.pc_name + location = var.gcve_zone +} + +resource "google_vmwareengine_cluster" "esxi-cluster" { + provider = google-beta + name = var.cluster_name + parent = data.google_vmwareengine_private_cloud.private_cloud.id + node_type_configs { + node_type_id = var.cluster_node_type + node_count = var.cluster_node_count + custom_core_count = var.custom_core_count + } +} diff --git a/modules/gcve-cluster/outputs.tf b/modules/gcve-cluster/outputs.tf new file mode 100644 index 0000000..b4553c1 --- /dev/null +++ b/modules/gcve-cluster/outputs.tf @@ -0,0 +1,20 @@ +/** + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +output "cluster" { + description = "The cluster resource" + value = google_vmwareengine_cluster.esxi-cluster +} diff --git a/modules/gcve-cluster/variables.tf b/modules/gcve-cluster/variables.tf new file mode 100644 index 0000000..25af9a0 --- /dev/null +++ b/modules/gcve-cluster/variables.tf @@ -0,0 +1,53 @@ +/** + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +variable "project" { + type = string + description = "Project where private cloud will be deployed" +} + +variable "cluster_name" { + type = string + description = "Name of the ESXi cluster." +} + +variable "gcve_zone" { + type = string + description = "Zone of the private cloud" +} + +variable "pc_name" { + type = string + description = "Name of the private cloud that will be deployed" +} + +variable "cluster_node_type" { + type = string + description = "Specify the node type for the management cluster in the private cloud" + default = "standard-72" +} + +variable "cluster_node_count" { + type = number + description = "Specify the number of nodes for the management cluster in the private cloud" + default = 3 +} + +variable "custom_core_count" { + type = number + description = "Specify the number of cores available to each node of the cluster. The value 0 will use the largest amount of available cores on each node in the cluster." + default = 0 +} diff --git a/modules/gcve-cluster/versions.tf b/modules/gcve-cluster/versions.tf new file mode 100644 index 0000000..68ee22a --- /dev/null +++ b/modules/gcve-cluster/versions.tf @@ -0,0 +1,27 @@ +/** + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +terraform { + required_version = ">= 1.3.0" + + required_providers { + google-beta = { + source = "hashicorp/google-beta" + version = ">= 4.71.0" + } + } +} +