Skip to content

Commit 4698a97

Browse files
committed
docs: add vmo cluster deployment DOC-1358
docs: add creation of virtual machine docs: add test cases DOC-1358 docs: add readme DOC-1358
1 parent 04cb3c8 commit 4698a97

23 files changed

+6550
-0
lines changed

.gitleaksignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cbb0d660a09cc0c47851ef59ac7f0c5fca177371:terraform/vmo-cluster/manifests/k8s-values.yaml:generic-api-key:114

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 -->
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
##########################
3+
# MAAS VMO Cluster Profile
4+
##########################
5+
resource "spectrocloud_cluster_profile" "maas-vmo-profile" {
6+
count = var.deploy-maas ? 1 : 0
7+
8+
name = "tf-maas-vmo-profile"
9+
description = "A basic cluster profile for MAAS VMO"
10+
tags = concat(var.tags, ["env:maas"])
11+
cloud = "maas"
12+
type = "cluster"
13+
version = "1.0.0"
14+
15+
pack {
16+
name = data.spectrocloud_pack.maas_ubuntu.name
17+
tag = data.spectrocloud_pack.maas_ubuntu.version
18+
uid = data.spectrocloud_pack.maas_ubuntu.id
19+
values = file("manifests/ubuntu-values.yaml")
20+
type = "spectro"
21+
}
22+
23+
pack {
24+
name = data.spectrocloud_pack.maas_k8s.name
25+
tag = data.spectrocloud_pack.maas_k8s.version
26+
uid = data.spectrocloud_pack.maas_k8s.id
27+
values = file("manifests/k8s-values.yaml")
28+
type = "spectro"
29+
}
30+
31+
pack {
32+
name = data.spectrocloud_pack.maas_cni.name
33+
tag = data.spectrocloud_pack.maas_cni.version
34+
uid = data.spectrocloud_pack.maas_cni.id
35+
values = file("manifests/cni-values.yaml")
36+
type = "spectro"
37+
}
38+
39+
pack {
40+
name = data.spectrocloud_pack.maas_csi.name
41+
tag = data.spectrocloud_pack.maas_csi.version
42+
uid = data.spectrocloud_pack.maas_csi.id
43+
values = templatefile("manifests/csi-values.yaml", {
44+
worker_nodes = var.maas-worker-nodes,
45+
})
46+
type = "spectro"
47+
}
48+
49+
pack {
50+
name = data.spectrocloud_pack.maas_vmo.name
51+
tag = data.spectrocloud_pack.maas_vmo.version
52+
uid = data.spectrocloud_pack.maas_vmo.id
53+
values = file("manifests/vmo-values.yaml")
54+
type = "spectro"
55+
}
56+
57+
pack {
58+
name = "vmo-extras"
59+
type = "manifest"
60+
tag = "1.0.0"
61+
values = file("manifests/vmo-extras-values.yaml")
62+
manifest {
63+
name = "vmo-extras"
64+
content = file("manifests/vmo-extras-manifest.yaml")
65+
}
66+
}
67+
68+
}

terraform/vmo-cluster/clusters.tf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright (c) Spectro Cloud
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
################
5+
# MAAS Cluster
6+
################
7+
8+
resource "spectrocloud_cluster_maas" "maas-cluster" {
9+
count = var.deploy-maas ? 1 : 0
10+
11+
name = "vmo-cluster-maas"
12+
tags = concat(var.tags, ["env:maas"])
13+
cloud_account_id = data.spectrocloud_cloudaccount_maas.account[0].id
14+
pause_agent_upgrades = "unlock"
15+
16+
cloud_config {
17+
domain = var.maas-domain
18+
}
19+
20+
cluster_profile {
21+
id = resource.spectrocloud_cluster_profile.maas-vmo-profile[0].id
22+
}
23+
24+
machine_pool {
25+
name = "maas-control-plane"
26+
count = 1
27+
control_plane = true
28+
azs = var.maas-control-plane-azs
29+
node_tags = var.maas-control-plane-node-tags
30+
instance_type {
31+
min_cpu = 8
32+
min_memory_mb = 16000
33+
}
34+
placement {
35+
resource_pool = var.maas-control-plane-resource-pool
36+
}
37+
}
38+
39+
machine_pool {
40+
name = "maas-worker-basic"
41+
count = 1
42+
azs = var.maas-worker-azs
43+
node_tags = var.maas-worker-node-tags
44+
instance_type {
45+
min_cpu = 8
46+
min_memory_mb = 32000
47+
}
48+
placement {
49+
resource_pool = var.maas-worker-resource-pool
50+
}
51+
}
52+
}

terraform/vmo-cluster/data.tf

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (c) Spectro Cloud
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
########################################
5+
# Data resources for the cluster profile
6+
########################################
7+
data "spectrocloud_registry" "public_registry" {
8+
name = "Public Repo"
9+
}
10+
11+
######
12+
# MAAS
13+
######
14+
15+
data "spectrocloud_cloudaccount_maas" "account" {
16+
count = var.deploy-maas ? 1 : 0
17+
name = var.pcg-name
18+
}
19+
20+
data "spectrocloud_pack" "maas_ubuntu" {
21+
name = "ubuntu-maas"
22+
version = "22.04"
23+
registry_uid = data.spectrocloud_registry.public_registry.id
24+
}
25+
26+
data "spectrocloud_pack" "maas_k8s" {
27+
name = "kubernetes"
28+
version = "1.30.6"
29+
registry_uid = data.spectrocloud_registry.public_registry.id
30+
}
31+
32+
data "spectrocloud_pack" "maas_cni" {
33+
name = "cni-cilium-oss"
34+
version = "1.15.3"
35+
registry_uid = data.spectrocloud_registry.public_registry.id
36+
}
37+
38+
data "spectrocloud_pack" "maas_csi" {
39+
name = "csi-rook-ceph-helm"
40+
version = "1.14.9"
41+
registry_uid = data.spectrocloud_registry.public_registry.id
42+
}
43+
44+
data "spectrocloud_pack" "maas_vmo" {
45+
name = "virtual-machine-orchestrator"
46+
version = "4.4.10"
47+
registry_uid = data.spectrocloud_registry.public_registry.id
48+
}
49+
50+
data "spectrocloud_cluster" "maas_vmo_cluster" {
51+
count = var.deploy-maas-vm ? 1 : 0
52+
depends_on = [spectrocloud_cluster_maas.maas-cluster]
53+
name = "vmo-cluster-maas"
54+
context = "project"
55+
}
56+
57+

0 commit comments

Comments
 (0)