Skip to content

Commit 443c478

Browse files
authored
Merge pull request #15 from equinix-labs/add_new_examples
chore: Add more deployment examples in the examples folder
2 parents e96b833 + 76574e0 commit 443c478

21 files changed

+299
-57
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ This project may be deployed into new project(s) or existing project(s). Check o
2222

2323
| Name | Description |
2424
|------|---------|
25-
| [eksa-setup](./examples/eksa-setup/) | Deploys a AWS EKS-A cluster into new projects provisioned for each user described in users.csv |
26-
| [metal-setup](./examples/metal-setup/) | Deploys a cluster or bare nodes into new projects provisioned for each user described in users.csv |
25+
| [eksa-setup](./examples/eksa-setup/) | Deploys a AWS EKS-A cluster into existing projects |
26+
| [eksa-setup-new](./examples/eksa-setup-new/) | Deploys a AWS EKS-A cluster into new projects provisioned for each user described in users.csv |
27+
| [metal-setup](./examples/metal-setup/) | Deploys a cluster or bare nodes into existing projects |
28+
| [metal-setup-new](./examples/metal-setup-new/) | Deploys a cluster or bare nodes into new projects provisioned for each user described in users.csv |
2729

2830
<!-- BEGIN_TF_DOCS -->
2931
## Requirements

