Skip to content

Commit 4c91f9b

Browse files
authored
Merge pull request #24 from equinix-labs/add_k3s
feat: added k3s module, addons, examples, updated READMEs
2 parents 3942250 + 4c253ed commit 4c91f9b

27 files changed

+518
-119
lines changed

.gitignore

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Session.vim
2626
*.tfstate
2727
*.tfstate.*
2828

29+
.terraform.lock.hcl
30+
2931
# Crash log files
3032
crash.log
3133

@@ -42,12 +44,6 @@ override.tf.json
4244
*_override.tf
4345
*_override.tf.json
4446

45-
# Include override files you do wish to add to version control using negated pattern
46-
#
47-
# !example_override.tf
48-
!.terraform.lock.hcl
49-
**/*/.terraform.lock.hcl
50-
5147
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
5248
# example: *tfplan*
5349
**/terraform.tfvars

.terraform.lock.hcl

Lines changed: 0 additions & 103 deletions
This file was deleted.

README.md

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

3232
| Name | Description |
3333
|------|---------|
34+
| [k3s-setup](./examples/k3s-setup/) | Deploys a SUSE K3s cluster into existing projects |
35+
| [k3s-setup-new](./examples/k3s-setup-new/) | Deploys a SUSE K3s cluster into new projects provisioned for each user described in users.csv |
3436
| [eksa-setup](./examples/eksa-setup/) | Deploys a AWS EKS-A cluster into existing projects |
3537
| [eksa-setup-new](./examples/eksa-setup-new/) | Deploys a AWS EKS-A cluster into new projects provisioned for each user described in users.csv |
3638
| [metal-setup](./examples/metal-setup/) | Deploys a cluster or bare nodes into existing projects |
@@ -52,6 +54,7 @@ No providers.
5254
| Name | Source | Version |
5355
|------|--------|---------|
5456
| <a name="module_deploy_eksa"></a> [deploy\_eksa](#module\_deploy\_eksa) | ./modules/eksa | n/a |
57+
| <a name="module_deploy_k3s"></a> [deploy\_k3s](#module\_deploy\_k3s) | ./modules/k3s | n/a |
5558
| <a name="module_deploy_metal"></a> [deploy\_metal](#module\_deploy\_metal) | ./modules/metal | n/a |
5659
| <a name="module_project_setup"></a> [project\_setup](#module\_project\_setup) | ./modules/invite-from-csv | n/a |
5760

@@ -63,14 +66,17 @@ No resources.
6366

6467
| Name | Description | Type | Default | Required |
6568
|------|-------------|------|---------|:--------:|
66-
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
67-
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
6869
| <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 |
6970
| <a name="input_enable_eksa"></a> [enable\_eksa](#input\_enable\_eksa) | Enable EKSA module | `bool` | `false` | no |
71+
| <a name="input_enable_k3s"></a> [enable\_k3s](#input\_enable\_k3s) | Enable K3s module | `bool` | `false` | no |
7072
| <a name="input_enable_metal"></a> [enable\_metal](#input\_enable\_metal) | Enable Metal module | `bool` | `false` | no |
7173
| <a name="input_enable_workshop_setup"></a> [enable\_workshop\_setup](#input\_enable\_workshop\_setup) | Enable Workshop Setup module | `bool` | `false` | no |
74+
| <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 | `bool` | `false` | no |
75+
| <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": true,<br> "k3s_version": "",<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 |
76+
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
7277
| <a name="input_metal_config"></a> [metal\_config](#input\_metal\_config) | Configuration for Metal module | <pre>object({<br> device_count = number<br> os = string<br> billing_cycle = string<br> cluster_name = string<br> device_type = string<br> })</pre> | <pre>{<br> "billing_cycle": "hourly",<br> "cluster_name": "metal-cluster",<br> "device_count": 3,<br> "device_type": "m3.small.x86",<br> "os": "ubuntu_20_04"<br>}</pre> | no |
7378
| <a name="input_metal_metro"></a> [metal\_metro](#input\_metal\_metro) | Equinix Metal metro | `string` | `"sv"` | no |
79+
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
7480
| <a name="input_metal_project_id"></a> [metal\_project\_id](#input\_metal\_project\_id) | Project ID | `string` | `""` | no |
7581
| <a name="input_metal_tags"></a> [metal\_tags](#input\_metal\_tags) | String list of common tags for Equinix resources | `list(string)` | <pre>[<br> "terraform",<br> "equinix-labs"<br>]</pre> | no |
7682

@@ -79,6 +85,7 @@ No resources.
7985
| Name | Description |
8086
|------|-------------|
8187
| <a name="output_deploy_eksa_outputs"></a> [deploy\_eksa\_outputs](#output\_deploy\_eksa\_outputs) | Outputs of the Deploy EKSA module |
88+
| <a name="output_deploy_k3s_outputs"></a> [deploy\_k3s\_outputs](#output\_deploy\_k3s\_outputs) | Outputs of the Deploy K3s module |
8289
| <a name="output_deploy_metal_outputs"></a> [deploy\_metal\_outputs](#output\_deploy\_metal\_outputs) | Outputs of the Deploy Metal module |
8390
| <a name="output_project_setup_outputs"></a> [project\_setup\_outputs](#output\_project\_setup\_outputs) | Outputs of the Project Setup module |
8491
<!-- END_TF_DOCS -->

examples/eksa-setup-new/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ output "workshop_setup_outputs" {
55
value = { for k, v in module.workshop_setup.project_setup_outputs : k => v }
66
}
77

8-
# Module Deploy Metal Outputs
8+
# Module Deploy EKSA Outputs
99
output "deploy_eksa_outputs" {
1010
description = "Outputs of the Deploy EKSA module"
1111

examples/eksa-setup/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Module Deploy Metal Outputs
1+
# Module Deploy EKSA Outputs
22
output "deploy_eksa_outputs" {
33
description = "Outputs of the Deploy EKSA module"
44

examples/k3s-setup-new/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Terraform Equinix Labs K3s 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 [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.
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_k3s"></a> [deploy\_k3s](#module\_deploy\_k3s) | ../../ | 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_enable_k3s"></a> [enable\_k3s](#input\_enable\_k3s) | Enable K3s module | `bool` | `true` | no |
33+
| <a name="input_enable_workshop_setup"></a> [enable\_workshop\_setup](#input\_enable\_workshop\_setup) | Enable Workshop Setup module | `bool` | `true` | no |
34+
| <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 |
35+
| <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 |
36+
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
37+
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
38+
39+
## Outputs
40+
41+
| Name | Description |
42+
|------|-------------|
43+
| <a name="output_deploy_k3s_outputs"></a> [deploy\_k3s\_outputs](#output\_deploy\_k3s\_outputs) | Outputs of the Deploy K3s module |
44+
| <a name="output_workshop_setup_outputs"></a> [workshop\_setup\_outputs](#output\_workshop\_setup\_outputs) | Outputs of the Workshop Setup module |
45+
<!-- END_TF_DOCS -->

examples/k3s-setup-new/main.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 K3s module if platform of choice is K3s
27+
module "deploy_k3s" {
28+
for_each = { for k, v in module.workshop_setup.project_setup_outputs[0].invite_from_csv_outputs : k => v if var.enable_k3s }
29+
enable_k3s = var.enable_k3s
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+
global_ip = var.global_ip
35+
k3s_config = var.k3s_config
36+
}

examples/k3s-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 K3s Outputs
9+
output "deploy_k3s_outputs" {
10+
description = "Outputs of the Deploy K3s module"
11+
12+
value = { for k, v in var.k3s_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

0 commit comments

Comments
 (0)