diff --git a/README.md b/README.md index 36c8314..19806e4 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) # Spectro Cloud Tutorials + A collection of Spectro Cloud tutorials and their respective sample code.

drawing

- The following tutorial code is available: + - [hello-universe-tf](./terraform/hello-universe-tf/README.md) - Deploy the Hello Universe application into two Palette Virtual Clusters. [Link](https://docs.spectrocloud.com/devx/apps/deploy-app) to the tutorial. - [pack-tf](./terraform/pack-tf/README.md) - Learn how to create a custom pack. [Link](https://docs.spectrocloud.com/registries-and-packs/deploy-pack) @@ -19,9 +20,11 @@ The following tutorial code is available: - [Deploy an Edge cluster on VMware](./edge/vmware/README.md) - Learn how to deploy an Edge cluster on VMware. [Link](https://docs.spectrocloud.com/clusters/edge/site-deployment/deploy-cluster) +- [vmware-cluster-deployment-tf](./terraform/vmware-cluster-deployment-tf/README.md) - Learn how to deploy a VMware cluster and the Hello Universe application as a part of the Deploy App Workloads with a PCG tutorial. [Link](https://docs.spectrocloud.com/clusters/pcg/deploy-app-pcg) + ## Docker -All the tutorials are available in a Docker image that you can use to get started with the tutorials. +All the tutorials are available in a Docker image that you can use to get started with the tutorials. Review the [Docker steps](./docs/docker.md) to get started with the Docker image. ## Image Verification diff --git a/terraform/vmware-cluster-deployment-tf/README.md b/terraform/vmware-cluster-deployment-tf/README.md index 582d6e2..3dd98c8 100644 --- a/terraform/vmware-cluster-deployment-tf/README.md +++ b/terraform/vmware-cluster-deployment-tf/README.md @@ -1,6 +1,6 @@ # Hello Universe TF -This folder contains the demo code for the Deploy App Workloads with a PCG tutorial. Use the code in this directory with the tutorial. +This folder contains the demo code for the [Deploy App Workloads with a PCG](https://docs.spectrocloud.com/clusters/pcg/deploy-app-pcg) tutorial. Use the code in this directory with the tutorial. To get started, review the [prerequisites](#prerequisites). Next, follow the steps in the tutorial to deploy a VMware cluster and add-on pack. Use the [terraform.tfvars](./terraform.tfvars) file to provide the required variables. @@ -11,7 +11,7 @@ You will need the following items before getting started: 1. A Palette API key. 2. A VMware PCG added to your Palette account. -3. A public SSH key that will be used to access the cluster nodes. +3. A public SSH key that will be used to access the cluster nodes. If not provided, a new key pair will be generated. > [!NOTE] > This Terraform code will deploy the resources specified in the template to **VMware vSphere**. @@ -21,6 +21,7 @@ You will need the following items before getting started: | Name | Version | | --------------------------------------------------------------------------------- | --------- | | [spectrocloud](#requirement_spectrocloud) | >= 0.16.1 | +| [tls](#requirement_tls) | 4.0.4 | | [vsphere](#requirement_vsphere) | >= 2.6.1 | ## Providers @@ -28,6 +29,7 @@ You will need the following items before getting started: | Name | Version | | --------------------------------------------------------------------------- | ------- | | [spectrocloud](#provider_spectrocloud) | 0.17.4 | +| [tls](#provider_tls) | 4.0.4 | ## Modules @@ -40,6 +42,7 @@ No modules. | [spectrocloud_cluster_profile.profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | | [spectrocloud_cluster_vsphere.cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_vsphere) | resource | | [spectrocloud_privatecloudgateway_ippool.ippool](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/privatecloudgateway_ippool) | resource | +| [tls_private_key.tutorial_ssh_key](https://registry.terraform.io/providers/hashicorp/tls/4.0.4/docs/resources/private_key) | resource | | [spectrocloud_cloudaccount_vsphere.account](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cloudaccount_vsphere) | data source | | [spectrocloud_pack.cni](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | | [spectrocloud_pack.csi](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | @@ -51,26 +54,26 @@ No modules. ## Inputs -| Name | Description | Type | Default | Required | -| ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------- | :------: | -| [cluster_name](#input_cluster_name) | The name of the cluster. | `string` | `"pcg-tutorial-cluster"` | no | -| [cluster_profile_description](#input_cluster_profile_description) | Provide a description of the cluster profile. | `string` | `"My cluster profile as part of the pcg tutorial."` | no | -| [cluster_profile_name](#input_cluster_profile_name) | The name of the cluster profile. | `string` | `"pcg-tutorial-profile"` | no | -| [datacenter_name](#input_datacenter_name) | The name of the vsphere datacenter. | `string` | n/a | yes | -| [datastore_name](#input_datastore_name) | The name of the vsphere datastore. | `string` | n/a | yes | -| [folder_name](#input_folder_name) | The name of the vsphere folder. | `string` | n/a | yes | -| [ip_range_end](#input_ip_range_end) | The last IP of your IP range. | `string` | n/a | yes | -| [ip_range_start](#input_ip_range_start) | The first IP of your IP range. | `string` | n/a | yes | -| [metallb_ip](#input_metallb_ip) | Provide the metallb ip. | `string` | n/a | yes | -| [nameserver_addr](#input_nameserver_addr) | The nameserver address of your network. | `set(string)` | n/a | yes | -| [network_gateway](#input_network_gateway) | The gateway of your network. | `string` | n/a | yes | -| [network_name](#input_network_name) | The name of the vsphere network. | `string` | n/a | yes | -| [network_prefix](#input_network_prefix) | The network prefix of your IP Pool. | `number` | n/a | yes | -| [pcg_name](#input_pcg_name) | The name of the Vsphere PCG | `string` | n/a | yes | -| [resource_pool_name](#input_resource_pool_name) | The name of the vsphere resource pool. | `string` | n/a | yes | -| [ssh_key](#input_ssh_key) | Specify the public key that will be used to access the cluster nodes. | `string` | n/a | yes | -| [tags](#input_tags) | The default tags to apply to Palette resources | `list(string)` |
[
"spectro-cloud-education",
"app:hello-universe",
"terraform_managed:true"
]
| no | -| [vsphere_cluster](#input_vsphere_cluster) | The name of your vsphere cluster. | `string` | n/a | yes | +| Name | Description | Type | Default | Required | +| ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------: | +| [cluster_name](#input_cluster_name) | The name of the cluster. | `string` | `"pcg-tutorial-cluster"` | no | +| [cluster_profile_description](#input_cluster_profile_description) | Provide a description of the cluster profile. | `string` | `"My cluster profile as part of the PCG tutorial."` | no | +| [cluster_profile_name](#input_cluster_profile_name) | The name of the cluster profile. | `string` | `"pcg-tutorial-profile"` | no | +| [datacenter_name](#input_datacenter_name) | The name of the datacenter in vSphere.. | `string` | n/a | yes | +| [datastore_name](#input_datastore_name) | The name of the vSphere datastore. | `string` | n/a | yes | +| [folder_name](#input_folder_name) | The name of the folder in vSphere. | `string` | n/a | yes | +| [ip_range_end](#input_ip_range_end) | The last IP address of your PCG IP pool range. | `string` | n/a | yes | +| [ip_range_start](#input_ip_range_start) | The first IP address of your PCG IP pool range. | `string` | n/a | yes | +| [metallb_ip](#input_metallb_ip) | The IP address range for your MetalLB Load Balancer. | `string` | n/a | yes | +| [nameserver_addr](#input_nameserver_addr) | The DNS nameserver IP addresses of your network. | `set(string)` | n/a | yes | +| [network_gateway](#input_network_gateway) | The IP address of the vSphere network gateway. | `string` | n/a | yes | +| [network_name](#input_network_name) | The name of the vSphere network. | `string` | n/a | yes | +| [network_prefix](#input_network_prefix) | The prefix of your vSphere network. | `number` | n/a | yes | +| [pcg_name](#input_pcg_name) | The name of the IP Pool PCG. | `string` | n/a | yes | +| [resource_pool_name](#input_resource_pool_name) | The name of the vSphere resource pool. | `string` | n/a | yes | +| [ssh_key](#input_ssh_key) | Specify the public key that will be used to access the cluster nodes. If not provided, a new key pair will be generated. Press enter to generate a new key pair. | `string` | n/a | yes | +| [tags](#input_tags) | The default tags to apply to Palette resources | `list(string)` |
[
"spectro-cloud-education",
"app:hello-universe",
"terraform_managed:true",
"repository:spectrocloud:tutorials",
"tutorial:DEPLOY_APP_WORKLOADS_WITH_A_PCG"
]
| no | +| [vsphere_cluster](#input_vsphere_cluster) | The name of your vSphere cluster. | `string` | n/a | yes | ## Outputs @@ -78,5 +81,3 @@ No modules. | ----------------------------------------------------------------- | ----------- | | [Advisory](#output_Advisory) | n/a | | [profile_id](#output_profile_id) | n/a | - - diff --git a/terraform/vmware-cluster-deployment-tf/cluster.tf b/terraform/vmware-cluster-deployment-tf/cluster.tf index cccc5b4..a7dce97 100644 --- a/terraform/vmware-cluster-deployment-tf/cluster.tf +++ b/terraform/vmware-cluster-deployment-tf/cluster.tf @@ -8,7 +8,7 @@ resource "spectrocloud_cluster_vsphere" "cluster" { depends_on = [spectrocloud_cluster_profile.profile] cloud_config { - ssh_key = var.ssh_key + ssh_key = local.ssh_public_key datacenter = var.datacenter_name folder = var.folder_name static_ip = true diff --git a/terraform/vmware-cluster-deployment-tf/data.tf b/terraform/vmware-cluster-deployment-tf/data.tf index b3a072b..a34f8f9 100644 --- a/terraform/vmware-cluster-deployment-tf/data.tf +++ b/terraform/vmware-cluster-deployment-tf/data.tf @@ -38,8 +38,8 @@ data "spectrocloud_pack" "csi" { } data "spectrocloud_pack" "metallb" { - name = "lb-metallb" - version = "0.13.7" + name = "lb-metallb-helm" + version = "0.13.11" registry_uid = data.spectrocloud_registry.public_registry.id } diff --git a/terraform/vmware-cluster-deployment-tf/inputs.tf b/terraform/vmware-cluster-deployment-tf/inputs.tf index beb61bf..43d23fb 100644 --- a/terraform/vmware-cluster-deployment-tf/inputs.tf +++ b/terraform/vmware-cluster-deployment-tf/inputs.tf @@ -39,7 +39,7 @@ variable "tags" { description = "The default tags to apply to Palette resources" # Value and key must be 63 characters or less, must start and end with an alphanumeric character, and can contain only alphanumeric characters, dots, dashes or underscores. # Slashes `\` are not allowed. - default = ["spectro-cloud-education", "app:hello-universe", "terraform_managed:true"] + default = ["spectro-cloud-education", "app:hello-universe", "terraform_managed:true", "repository:spectrocloud:tutorials", "tutorial:DEPLOY_APP_WORKLOADS_WITH_A_PCG"] } ################################################# @@ -51,7 +51,7 @@ variable "tags" { # The value should include the public key for accessing the cluster nodes. variable "ssh_key" { type = string - description = "Specify the public key that will be used to access the cluster nodes." + description = "Specify the public key that will be used to access the cluster nodes. If not provided, a new key pair will be generated. Press enter to generate a new key pair." sensitive = true } diff --git a/terraform/vmware-cluster-deployment-tf/profile.tf b/terraform/vmware-cluster-deployment-tf/profile.tf index 75c7d67..f3955f4 100644 --- a/terraform/vmware-cluster-deployment-tf/profile.tf +++ b/terraform/vmware-cluster-deployment-tf/profile.tf @@ -42,10 +42,10 @@ resource "spectrocloud_cluster_profile" "profile" { } pack { - name = "lb-metallb" + name = "lb-metallb-helm" tag = "0.13.x" uid = data.spectrocloud_pack.metallb.id - values = format("%s - %s", data.spectrocloud_pack.metallb.values, var.metallb_ip) + values = replace(data.spectrocloud_pack.metallb.values, "192.168.10.0/24", var.metallb_ip) } ############################ diff --git a/terraform/vmware-cluster-deployment-tf/provider.tf b/terraform/vmware-cluster-deployment-tf/provider.tf index 7402a42..d38014b 100644 --- a/terraform/vmware-cluster-deployment-tf/provider.tf +++ b/terraform/vmware-cluster-deployment-tf/provider.tf @@ -7,10 +7,16 @@ terraform { version = ">= 0.16.1" source = "spectrocloud/spectrocloud" } + vsphere = { source = "hashicorp/vsphere" version = ">= 2.6.1" } + + tls = { + source = "hashicorp/tls" + version = "4.0.4" + } } } diff --git a/terraform/vmware-cluster-deployment-tf/ssh-key.tf b/terraform/vmware-cluster-deployment-tf/ssh-key.tf new file mode 100644 index 0000000..2a01ff1 --- /dev/null +++ b/terraform/vmware-cluster-deployment-tf/ssh-key.tf @@ -0,0 +1,12 @@ +# Copyright (c) Spectro Cloud +# SPDX-License-Identifier: Apache-2.0 + +resource "tls_private_key" "tutorial_ssh_key" { + count = var.ssh_key == "" ? 1 : 0 + algorithm = "RSA" + rsa_bits = "4096" +} + +locals { + ssh_public_key = var.ssh_key != "" ? var.ssh_key : tls_private_key.tutorial_ssh_key[0].public_key_openssh +} \ No newline at end of file