generated from equinix-labs/terraform-equinix-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from equinix-labs/add_k3s
feat: added k3s module, addons, examples, updated READMEs
- Loading branch information
Showing
27 changed files
with
518 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Terraform Equinix Labs K3s Setup Example | ||
|
||
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 [k3s](https://github.com/equinix-labs/terraform-equinix-metal-k3s) 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. | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 | | ||
| <a name="requirement_equinix"></a> [equinix](#requirement\_equinix) | >= 1.10.0 | | ||
|
||
## Providers | ||
|
||
No providers. | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_deploy_k3s"></a> [deploy\_k3s](#module\_deploy\_k3s) | ../../ | n/a | | ||
| <a name="module_workshop_setup"></a> [workshop\_setup](#module\_workshop\_setup) | ../../ | n/a | | ||
|
||
## Resources | ||
|
||
No resources. | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_enable_k3s"></a> [enable\_k3s](#input\_enable\_k3s) | Enable K3s module | `bool` | `true` | no | | ||
| <a name="input_enable_workshop_setup"></a> [enable\_workshop\_setup](#input\_enable\_workshop\_setup) | Enable Workshop Setup module | `bool` | `true` | no | | ||
| <a name="input_global_ip"></a> [global\_ip](#input\_global\_ip) | Enables a global anycast IPv4 that will be shared for all clusters in all metros | `string` | `false` | no | | ||
| <a name="input_k3s_config"></a> [k3s\_config](#input\_k3s\_config) | Module configuration for K3s module | <pre>list(object({<br> name = string<br> metro = string<br> plan_control_plane = string<br> plan_node = string<br> node_count = number<br> k3s_ha = bool<br> os = string<br> control_plane_hostnames = string<br> node_hostnames = string<br> custom_k3s_token = string<br> ip_pool_count = number<br> k3s_version = string<br> metallb_version = string<br> }))</pre> | <pre>[<br> {<br> "control_plane_hostnames": "k3s-cp",<br> "custom_k3s_token": "",<br> "ip_pool_count": 1,<br> "k3s_ha": false,<br> "k3s_version": "v1.4.stable.1",<br> "metallb_version": "",<br> "metro": "SV",<br> "name": "k3s-cluster",<br> "node_count": 3,<br> "node_hostnames": "k3s-node",<br> "os": "debian_11",<br> "plan_control_plane": "c3.small.x86",<br> "plan_node": "c3.small.x86"<br> }<br>]</pre> | no | | ||
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes | | ||
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_deploy_k3s_outputs"></a> [deploy\_k3s\_outputs](#output\_deploy\_k3s\_outputs) | Outputs of the Deploy K3s module | | ||
| <a name="output_workshop_setup_outputs"></a> [workshop\_setup\_outputs](#output\_workshop\_setup\_outputs) | Outputs of the Workshop Setup module | | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Setup provider block | ||
terraform { | ||
required_version = ">= 1.3" | ||
|
||
required_providers { | ||
equinix = { | ||
source = "equinix/equinix" | ||
version = ">= 1.10.0" | ||
} | ||
} | ||
} | ||
|
||
# Setup metal auth token for provider | ||
provider "equinix" { | ||
auth_token = var.metal_auth_token | ||
} | ||
|
||
# Setup the workshop | ||
module "workshop_setup" { | ||
enable_workshop_setup = var.enable_workshop_setup | ||
source = "../../" | ||
metal_organization_id = var.metal_organization_id | ||
metal_auth_token = var.metal_auth_token | ||
} | ||
|
||
# Deploy the K3s module if platform of choice is K3s | ||
module "deploy_k3s" { | ||
for_each = { for k, v in module.workshop_setup.project_setup_outputs[0].invite_from_csv_outputs : k => v if var.enable_k3s } | ||
enable_k3s = var.enable_k3s | ||
source = "../../" | ||
metal_organization_id = var.metal_organization_id | ||
metal_auth_token = var.metal_auth_token | ||
metal_project_id = each.value.collaborator_project_id | ||
global_ip = var.global_ip | ||
k3s_config = var.k3s_config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Module Workshop Setup Outputs | ||
output "workshop_setup_outputs" { | ||
description = "Outputs of the Workshop Setup module" | ||
|
||
value = { for k, v in module.workshop_setup.project_setup_outputs : k => v } | ||
} | ||
|
||
# Module Deploy K3s Outputs | ||
output "deploy_k3s_outputs" { | ||
description = "Outputs of the Deploy K3s module" | ||
|
||
value = { for k, v in var.k3s_config : k => v } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
metal_api_token="your_token_here" #This must be a user API token | ||
metal_organization_id="your_organization_id" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
email,metro,plan | ||
may@example.com,da,m3.small.x86 | ||
chris@example.com,da,m3.small.x86 | ||
oscar@example.com,da,m3.small.x86 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Module Vars | ||
variable "metal_auth_token" { | ||
description = "Equinix Metal user api token." | ||
type = string | ||
sensitive = true | ||
} | ||
|
||
variable "metal_organization_id" { | ||
type = string | ||
description = "Equinix Metal organization id" | ||
} | ||
|
||
variable "enable_workshop_setup" { | ||
type = bool | ||
description = "Enable Workshop Setup module" | ||
default = true | ||
} | ||
|
||
variable "global_ip" { | ||
description = "Enables a global anycast IPv4 that will be shared for all clusters in all metros" | ||
type = string | ||
default = false | ||
} | ||
|
||
variable "enable_k3s" { | ||
type = bool | ||
description = "Enable K3s module" | ||
default = true | ||
} | ||
|
||
# Module Config | ||
variable "k3s_config" { | ||
description = "Module configuration for K3s module" | ||
type = list(object({ | ||
name = string | ||
metro = string | ||
plan_control_plane = string | ||
plan_node = string | ||
node_count = number | ||
k3s_ha = bool | ||
os = string | ||
control_plane_hostnames = string | ||
node_hostnames = string | ||
custom_k3s_token = string | ||
ip_pool_count = number | ||
k3s_version = string | ||
metallb_version = string | ||
})) | ||
default = [{ | ||
name = "k3s-cluster" | ||
metro = "SV" | ||
plan_control_plane = "c3.small.x86" | ||
plan_node = "c3.small.x86" | ||
node_count = 3 | ||
k3s_ha = false | ||
os = "debian_11" | ||
control_plane_hostnames = "k3s-cp" | ||
node_hostnames = "k3s-node" | ||
custom_k3s_token = "" | ||
ip_pool_count = 1 | ||
k3s_version = "v1.4.stable.1" | ||
metallb_version = "" | ||
}] | ||
} |
Oops, something went wrong.