Skip to content

Commit

Permalink
docs: added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-cardenas-coding committed Jan 20, 2024
1 parent cd4698d commit b90315a
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ 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)


## Patterns

The following patterns are available:

- [Cluster Profile Management Patterns](./terraform/cp-management/README.md) - Learn how to manage cluster profiles using Terraform by reviewing the different patterns available.

## Docker

All the tutorials are available in a Docker image that you can use to get started with the tutorials.
Expand Down
12 changes: 12 additions & 0 deletions terraform/cp-management/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Cluster Profile Management Patterns

This folder contains examples of how to manage cluster profiles using Terraform. There are multiple ways to manage cluster profiles using Terraform. The examples in this folder are meant to be used as a starting point for managing cluster profiles using Terraform. Use these examples as a reference and modify them to suit your needs.


Check out the READMEs in each folder to learn more about the different patterns.

- [Basic Pattern](./basic/README.md)

- [Intermediate Pattern](./cp-versions/README.md)

- [Advanced Pattern](./cp-profiles-with-module/README.md)
63 changes: 63 additions & 0 deletions terraform/cp-management/cp-profiles-with-module/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Advanced Pattern

This pattern leverages Terraform modules to decouple the management of cluster profile versions from the cluster profile resource. Each cluster profile version is defined through a dedicated module. Terraform logic is applied to achieve unique cluster profile versions.


| Pros |
Expand All @@ -17,4 +18,66 @@
| May be fifficult to understand |
| YAML customization requires additional logic to support |
| Removing a version requires using the command `terraform destroy -target` where the specific version module is targeted. |
| Assumes all packs are defined in the same registry. Otherwise, additional logic is required. |

## Usage

1. To add a new version, create a new module in the `modules` directory. The module name should be the version number. For example, if you are adding version `1.0.0`, the module name would be `[your-module-name-1-0-0]`. Populate with all the required variables and resources.

```hcl
module "primary-cp-1-0-0" {
source = "../cp-modules"
name = "md-test"
infrastructure_provider = "aws"
cluster_profile_type = "cluster"
registry_name = "Public Repo"
profile_version = "1.0.0"
pack_order = ["ubuntu-aws", "kubernetes","cni-calico", "csi-aws-ebs" ]
packs = {
"csi-aws-ebs" = "1.22.0"
"cni-calico" = "3.26.1"
"kubernetes" = "1.27.5"
"ubuntu-aws" = "22.04"
}
}
```

2. The module requires you to explicity define the order of the packs. This is done through the `pack_order` variable. The order of the packs is important because it determines the order in which the packs are applied to the cluster. The first item in the list has the highest priority and the last item in the list has the lowest priority. This corresponds to the order in which the packs are applied to the cluster profile.

3. The module requires you to explicity define the pack name and version. This is done through the `packs` variable. The pack name and version are used to create the pack resource. You can also define the pack registry name through the `registry_name` variable. If the pack registry name is not defined, the default registry is used.


4. To add a new version to the cluster profile, add a new module resource to the `spectrocloud_cluster_profile` resource. The module name should be the version number. For example, if you are adding version `1.0.1`, the module name would be `[your-module-name-1-0-1]`.

```hcl
module "primary-cp-1-0-1" {
source = "../cp-modules"
name = "md-test"
infrastructure_provider = "aws"
cluster_profile_type = "cluster"
registry_name = "Public Repo"
profile_version = "1.0.1"
pack_order = ["ubuntu-aws", "kubernetes","cni-calico", "csi-aws-ebs" ]
packs = {
"csi-aws-ebs" = "1.22.0"
"cni-calico" = "3.26.1"
"kubernetes" = "1.27.5"
"ubuntu-aws" = "22.04"
}
}
```

5. To use the new version, update the `spectrocloud_cluster` resource to use the new version.

```hcl
resource "spectrocloud_cluster" "primary-cluster" {
name = "primary-cluster"
cluster_profile = module.primary-cp-1-0-1.id
....
}
```

> [!NOTE]
> You can also access all the exported attributes from the module. To search for an exported attribute, reference the module `module.primary-cp-1-0-1` and add a `.` to the end of the module name. This will display all the exported attributes, assuming your editor supports the Terraform language server.

0 comments on commit b90315a

Please sign in to comment.