Skip to content

Commit 30fbc47

Browse files
committed
docs: add readme DOC-1358
1 parent f097d5e commit 30fbc47

File tree

10 files changed

+112
-47
lines changed

10 files changed

+112
-47
lines changed

terraform/vmo-cluster/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Deploy and Manage VMs using Palette VMO
2+
3+
This folder contains the demo code for the **Deploy and Manage VMs using Palette VMO** tutorial.
4+
5+
The Terraform code has two main toggle variables that you can use to deploy resources to [Canonical MAAS](https://maas.io/docs).
6+
7+
| Variable | Provider | Description | Default |
8+
| ---------------- | -------- | ------------------------------------------------- | ------- |
9+
| `deploy-maas` | MAAS | Enable to deploy a cluster to MAAS. | `false` |
10+
| `deploy-maas-vm` | MAAS | Enable to deploy a VM to a deployed MAAS cluster. | `false` |
11+
12+
13+
To get started, open the **terraform.tfvars** file. Toggle the provider variable as specified in the table and provide values to your cloud provider variables, replacing all instances of the string `REPLACE ME`.
14+
15+
<!-- BEGIN_TF_DOCS -->
16+
## Requirements
17+
18+
| Name | Version |
19+
|------|---------|
20+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.9 |
21+
| <a name="requirement_local"></a> [local](#requirement\_local) | 2.4.1 |
22+
| <a name="requirement_spectrocloud"></a> [spectrocloud](#requirement\_spectrocloud) | >= 0.22.2 |
23+
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | 4.0.4 |
24+
25+
## Providers
26+
27+
| Name | Version |
28+
|------|---------|
29+
| <a name="provider_local"></a> [local](#provider\_local) | 2.4.1 |
30+
| <a name="provider_spectrocloud"></a> [spectrocloud](#provider\_spectrocloud) | 0.22.2 |
31+
| <a name="provider_tls"></a> [tls](#provider\_tls) | 4.0.4 |
32+
33+
## Modules
34+
35+
No modules.
36+
37+
## Resources
38+
39+
| Name | Type |
40+
|------|------|
41+
| [spectrocloud_cluster_profile.maas-vmo-profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource |
42+
| [spectrocloud_cluster_maas.maas-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_maas) | resource |
43+
| [spectrocloud_virtual_machine.virtual-machine](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/virtual_machine) | resource |
44+
| [spectrocloud_cloudaccount_maas.account](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cloudaccount_maas) | data source |
45+
| [spectrocloud_pack.maas_vmo](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
46+
| [spectrocloud_pack.maas_cni](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
47+
| [spectrocloud_pack.maas_csi](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
48+
| [spectrocloud_pack.maas_k8s](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
49+
| [spectrocloud_pack.maas_ubuntu](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
50+
| [spectrocloud_cluster.maas_vmo_cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cluster) | data source |
51+
| [spectrocloud_registry.public_registry](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/registry) | data source |
52+
53+
## Inputs
54+
55+
| Name | Description | Type | Default | Required |
56+
|------|-------------|------|---------|:--------:|
57+
| <a name="input_deploy-maas"></a> [deploy-maas](#input\_deploy-maas) | A flag for enabling a cluster deployment on MAAS. | `bool` | n/a | yes |
58+
| <a name="input_deploy-maas-vm"></a> [deploy-maas-vm](#input\_deploy-maas-vm) | A flag for enabling a VM creation on a MAAS cluster. | `bool` | n/a | yes |
59+
| <a name="input_pcg-name"></a> [pcg-name](#input\_pcg-name) | The name of the PCG that will be used to deploy the cluster. | `string` | n/a | yes |
60+
| <a name="input_maas-domain"></a> [maas-domain](#input\_maas-domain) | The MaaS domain that will be used to deploy the cluster. | `string` | n/a | yes |
61+
| <a name="input_maas-worker-nodes"></a> [maas-worker-nodes](#input\_maas-worker-nodes) | The number of worker nodes that will be used to deploy the cluster. | `number` | 1 | yes |
62+
| <a name="input_maas-control-plane-nodes"></a> [maas-control-plane-nodes](#input\_maas-control-plane-nodes) | The number of control plane nodes that will be used to deploy the cluster. | `number` | 1 | yes |
63+
| <a name="input_maas-worker-resource-pool"></a> [maas-worker-resource-pool](#input\_maas-worker-resource-pool) | The resource pool to deploy the worker nodes to. | `string` | n/a | yes |
64+
| <a name="input_maas-control-plane-resource-pool"></a> [maas-control-plane-resource-pool](#input\_maas-control-plane-resource-pool) | The resource pool to deploy the control plane nodes to. | `string` | n/a | yes |
65+
| <a name="input_maas-worker-azs"></a> [maas-worker-azs](#input\_maas-worker-azs) | The set of availability zones to deploy the worker nodes to. | `set(string)` | n/a | yes |
66+
| <a name="input_maas-control-plane-azs"></a> [maas-control-plane-azs](#input\_maas-control-plane-azs) | The set of availability zones to deploy the control plane nodes to. | `set(string)` | n/a | yes |
67+
| <a name="input_maas-worker-node-tags"></a> [maas-worker-node-tags](#input\_maas-worker-node-tags) | The set of tag values that you want to apply to all nodes in the node worker pool. | `set(string)` | n/a | yes |
68+
| <a name="input_maas-control-plane-node-tags"></a> [maas-control-plane-node-tags](#input\_maas-control-plane-node-tags) | The set of tag values that you want to apply to all nodes in the node control plane pool. | `set(string)` | n/a | yes |
69+
| <a name="input_tags"></a> [tags](#input\_tags) | The default tags to apply to Palette resources. | `list(string)` | <pre>[<br> "spectro-cloud-education",<br> "spectrocloud:tutorials",<br> "terraform_managed:true",<br> "tutorial:vmo-cluster-deployment"<br>]</pre> | no |
70+
71+
## Outputs
72+
No outputs.
73+
74+
<!-- END_TF_DOCS -->

terraform/vmo-cluster/cluster_profiles.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
##########################
3-
# MaaS VMO Cluster Profile
3+
# MAAS VMO Cluster Profile
44
##########################
55
resource "spectrocloud_cluster_profile" "maas-vmo-profile" {
66
count = var.deploy-maas ? 1 : 0
77

88
name = "tf-maas-vmo-profile"
9-
description = "A basic cluster profile for MaaS VMO"
9+
description = "A basic cluster profile for MAAS VMO"
1010
tags = concat(var.tags, ["env:maas"])
1111
cloud = "maas"
1212
type = "cluster"

terraform/vmo-cluster/clusters.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
################
5-
# MaaS Cluster
5+
# MAAS Cluster
66
################
77

8-
resource "spectrocloud_cluster_maas" "cluster" {
8+
resource "spectrocloud_cluster_maas" "maas-cluster" {
99
count = var.deploy-maas ? 1 : 0
1010

1111
name = "vmo-cluster-maas"

terraform/vmo-cluster/data.tf

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ data "spectrocloud_registry" "public_registry" {
88
name = "Public Repo"
99
}
1010

11-
data "spectrocloud_registry" "community_registry" {
12-
name = "Palette Community Registry"
13-
}
14-
1511
######
16-
# MaaS
12+
# MAAS
1713
######
1814

1915
data "spectrocloud_cloudaccount_maas" "account" {
@@ -52,7 +48,8 @@ data "spectrocloud_pack" "maas_vmo" {
5248
}
5349

5450
data "spectrocloud_cluster" "maas_vmo_cluster" {
55-
depends_on = [spectrocloud_cluster_maas.cluster]
51+
count = var.deploy-maas-vm ? 1 : 0
52+
depends_on = [spectrocloud_cluster_maas.maas-cluster]
5653
name = "vmo-cluster-maas"
5754
context = "project"
5855
}

terraform/vmo-cluster/inputs.tf

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,24 @@ variable "tags" {
2525
description = "The default tags to apply to Palette resources."
2626
default = [
2727
"spectro-cloud-education",
28-
"app:hello-universe",
2928
"spectrocloud:tutorials",
3029
"terraform_managed:true",
3130
"tutorial:vmo-cluster-deployment"
3231
]
3332
}
3433

3534
######
36-
# MaaS
35+
# MAAS
3736
######
3837

3938
variable "deploy-maas" {
4039
type = bool
41-
description = "A flag for enabling a deployment on MaaS."
40+
description = "A flag for enabling a deployment on MAAS."
4241
}
4342

4443
variable "deploy-maas-vm" {
4544
type = bool
46-
description = "A flag for enabling a VM creation on the MaaS cluster."
45+
description = "A flag for enabling a VM creation on the MAAS cluster."
4746
}
4847

4948
variable "pcg-name" {
@@ -52,17 +51,17 @@ variable "pcg-name" {
5251

5352
validation {
5453
condition = var.deploy-maas ? var.pcg-name != "REPLACE ME" && var.pcg-name != "" : true
55-
error_message = "Provide the correct MaaS PCG name."
54+
error_message = "Provide the correct MAAS PCG name."
5655
}
5756
}
5857

5958
variable "maas-domain" {
6059
type = string
61-
description = "MaaS domain"
60+
description = "MAAS domain"
6261

6362
validation {
6463
condition = var.deploy-maas ? var.maas-domain != "REPLACE ME" && var.maas-domain != "" : true
65-
error_message = "Provide the correct MaaS domain."
64+
error_message = "Provide the correct MAAS domain."
6665
}
6766
}
6867

@@ -79,7 +78,7 @@ variable "maas-worker-nodes" {
7978

8079
variable "maas-worker-resource-pool" {
8180
type = string
82-
description = "Resource pool for the MaaS worker nodes."
81+
description = "Resource pool for the MAAS worker nodes."
8382

8483
validation {
8584
condition = var.deploy-maas ? var.maas-worker-resource-pool != "REPLACE ME" && var.maas-worker-resource-pool != "" : true
@@ -89,7 +88,7 @@ variable "maas-worker-resource-pool" {
8988

9089
variable "maas-worker-azs" {
9190
type = set(string)
92-
description = "Set of AZs for the MaaS worker nodes."
91+
description = "Set of AZs for the MAAS worker nodes."
9392

9493
validation {
9594
condition = var.deploy-maas ? !contains(var.maas-worker-azs, "REPLACE ME") && length(var.maas-worker-azs) != 0 : true
@@ -99,7 +98,7 @@ variable "maas-worker-azs" {
9998

10099
variable "maas-worker-node-tags" {
101100
type = set(string)
102-
description = "Set of node tags for the MaaS worker nodes."
101+
description = "Set of node tags for the MAAS worker nodes."
103102

104103
validation {
105104
condition = var.deploy-maas ? !contains(var.maas-worker-node-tags, "REPLACE ME") && length(var.maas-worker-node-tags) != 0 : true
@@ -120,7 +119,7 @@ variable "maas-control-plane-nodes" {
120119

121120
variable "maas-control-plane-resource-pool" {
122121
type = string
123-
description = "Resource pool for the MaaS control plane nodes."
122+
description = "Resource pool for the MAAS control plane nodes."
124123

125124
validation {
126125
condition = var.deploy-maas ? var.maas-control-plane-resource-pool != "REPLACE ME" && var.maas-control-plane-resource-pool != "" : true
@@ -130,7 +129,7 @@ variable "maas-control-plane-resource-pool" {
130129

131130
variable "maas-control-plane-azs" {
132131
type = set(string)
133-
description = "Set of AZs for the MaaS control plane nodes."
132+
description = "Set of AZs for the MAAS control plane nodes."
134133

135134
validation {
136135
condition = var.deploy-maas ? !contains(var.maas-control-plane-azs, "REPLACE ME") && length(var.maas-control-plane-azs) != 0 : true
@@ -140,7 +139,7 @@ variable "maas-control-plane-azs" {
140139

141140
variable "maas-control-plane-node-tags" {
142141
type = set(string)
143-
description = "Set of node tags for the MaaS control plane nodes."
142+
description = "Set of node tags for the MAAS control plane nodes."
144143

145144
validation {
146145
condition = var.deploy-maas ? !contains(var.maas-control-plane-node-tags, "REPLACE ME") && length(var.maas-control-plane-node-tags) != 0 : true

terraform/vmo-cluster/provider.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ terraform {
1313
version = "4.0.4"
1414
}
1515

16-
vsphere = {
17-
source = "hashicorp/vsphere"
18-
version = ">= 2.6.1"
19-
}
20-
2116
local = {
2217
source = "hashicorp/local"
2318
version = "2.4.1"

terraform/vmo-cluster/terraform.tfvars

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
palette-project = "Default" # The name of your project in Palette.
88

99
############################
10-
# MaaS Deployment Settings
10+
# MAAS Deployment Settings
1111
############################
12-
deploy-maas = false # Set to true to deploy to MaaS.
13-
deploy-maas-vm = false # Set to true to create a VM on MaaS cluster once deployed.
12+
deploy-maas = false # Set to true to deploy to MAAS.
13+
deploy-maas-vm = false # Set to true to create a VM on MAAS cluster once deployed.
1414

1515
pcg-name = "REPLACE ME" # Provide the name of the PCG that will be used to deploy the Palette cluster.
16-
maas-domain = "REPLACE ME" # Provide the MaaS domain that will be used to deploy the Palette cluster.
16+
maas-domain = "REPLACE ME" # Provide the MAAS domain that will be used to deploy the Palette cluster.
1717

18-
maas-worker-nodes = 1 # Provide the number of worker nodes that will be used for Palette cluster.
18+
maas-worker-nodes = 1 # Provide the number of worker nodes that will be used for the Palette cluster.
1919
maas-worker-resource-pool = "REPLACE ME" # Provide a resource pool for the worker nodes.
2020
maas-worker-azs = ["REPLACE ME"] # Provide a set of availability zones for the worker nodes.
2121
maas-worker-node-tags = ["REPLACE ME"] # Provide a set of node tags for the worker nodes.
2222

23-
maas-control-plane-nodes = 1 # Provide the number of control plane nodes that will be used for Palette cluster.
23+
maas-control-plane-nodes = 1 # Provide the number of control plane nodes that will be used for the Palette cluster.
2424
maas-control-plane-resource-pool = "REPLACE ME" # Provide a resource pool for the control plane nodes.
2525
maas-control-plane-azs = ["REPLACE ME"] # Provide a set of availability zones for the control plane nodes.
2626
maas-control-plane-node-tags = ["REPLACE ME"] # Provide a set of node tags for the control plane nodes.

terraform/vmo-cluster/tests/maas-cluster-vm.tftest.hcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) Spectro Cloud
22
# SPDX-License-Identifier: Apache-2.0
3-
# Test case 3 - Verify MaaS profile, cluster and VM are correctly planned when values are provided.
3+
# Test case 3 - Verify MAAS profile, cluster and VM are correctly planned when values are provided.
44

55
variables {
66
deploy-maas = true
@@ -26,17 +26,17 @@ run "verify_maas" {
2626

2727
assert {
2828
condition = length(spectrocloud_cluster_profile.maas-vmo-profile) == 1
29-
error_message = "No MaaS cluster profile was created"
29+
error_message = "No MAAS cluster profile was created"
3030
}
3131

3232
assert {
33-
condition = length(spectrocloud_cluster_maas.cluster) == 1
34-
error_message = "No MaaS cluster was created"
33+
condition = length(spectrocloud_cluster_maas.maas-cluster) == 1
34+
error_message = "No MAAS cluster was created"
3535
}
3636

3737
assert {
3838
condition = length(spectrocloud_virtual_machine.virtual-machine) == 1
39-
error_message = "No MaaS VM was created"
39+
error_message = "No MAAS VM was created"
4040
}
4141

4242
}

terraform/vmo-cluster/tests/maas-cluster.tftest.hcl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) Spectro Cloud
22
# SPDX-License-Identifier: Apache-2.0
3-
# Test case 2 - Verify MaaS profile and cluster are correctly planned when values are provided.
3+
# Test case 2 - Verify MAAS profile and cluster are correctly planned when values are provided.
44

55
variables {
66
deploy-maas = true
@@ -26,12 +26,12 @@ run "verify_maas" {
2626

2727
assert {
2828
condition = length(spectrocloud_cluster_profile.maas-vmo-profile) == 1
29-
error_message = "No MaaS cluster profile was created"
29+
error_message = "No MAAS cluster profile was created"
3030
}
3131

3232
assert {
33-
condition = length(spectrocloud_cluster_maas.cluster) == 1
34-
error_message = "No MaaS cluster was created"
33+
condition = length(spectrocloud_cluster_maas.maas-cluster) == 1
34+
error_message = "No MAAS cluster was created"
3535
}
3636

3737
}

terraform/vmo-cluster/virtual_machines.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
##########################
3-
# MaaS Virtual Machine
3+
# MAAS Virtual Machine
44
##########################
55
resource "spectrocloud_virtual_machine" "virtual-machine" {
66
count = var.deploy-maas-vm ? 1 : 0
7-
depends_on = [spectrocloud_cluster_maas.cluster]
7+
depends_on = [spectrocloud_cluster_maas.maas-cluster]
88

9-
cluster_uid = data.spectrocloud_cluster.maas_vmo_cluster.id
10-
cluster_context = data.spectrocloud_cluster.maas_vmo_cluster.context
9+
cluster_uid = data.spectrocloud_cluster.maas_vmo_cluster[0].id
10+
cluster_context = data.spectrocloud_cluster.maas_vmo_cluster[0].context
1111

1212
run_on_launch = true
1313
namespace = "default"

0 commit comments

Comments
 (0)