Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add VMO cluster deployment DOC-1358 #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cbb0d660a09cc0c47851ef59ac7f0c5fca177371:terraform/vmo-cluster/manifests/k8s-values.yaml:generic-api-key:114
74 changes: 74 additions & 0 deletions terraform/vmo-cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Deploy and Manage VMs using Palette VMO

This folder contains the demo code for the **Deploy and Manage VMs using Palette VMO** tutorial.

The Terraform code has two main toggle variables that you can use to deploy resources to [Canonical MAAS](https://maas.io/docs).

| Variable | Provider | Description | Default |
| ---------------- | -------- | ------------------------------------------------- | ------- |
| `deploy-maas` | MAAS | Enable to deploy a cluster to MAAS. | `false` |
| `deploy-maas-vm` | MAAS | Enable to deploy a VM to a deployed MAAS cluster. | `false` |


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`.

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.9 |
| <a name="requirement_local"></a> [local](#requirement\_local) | 2.4.1 |
| <a name="requirement_spectrocloud"></a> [spectrocloud](#requirement\_spectrocloud) | >= 0.22.2 |
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | 4.0.4 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_local"></a> [local](#provider\_local) | 2.4.1 |
| <a name="provider_spectrocloud"></a> [spectrocloud](#provider\_spectrocloud) | 0.22.2 |
| <a name="provider_tls"></a> [tls](#provider\_tls) | 4.0.4 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [spectrocloud_cluster_profile.maas-vmo-profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource |
| [spectrocloud_cluster_maas.maas-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_maas) | resource |
| [spectrocloud_virtual_machine.virtual-machine](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/virtual_machine) | resource |
| [spectrocloud_cloudaccount_maas.account](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cloudaccount_maas) | data source |
| [spectrocloud_pack.maas_vmo](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
| [spectrocloud_pack.maas_cni](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
| [spectrocloud_pack.maas_csi](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
| [spectrocloud_pack.maas_k8s](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
| [spectrocloud_pack.maas_ubuntu](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source |
| [spectrocloud_cluster.maas_vmo_cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cluster) | data source |
| [spectrocloud_registry.public_registry](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/registry) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_deploy-maas"></a> [deploy-maas](#input\_deploy-maas) | A flag for enabling a cluster deployment on MAAS. | `bool` | n/a | yes |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |

## Outputs
No outputs.

<!-- END_TF_DOCS -->
68 changes: 68 additions & 0 deletions terraform/vmo-cluster/cluster_profiles.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

##########################
# MAAS VMO Cluster Profile
##########################
resource "spectrocloud_cluster_profile" "maas-vmo-profile" {
count = var.deploy-maas ? 1 : 0

name = "tf-maas-vmo-profile"
description = "A basic cluster profile for MAAS VMO"
tags = concat(var.tags, ["env:maas"])
cloud = "maas"
type = "cluster"
version = "1.0.0"

pack {
name = data.spectrocloud_pack.maas_ubuntu.name
tag = data.spectrocloud_pack.maas_ubuntu.version
uid = data.spectrocloud_pack.maas_ubuntu.id
values = file("manifests/ubuntu-values.yaml")
type = "spectro"
}

pack {
name = data.spectrocloud_pack.maas_k8s.name
tag = data.spectrocloud_pack.maas_k8s.version
uid = data.spectrocloud_pack.maas_k8s.id
values = file("manifests/k8s-values.yaml")
type = "spectro"
}

pack {
name = data.spectrocloud_pack.maas_cni.name
tag = data.spectrocloud_pack.maas_cni.version
uid = data.spectrocloud_pack.maas_cni.id
values = file("manifests/cni-values.yaml")
type = "spectro"
}

pack {
name = data.spectrocloud_pack.maas_csi.name
tag = data.spectrocloud_pack.maas_csi.version
uid = data.spectrocloud_pack.maas_csi.id
values = templatefile("manifests/csi-values.yaml", {
worker_nodes = var.maas-worker-nodes,
})
type = "spectro"
}

pack {
name = data.spectrocloud_pack.maas_vmo.name
tag = data.spectrocloud_pack.maas_vmo.version
uid = data.spectrocloud_pack.maas_vmo.id
values = file("manifests/vmo-values.yaml")
type = "spectro"
}

pack {
name = "vmo-extras"
type = "manifest"
tag = "1.0.0"
values = file("manifests/vmo-extras-values.yaml")
manifest {
name = "vmo-extras"
content = file("manifests/vmo-extras-manifest.yaml")
}
}

}
52 changes: 52 additions & 0 deletions terraform/vmo-cluster/clusters.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) Spectro Cloud
# SPDX-License-Identifier: Apache-2.0

################
# MAAS Cluster
################

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

name = "vmo-cluster-maas"
tags = concat(var.tags, ["env:maas"])
cloud_account_id = data.spectrocloud_cloudaccount_maas.account[0].id
pause_agent_upgrades = "unlock"

cloud_config {
domain = var.maas-domain
}

cluster_profile {
id = resource.spectrocloud_cluster_profile.maas-vmo-profile[0].id
}

machine_pool {
name = "maas-control-plane"
count = 1
control_plane = true
azs = var.maas-control-plane-azs
node_tags = var.maas-control-plane-node-tags
instance_type {
min_cpu = 8
min_memory_mb = 16000
}
placement {
resource_pool = var.maas-control-plane-resource-pool
}
}

machine_pool {
name = "maas-worker-basic"
count = 1
azs = var.maas-worker-azs
node_tags = var.maas-worker-node-tags
instance_type {
min_cpu = 8
min_memory_mb = 32000
}
placement {
resource_pool = var.maas-worker-resource-pool
}
}
}
57 changes: 57 additions & 0 deletions terraform/vmo-cluster/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright (c) Spectro Cloud
# SPDX-License-Identifier: Apache-2.0

########################################
# Data resources for the cluster profile
########################################
data "spectrocloud_registry" "public_registry" {
name = "Public Repo"
}

######
# MAAS
######

data "spectrocloud_cloudaccount_maas" "account" {
count = var.deploy-maas ? 1 : 0
name = var.pcg-name
}

data "spectrocloud_pack" "maas_ubuntu" {
name = "ubuntu-maas"
version = "22.04"
registry_uid = data.spectrocloud_registry.public_registry.id
}

data "spectrocloud_pack" "maas_k8s" {
name = "kubernetes"
version = "1.30.6"
registry_uid = data.spectrocloud_registry.public_registry.id
}

data "spectrocloud_pack" "maas_cni" {
name = "cni-cilium-oss"
version = "1.15.3"
registry_uid = data.spectrocloud_registry.public_registry.id
}

data "spectrocloud_pack" "maas_csi" {
name = "csi-rook-ceph-helm"
version = "1.14.9"
registry_uid = data.spectrocloud_registry.public_registry.id
}

data "spectrocloud_pack" "maas_vmo" {
name = "virtual-machine-orchestrator"
version = "4.4.10"
registry_uid = data.spectrocloud_registry.public_registry.id
}

data "spectrocloud_cluster" "maas_vmo_cluster" {
count = var.deploy-maas-vm ? 1 : 0
depends_on = [spectrocloud_cluster_maas.maas-cluster]
name = "vmo-cluster-maas"
context = "project"
}


Loading
Loading