Skip to content

Commit 3ee17d5

Browse files
authored
Merge pull request #31 from equinix-labs/add_k8s
feat: added k8s add-on with examples
2 parents ff996a6 + 6b59cc6 commit 3ee17d5

19 files changed

+397
-2
lines changed

README.md

Lines changed: 8 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+
| [k8s-setup](./examples/k8s-setup/) | Deploys a kubernetes cluster into existing projects |
35+
| [k8s-setup-new](./examples/k8s-setup-new/) | Deploys a kubernetes cluster into new projects provisioned for each user described in users.csv |
3436
| [k3s-setup](./examples/k3s-setup/) | Deploys a SUSE K3s cluster into existing projects |
3537
| [k3s-setup-new](./examples/k3s-setup-new/) | Deploys a SUSE K3s cluster into new projects provisioned for each user described in users.csv |
3638
| [eksa-setup](./examples/eksa-setup/) | Deploys a AWS EKS-A cluster into existing projects |
@@ -55,6 +57,7 @@ No providers.
5557
|------|--------|---------|
5658
| <a name="module_deploy_eksa"></a> [deploy\_eksa](#module\_deploy\_eksa) | ./modules/eksa | n/a |
5759
| <a name="module_deploy_k3s"></a> [deploy\_k3s](#module\_deploy\_k3s) | ./modules/k3s | n/a |
60+
| <a name="module_deploy_k8s"></a> [deploy\_k8s](#module\_deploy\_k8s) | ./modules/k8s | n/a |
5861
| <a name="module_deploy_metal"></a> [deploy\_metal](#module\_deploy\_metal) | ./modules/metal | n/a |
5962
| <a name="module_project_setup"></a> [project\_setup](#module\_project\_setup) | ./modules/invite-from-csv | n/a |
6063

@@ -66,17 +69,19 @@ No resources.
6669

6770
| Name | Description | Type | Default | Required |
6871
|------|-------------|------|---------|:--------:|
69-
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
70-
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
7172
| <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 |
7273
| <a name="input_enable_eksa"></a> [enable\_eksa](#input\_enable\_eksa) | Enable EKSA module | `bool` | `false` | no |
7374
| <a name="input_enable_k3s"></a> [enable\_k3s](#input\_enable\_k3s) | Enable K3s module | `bool` | `false` | no |
75+
| <a name="input_enable_k8s"></a> [enable\_k8s](#input\_enable\_k8s) | Enable k8s module | `bool` | `false` | no |
7476
| <a name="input_enable_metal"></a> [enable\_metal](#input\_enable\_metal) | Enable Metal module | `bool` | `false` | no |
7577
| <a name="input_enable_workshop_setup"></a> [enable\_workshop\_setup](#input\_enable\_workshop\_setup) | Enable Workshop Setup module | `bool` | `false` | no |
7678
| <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 |
7779
| <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 |
80+
| <a name="input_k8s_config"></a> [k8s\_config](#input\_k8s\_config) | Module configuration for k8s module | <pre>object({<br> kube_vip_version = string<br> kubernetes_version = string<br> ssh_private_key_path = string<br> cp_ha = bool<br> worker_host_count = number<br> })</pre> | <pre>{<br> "cp_ha": true,<br> "kube_vip_version": "v0.6.2",<br> "kubernetes_version": "v1.27.5",<br> "ssh_private_key_path": "",<br> "worker_host_count": 1<br>}</pre> | no |
81+
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
7882
| <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 |
7983
| <a name="input_metal_metro"></a> [metal\_metro](#input\_metal\_metro) | Equinix Metal metro | `string` | `"sv"` | no |
84+
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
8085
| <a name="input_metal_project_id"></a> [metal\_project\_id](#input\_metal\_project\_id) | Project ID | `string` | `""` | no |
8186
| <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 |
8287

@@ -86,6 +91,7 @@ No resources.
8691
|------|-------------|
8792
| <a name="output_deploy_eksa_outputs"></a> [deploy\_eksa\_outputs](#output\_deploy\_eksa\_outputs) | Outputs of the Deploy EKSA module |
8893
| <a name="output_deploy_k3s_outputs"></a> [deploy\_k3s\_outputs](#output\_deploy\_k3s\_outputs) | Outputs of the Deploy K3s module |
94+
| <a name="output_deploy_k8s_outputs"></a> [deploy\_k8s\_outputs](#output\_deploy\_k8s\_outputs) | Outputs of the Deploy k8s module |
8995
| <a name="output_deploy_metal_outputs"></a> [deploy\_metal\_outputs](#output\_deploy\_metal\_outputs) | Outputs of the Deploy Metal module |
9096
| <a name="output_project_setup_outputs"></a> [project\_setup\_outputs](#output\_project\_setup\_outputs) | Outputs of the Project Setup module |
9197
<!-- END_TF_DOCS -->

examples/k8s-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 Kubernetes 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 [k8s](https://github.com/equinix-labs/terraform-equinix-labs/tree/main/modules/k8s) 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_k8s"></a> [deploy\_k8s](#module\_deploy\_k8s) | ../../ | 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_k8s"></a> [enable\_k8s](#input\_enable\_k8s) | Enable EKSA 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_k8s_config"></a> [k8s\_config](#input\_k8s\_config) | Module configuration for k8s module | <pre>object({<br> kube_vip_version = string<br> kubernetes_version = string<br> ssh_private_key_path = string<br> cp_ha = bool<br> worker_host_count = number<br> })</pre> | <pre>{<br> "cp_ha": true,<br> "kube_vip_version": "v0.6.2",<br> "kubernetes_version": "v1.27.5",<br> "ssh_private_key_path": "",<br> "worker_host_count": 1<br>}</pre> | no |
35+
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal user api token. | `string` | n/a | yes |
36+
| <a name="input_metal_organization_id"></a> [metal\_organization\_id](#input\_metal\_organization\_id) | Equinix Metal organization id | `string` | n/a | yes |
37+
38+
## Outputs
39+
40+
| Name | Description |
41+
|------|-------------|
42+
| <a name="output_deploy_k8s_outputs"></a> [deploy\_k8s\_outputs](#output\_deploy\_k8s\_outputs) | Outputs of the Deploy k8s 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/k8s-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 k8s module if platform of choice is k8s
27+
module "deploy_k8s" {
28+
for_each = { for k, v in module.workshop_setup.project_setup_outputs[0].invite_from_csv_outputs : k => v if var.enable_k8s }
29+
enable_k8s = var.enable_k8s
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+
k8s_config = var.k8s_config
35+
}

examples/k8s-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 = module.workshop_setup.project_setup_outputs
6+
}
7+
8+
# Module Deploy k8s Outputs
9+
output "deploy_k8s_outputs" {
10+
description = "Outputs of the Deploy k8s module"
11+
12+
value = var.k8s_config
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"

examples/k8s-setup-new/variables.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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_k8s" {
20+
type = bool
21+
description = "Enable EKSA module"
22+
default = true
23+
}
24+
25+
variable "k8s_config" {
26+
description = "Module configuration for k8s module"
27+
type = object({
28+
kube_vip_version = string
29+
kubernetes_version = string
30+
ssh_private_key_path = string
31+
cp_ha = bool
32+
worker_host_count = number
33+
})
34+
default = {
35+
kube_vip_version = "v0.6.2"
36+
kubernetes_version = "v1.27.5"
37+
ssh_private_key_path = ""
38+
cp_ha = true
39+
worker_host_count = 1
40+
}
41+
}

examples/k8s-setup/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Terraform Equinix Labs Kubernetes Setup Example
2+
3+
This is an example of how to utilize the root module to deploy the [k8s](https://github.com/equinix-labs/terraform-equinix-labs/tree/main/modules/k8s) 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 `k8s_config` in 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_k8s"></a> [deploy\_k8s](#module\_deploy\_k8s) | ../../ | n/a |
22+
23+
## Resources
24+
25+
No resources.
26+
27+
## Inputs
28+
29+
| Name | Description | Type | Default | Required |
30+
|------|-------------|------|---------|:--------:|
31+
| <a name="input_enable_k8s"></a> [enable\_k8s](#input\_enable\_k8s) | Enable EKSA module | `bool` | `true` | no |
32+
| <a name="input_k8s_config"></a> [k8s\_config](#input\_k8s\_config) | Module configuration for k8s module | <pre>object({<br> kube_vip_version = string<br> kubernetes_version = string<br> ssh_private_key_path = string<br> cp_ha = bool<br> worker_host_count = number<br> })</pre> | <pre>{<br> "cp_ha": true,<br> "kube_vip_version": "v0.6.2",<br> "kubernetes_version": "v1.27.5",<br> "ssh_private_key_path": "",<br> "worker_host_count": 1<br>}</pre> | 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 |
36+
37+
## Outputs
38+
39+
| Name | Description |
40+
|------|-------------|
41+
| <a name="output_deploy_k8s_outputs"></a> [deploy\_k8s\_outputs](#output\_deploy\_k8s\_outputs) | Outputs of the Deploy k8s module |
42+
<!-- END_TF_DOCS -->

examples/k8s-setup/main.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
# Deploy the k8s module if platform of choice is k8s
19+
module "deploy_k8s" {
20+
for_each = { for k, v in var.metal_project_ids : k => v if var.enable_k8s }
21+
enable_k8s = var.enable_k8s
22+
source = "../../"
23+
metal_organization_id = var.metal_organization_id
24+
metal_auth_token = var.metal_auth_token
25+
metal_project_id = each.value
26+
k8s_config = var.k8s_config
27+
}

examples/k8s-setup/outputs.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Module Deploy EKSA Outputs
2+
output "deploy_k8s_outputs" {
3+
description = "Outputs of the Deploy k8s module"
4+
5+
value = var.k8s_config
6+
7+
}

0 commit comments

Comments
 (0)