examples/eksa-setup-new/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Terraform Equinix Labs EKSA Setup Example
2+
3+
This is an example of how to utilize the root module to deploy the [invite-from-csv](https://github.com/equinix-labs/terraform-equinix-labs/tree/main/modules/invite-from-csv) module and the [eksa](https://github.com/equinix-labs/terraform-equinix-labs/tree/main/modules/eksa) module. In this example, each user identified in the `users.csv` file (see users.csv.example) will have a project provisioned and an invitation sent by email to join that project. Kubernetes will then be provisioned into each user's project with the configurations set within the [variables.tf](./variables.tf) file.
4+
5+
<!-- BEGIN_TF_DOCS -->
6+
## Requirements
7+
8+
| Name | Version |
9+
|------|---------|
10+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
11+
| <a name="requirement_equinix"></a> [equinix](#requirement\_equinix) | >= 1.10.0 |
12+
13+
## Providers
14+
15+
No providers.
16+
17+
## Modules
18+
19+
| Name | Source | Version |
20+
|------|--------|---------|
21+
| <a name="module_deploy_eksa"></a> [deploy\_eksa](#module\_deploy\_eksa) | ../../ | n/a |
22+
| <a name="module_workshop_setup"></a> [workshop\_setup](#module\_workshop\_setup) | ../../ | n/a |
23+
24+
## Resources
25+
26+
No resources.
27+
28+
## Inputs
29+
30+
| Name | Description | Type | Default | Required |
31+
|------|-------------|------|---------|:--------:|
32+
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
33+
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
34+
| <a name="input_eksa_config"></a> [eksa\_config](#input\_eksa\_config) | Module configuration for EKSA module | <pre>object({<br> cluster_name = string<br> cp_device_count = number<br> worker_device_count = number<br> })</pre> | <pre>{<br> "cluster_name": "equinix-labs-cluster",<br> "cp_device_count": 3,<br> "worker_device_count": 3<br>}</pre> | no |
35+
| <a name="input_enable_eksa"></a> [enable\_eksa](#input\_enable\_eksa) | Enable EKSA module | `bool` | `true` | no |
36+
| <a name="input_enable_workshop_setup"></a> [enable\_workshop\_setup](#input\_enable\_workshop\_setup) | Enable Workshop Setup module | `bool` | `true` | no |
37+
38+
## Outputs
39+
40+
| Name | Description |
41+
|------|-------------|
42+
| <a name="output_deploy_eksa_outputs"></a> [deploy\_eksa\_outputs](#output\_deploy\_eksa\_outputs) | Outputs of the Deploy EKSA module |
43+
| <a name="output_workshop_setup_outputs"></a> [workshop\_setup\_outputs](#output\_workshop\_setup\_outputs) | Outputs of the Workshop Setup module |
44+
<!-- END_TF_DOCS -->

examples/eksa-setup-new/main.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Setup provider block
2+
terraform {
3+
required_version = ">= 1.3"
4+
5+
required_providers {
6+
equinix = {
7+
source = "equinix/equinix"
8+
version = ">= 1.10.0"
9+
}
10+
}
11+
}
12+
13+
# Setup metal auth token for provider
14+
provider "equinix" {
15+
auth_token = var.metal_auth_token
16+
}
17+
18+
# Setup the workshop
19+
module "workshop_setup" {
20+
enable_workshop_setup = var.enable_workshop_setup
21+
source = "../../"
22+
metal_organization_id = var.metal_organization_id
23+
metal_auth_token = var.metal_auth_token
24+
}
25+
26+
# Deploy the EKSA module if platform of choice is EKSA
27+
module "deploy_eksa" {
28+
for_each = { for k, v in module.workshop_setup.project_setup_outputs[0].invite_from_csv_outputs : k => v if var.enable_eksa }
29+
enable_eksa = var.enable_eksa
30+
source = "../../"
31+
metal_organization_id = var.metal_organization_id
32+
metal_auth_token = var.metal_auth_token
33+
metal_project_id = each.value.collaborator_project_id
34+
eksa_config = var.eksa_config
35+
}

examples/eksa-setup-new/outputs.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Module Workshop Setup Outputs
2+
output "workshop_setup_outputs" {
3+
description = "Outputs of the Workshop Setup module"
4+
5+
value = { for k, v in module.workshop_setup.project_setup_outputs : k => v }
6+
}
7+
8+
# Module Deploy Metal Outputs
9+
output "deploy_eksa_outputs" {
10+
description = "Outputs of the Deploy EKSA module"
11+
12+
value = { for k, v in var.eksa_config : k => v }
13+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
metal_api_token="your_token_here" #This must be a user API token
2+
metal_organization_id="your_organization_id"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
email,metro,plan
2+
[email protected],da,m3.small.x86
3+
[email protected],da,m3.small.x86
4+
[email protected],da,m3.small.x86

examples/eksa-setup-new/variables.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Module Vars
2+
variable "metal_auth_token" {
3+
description = "Equinix Metal user api token."
4+
type = string
5+
sensitive = true
6+
}
7+
8+
variable "metal_organization_id" {
9+
type = string
10+
description = "Equinix Metal organization id"
11+
}
12+
13+
variable "enable_workshop_setup" {
14+
type = bool
15+
description = "Enable Workshop Setup module"
16+
default = true
17+
}
18+
19+
variable "enable_eksa" {
20+
type = bool
21+
description = "Enable EKSA module"
22+
default = true
23+
}
24+
25+
variable "eksa_config" {
26+
description = "Module configuration for EKSA module"
27+
type = object({
28+
cluster_name = string
29+
cp_device_count = number
30+
worker_device_count = number
31+
})
32+
default = {
33+
cluster_name = "equinix-labs-cluster"
34+
cp_device_count = 3
35+
worker_device_count = 3
36+
}
37+
}

examples/eksa-setup/README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Terraform Equinix Labs EKSA Setup Example
1+
# Terraform Equinix Labs ESKA Setup Example
22

3-
This is an example of how to utilize the root module to deploy the [invite-from-csv](https://github.com/equinix-labs/terraform-equinix-labs/tree/main/modules/invite-from-csv) module and the [eksa](https://github.com/equinix-labs/terraform-equinix-labs/tree/main/modules/eksa) module. In this example, each user identified in the `users.csv` file (see users.csv.example) will have a project provisioned and an invitation sent by email to join that project. Kubernetes will then be provisioned into each user's project with the configurations set within the [variables.tf](./variables.tf) file.
3+
This is an example of how to utilize the root module to deploy the [eksa](https://github.com/equinix-labs/terraform-equinix-labs/tree/main/modules/eksa) module. In this example, deployment target projects must identified by the variable `metal_project_ids`. Kubernetes will then be provisioned into each project defined by variable `metal_project_ids` with the configurations set by variable `eksa_config` in the [variables.tf](./variables.tf) file.
44

55
<!-- BEGIN_TF_DOCS -->
66
## Requirements
@@ -19,7 +19,6 @@ No providers.
1919
| Name | Source | Version |
2020
|------|--------|---------|
2121
| <a name="module_deploy_eksa"></a> [deploy\_eksa](#module\_deploy\_eksa) | ../../ | n/a |
22-
| <a name="module_workshop_setup"></a> [workshop\_setup](#module\_workshop\_setup) | ../../ | n/a |
2322

2423
## Resources
2524

@@ -29,16 +28,15 @@ No resources.
2928

3029
| Name | Description | Type | Default | Required |
3130
|------|-------------|------|---------|:--------:|
32-
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
33-
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
3431
| <a name="input_eksa_config"></a> [eksa\_config](#input\_eksa\_config) | Module configuration for EKSA module | <pre>object({<br> cluster_name = string<br> cp_device_count = number<br> worker_device_count = number<br> })</pre> | <pre>{<br> "cluster_name": "equinix-labs-cluster",<br> "cp_device_count": 3,<br> "worker_device_count": 3<br>}</pre> | no |
3532
| <a name="input_enable_eksa"></a> [enable\_eksa](#input\_enable\_eksa) | Enable EKSA module | `bool` | `true` | no |
36-
| <a name="input_enable_workshop_setup"></a> [enable\_workshop\_setup](#input\_enable\_workshop\_setup) | Enable Workshop Setup module | `bool` | `true` | no |
33+
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
34+
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
35+
| <a name="input_metal_project_ids"></a> [metal\_project\_ids](#input\_metal\_project\_ids) | Project ID to deploy EKSA into | `list(string)` | `[]` | no |
3736

3837
## Outputs
3938

4039
| Name | Description |
4140
|------|-------------|
4241
| <a name="output_deploy_eksa_outputs"></a> [deploy\_eksa\_outputs](#output\_deploy\_eksa\_outputs) | Outputs of the Deploy EKSA module |
43-
| <a name="output_workshop_setup_outputs"></a> [workshop\_setup\_outputs](#output\_workshop\_setup\_outputs) | Outputs of the Workshop Setup module |
4442
<!-- END_TF_DOCS -->

examples/eksa-setup/main.tf

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,13 @@ provider "equinix" {
1515
auth_token = var.metal_auth_token
1616
}
1717

18-
# Setup the workshop
19-
module "workshop_setup" {
20-
enable_workshop_setup = var.enable_workshop_setup
21-
source = "../../"
22-
metal_organization_id = var.metal_organization_id
23-
metal_auth_token = var.metal_auth_token
24-
}
25-
2618
# Deploy the EKSA module if platform of choice is EKSA
2719
module "deploy_eksa" {
28-
for_each = { for k, v in module.workshop_setup.project_setup_outputs[0].invite_from_csv_outputs : k => v if var.enable_eksa }
20+
for_each = { for k, v in var.metal_project_ids : k => v if var.enable_eksa }
2921
enable_eksa = var.enable_eksa
3022
source = "../../"
3123
metal_organization_id = var.metal_organization_id
3224
metal_auth_token = var.metal_auth_token
33-
metal_project_id = each.value.collaborator_project_id
25+
metal_project_id = each.value
3426
eksa_config = var.eksa_config
3527
}

examples/eksa-setup/outputs.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# Module Workshop Setup Outputs
2-
output "workshop_setup_outputs" {
3-
description = "Outputs of the Workshop Setup module"
4-
5-
value = { for k, v in module.workshop_setup.project_setup_outputs : k => v }
6-
}
7-
81
# Module Deploy Metal Outputs
92
output "deploy_eksa_outputs" {
103
description = "Outputs of the Deploy EKSA module"

0 commit comments

Comments
 (0)