Skip to content

Commit daa33ae

Browse files
docs: add terraform files to deploy a vmware cluster (#36)
* docs: add terraform files to deploy a vmware cluster * docs: improve readme * apply suggestions from code review * add creation of ssh key pair * added dynamic IP placement, addressed suggestions from review * Update terraform/vmware-cluster-deployment-tf/provider.tf Co-authored-by: Karl Cardenas <karl@spectrocloud.com> --------- Co-authored-by: Karl Cardenas <karl@spectrocloud.com>
1 parent 606c9d6 commit daa33ae

File tree

11 files changed

+619
-2
lines changed

11 files changed

+619
-2
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[![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)
22

33
# Spectro Cloud Tutorials
4+
45
A collection of Spectro Cloud tutorials and their respective sample code.
56

67
<p align="center">
78
<img src="/static/img/spectro-wizard.png" alt="drawing" width="500"/>
89
</p>
910

10-
1111
The following tutorial code is available:
12+
1213
- [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.
1314

1415
- [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:
1920

2021
- [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)
2122

23+
- [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)
24+
2225
## Docker
2326

24-
All the tutorials are available in a Docker image that you can use to get started with the tutorials.
27+
All the tutorials are available in a Docker image that you can use to get started with the tutorials.
2528
Review the [Docker steps](./docs/docker.md) to get started with the Docker image.
2629

2730
## Image Verification
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Hello Universe TF
2+
3+
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.
4+
5+
To get started, review the [prerequisites](#prerequisites). Next, follow the steps in the tutorial to deploy a VMware cluster and add-on pack.
6+
Use the [terraform.tfvars](./terraform.tfvars) file to provide the required variables.
7+
8+
## Prerequisites
9+
10+
You will need the following items before getting started:
11+
12+
1. A Palette API key.
13+
2. A VMware PCG added to your Palette account.
14+
3. A public SSH key that will be used to access the cluster nodes. If not provided, a new key pair will be generated.
15+
16+
> [!NOTE]
17+
> This Terraform code will deploy the resources specified in the template to **VMware vSphere**.
18+
19+
## Requirements
20+
21+
| Name | Version |
22+
| --------------------------------------------------------------------------------- | --------- |
23+
| <a name="requirement_local"></a> [local](#requirement_local) | 2.4.1 |
24+
| <a name="requirement_spectrocloud"></a> [spectrocloud](#requirement_spectrocloud) | >= 0.16.1 |
25+
| <a name="requirement_tls"></a> [tls](#requirement_tls) | 4.0.4 |
26+
| <a name="requirement_vsphere"></a> [vsphere](#requirement_vsphere) | >= 2.6.1 |
27+
28+
## Providers
29+
30+
| Name | Version |
31+
| --------------------------------------------------------------------------- | ------- |
32+
| <a name="provider_local"></a> [local](#provider_local) | 2.4.1 |
33+
| <a name="provider_spectrocloud"></a> [spectrocloud](#provider_spectrocloud) | 0.17.4 |
34+
| <a name="provider_tls"></a> [tls](#provider_tls) | 4.0.4 |
35+
36+
## Modules
37+
38+
No modules.
39+
40+
## Resources
41+
42+
| Name | Type |
43+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- |
44+
| [local_file.public_key_file](https://registry.terraform.io/providers/hashicorp/local/2.4.1/docs/resources/file) | resource |
45+
| [local_sensitive_file.private_key_file](https://registry.terraform.io/providers/hashicorp/local/2.4.1/docs/resources/sensitive_file) | resource |
46+
| [spectrocloud_cluster_profile.profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource |
47+
| [spectrocloud_cluster_vsphere.cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_vsphere) | resource |
48+
| [tls_private_key.tutorial_ssh_key](https://registry.terraform.io/providers/hashicorp/tls/4.0.4/docs/resources/private_key) | resource |
49+
| [spectrocloud_cloudaccount_vsphere.account](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cloudaccount_vsphere) | data source |
50+
| [spectrocloud_pack.cni](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
51+
| [spectrocloud_pack.csi](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
52+
| [spectrocloud_pack.hellouniverse](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
53+
| [spectrocloud_pack.k8s](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
54+
| [spectrocloud_pack.metallb](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
55+
| [spectrocloud_pack.ubuntu](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
56+
| [spectrocloud_registry.community_registry](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/registry) | data source |
57+
| [spectrocloud_registry.public_registry](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/registry) | data source |
58+
59+
## Inputs
60+
61+
| Name | Description | Type | Default | Required |
62+
| ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------: |
63+
| <a name="input_cluster_name"></a> [cluster_name](#input_cluster_name) | The name of the cluster. | `string` | `"pcg-tutorial-cluster"` | no |
64+
| <a name="input_cluster_profile_description"></a> [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 |
65+
| <a name="input_cluster_profile_name"></a> [cluster_profile_name](#input_cluster_profile_name) | The name of the cluster profile. | `string` | `"pcg-tutorial-profile"` | no |
66+
| <a name="input_datacenter_name"></a> [datacenter_name](#input_datacenter_name) | The name of the datacenter in vSphere.. | `string` | n/a | yes |
67+
| <a name="input_datastore_name"></a> [datastore_name](#input_datastore_name) | The name of the vSphere datastore. | `string` | n/a | yes |
68+
| <a name="input_folder_name"></a> [folder_name](#input_folder_name) | The name of the folder in vSphere. | `string` | n/a | yes |
69+
| <a name="input_metallb_ip"></a> [metallb_ip](#input_metallb_ip) | The IP address range for your MetalLB Load Balancer. | `string` | n/a | yes |
70+
| <a name="input_network_name"></a> [network_name](#input_network_name) | The name of the vSphere network. | `string` | n/a | yes |
71+
| <a name="input_pcg_name"></a> [pcg_name](#input_pcg_name) | The name of the PCG. | `string` | n/a | yes |
72+
| <a name="input_resource_pool_name"></a> [resource_pool_name](#input_resource_pool_name) | The name of the vSphere resource pool. | `string` | n/a | yes |
73+
| <a name="input_search_domain"></a> [search_domain](#input_search_domain) | The name of network search domain. | `string` | n/a | yes |
74+
| <a name="input_ssh_key"></a> [ssh_key](#input_ssh_key) | The path to the public key that will be added to the cluster nodes. If not provided, a new key pair will be generated. | `string` | n/a | yes |
75+
| <a name="input_ssh_key_private"></a> [ssh_key_private](#input_ssh_key_private) | The path to the private key that will be used to access the cluster nodes. If not provided, a new key pair will be generated. | `string` | n/a | yes |
76+
| <a name="input_tags"></a> [tags](#input_tags) | The default tags to apply to Palette resources | `list(string)` | <pre>[<br> "spectro-cloud-education",<br> "app:hello-universe",<br> "terraform_managed:true",<br> "repository:spectrocloud:tutorials",<br> "tutorial:DEPLOY_APP_WORKLOADS_WITH_A_PCG"<br>]</pre> | no |
77+
| <a name="input_vsphere_cluster"></a> [vsphere_cluster](#input_vsphere_cluster) | The name of your vSphere cluster. | `string` | n/a | yes |
78+
79+
## Outputs
80+
81+
| Name | Description |
82+
| -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
83+
| <a name="output_Advisory"></a> [Advisory](#output_Advisory) | n/a |
84+
| <a name="output_ssh_connection_command"></a> [ssh_connection_command](#output_ssh_connection_command) | Command to use the generated private SSH key to access the nodes. |
85+
| <a name="output_ssh_connection_command_user"></a> [ssh_connection_command_user](#output_ssh_connection_command_user) | Command to use the user's private SSH key to access the nodes. |
86+
| <a name="output_ssh_key_location"></a> [ssh_key_location](#output_ssh_key_location) | Location of the generated private SSH key file |
87+
| <a name="output_ssh_public_key_location"></a> [ssh_public_key_location](#output_ssh_public_key_location) | Location of the generated public SSH key file |
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright (c) Spectro Cloud
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
resource "spectrocloud_cluster_vsphere" "cluster" {
5+
name = var.cluster_name
6+
tags = var.tags
7+
cloud_account_id = data.spectrocloud_cloudaccount_vsphere.account.id
8+
depends_on = [spectrocloud_cluster_profile.profile]
9+
10+
cloud_config {
11+
ssh_key = local.ssh_public_key
12+
datacenter = var.datacenter_name
13+
folder = var.folder_name
14+
static_ip = false # If true, the cluster will use static IP placement. If false, the cluster will use DDNS.
15+
network_search_domain = var.search_domain
16+
}
17+
18+
cluster_profile {
19+
id = spectrocloud_cluster_profile.profile.id
20+
}
21+
22+
scan_policy {
23+
configuration_scan_schedule = "0 0 * * SUN"
24+
penetration_scan_schedule = "0 0 * * SUN"
25+
conformance_scan_schedule = "0 0 1 * *"
26+
}
27+
28+
##############################
29+
# control-plane-pool
30+
##############################
31+
machine_pool {
32+
name = "control-plane-pool"
33+
count = 1
34+
control_plane = true
35+
control_plane_as_worker = true
36+
37+
instance_type {
38+
cpu = 4
39+
disk_size_gb = 60
40+
memory_mb = 8000
41+
}
42+
43+
placement {
44+
cluster = var.vsphere_cluster
45+
datastore = var.datastore_name
46+
network = var.network_name
47+
resource_pool = var.resource_pool_name
48+
# Required for static IP placement.
49+
#static_ip_pool_id = resource.spectrocloud_privatecloudgateway_ippool.ippool.id
50+
}
51+
52+
additional_labels = {
53+
"owner" = "docs"
54+
"purpose" = "tutorial"
55+
"type" = "control-plane-node"
56+
}
57+
}
58+
59+
##############################
60+
# worker-pool
61+
##############################
62+
machine_pool {
63+
name = "worker-pool"
64+
count = 1
65+
control_plane = false
66+
67+
instance_type {
68+
cpu = 4
69+
disk_size_gb = 60
70+
memory_mb = 8000
71+
}
72+
73+
placement {
74+
cluster = var.vsphere_cluster
75+
datastore = var.datastore_name
76+
network = var.network_name
77+
resource_pool = var.resource_pool_name
78+
# Required for static IP placement.
79+
#static_ip_pool_id = resource.spectrocloud_privatecloudgateway_ippool.ippool.id
80+
}
81+
82+
additional_labels = {
83+
"owner" = "docs"
84+
"purpose" = "tutorial"
85+
"type" = "worker-node"
86+
}
87+
}
88+
89+
}

0 commit comments

Comments
 (0)