Skip to content

Commit

Permalink
October 2024 revamp
Browse files Browse the repository at this point in the history
Replaced Bird by native MetalLB
Setup Ingress IP properly
Added Rancher deployment
K3s or RKE2 available

Also, fixed pre-commit action
  • Loading branch information
e-minguez committed Oct 3, 2024
1 parent 0be4cdf commit 0b0ac79
Show file tree
Hide file tree
Showing 17 changed files with 1,144 additions and 552 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:

- name: Install Python3
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install tflint
uses: terraform-linters/setup-tflint@v4
Expand Down
289 changes: 215 additions & 74 deletions README.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions examples/demo_cluster/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SiDemo Cluster Example
# Demo Cluster Examples

This example demonstrates usage of the Equinix Metal K3s module. A Demo application is installed.
This example demonstrates usage of the Equinix Metal K3s/RKE2 module. A Demo application is installed.

## Usage

Expand Down Expand Up @@ -36,15 +36,15 @@ No resources.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Your Equinix Metal API key | `string` | n/a | yes |
| <a name="input_metal_project_id"></a> [metal\_project\_id](#input\_metal\_project\_id) | Your Equinix Metal Project ID | `string` | n/a | yes |
| <a name="input_clusters"></a> [clusters](#input\_clusters) | K3s cluster definition | <pre>list(object({<br> name = optional(string, "K3s demo cluster")<br> metro = optional(string, "FR")<br> plan_control_plane = optional(string, "c3.small.x86")<br> plan_node = optional(string, "c3.small.x86")<br> node_count = optional(number, 0)<br> k3s_ha = optional(bool, false)<br> os = optional(string, "debian_11")<br> control_plane_hostnames = optional(string, "k3s-cp")<br> node_hostnames = optional(string, "k3s-node")<br> custom_k3s_token = optional(string, "")<br> ip_pool_count = optional(number, 0)<br> k3s_version = optional(string, "")<br> metallb_version = optional(string, "")<br> }))</pre> | <pre>[<br> {}<br>]</pre> | no |
| <a name="input_clusters"></a> [clusters](#input\_clusters) | Cluster definition | <pre>list(object({<br/> name = optional(string, "Demo cluster")<br/> metro = optional(string, "FR")<br/> plan_control_plane = optional(string, "c3.small.x86")<br/> plan_node = optional(string, "c3.small.x86")<br/> node_count = optional(number, 0)<br/> ha = optional(bool, false)<br/> os = optional(string, "debian_11")<br/> control_plane_hostnames = optional(string, "cp")<br/> node_hostnames = optional(string, "node")<br/> custom_token = optional(string, "")<br/> ip_pool_count = optional(number, 0)<br/> kube_version = optional(string, "")<br/> metallb_version = optional(string, "")<br/> rancher_version = optional(string, "")<br/> rancher_flavor = optional(string, "")<br/> custom_rancher_password = optional(string, "")<br/> }))</pre> | <pre>[<br/> {}<br/>]</pre> | no |
| <a name="input_deploy_demo"></a> [deploy\_demo](#input\_deploy\_demo) | Deploys a simple demo using a global IP as ingress and a hello-kubernetes pods | `bool` | `false` | 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 | `bool` | `false` | no |
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Your Equinix Metal API key | `string` | n/a | yes |
| <a name="input_metal_project_id"></a> [metal\_project\_id](#input\_metal\_project\_id) | Your Equinix Metal Project ID | `string` | n/a | yes |

### Outputs

| Name | Description |
|------|-------------|
| <a name="output_demo_cluster"></a> [demo\_cluster](#output\_demo\_cluster) | Passthrough of the root module output |
| <a name="output_clusters_output"></a> [clusters\_output](#output\_clusters\_output) | Passthrough of the root module output |
<!-- END_TF_DOCS -->
2 changes: 1 addition & 1 deletion examples/demo_cluster/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "demo_cluster" {
output "clusters_output" {
description = "Passthrough of the root module output"
value = module.demo
}
23 changes: 19 additions & 4 deletions examples/demo_cluster/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
metal_auth_token="your_token_here" #This must be a user API token
metal_project_id="your_project_id"
clusters = [
clusters = [
{
name = "Your cluster name"
name = "FR DEV Cluster"
rancher_flavor = "stable"
ip_pool_count = 1
kube_version = "v1.29.9+k3s1"
},
{
name = "Your cluster name"
metro = "SV"
name = "SV DEV Cluster"
metro = "SV"
node_count = 1
kube_version = "v1.30.3+rke2r1"
},
{
name = "SV Production"
ip_pool_count = 4
ha = true
metro = "SV"
node_count = 3
}
]

global_ip = true
deploy_demo = true
17 changes: 10 additions & 7 deletions examples/demo_cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ variable "deploy_demo" {
}

variable "clusters" {
description = "K3s cluster definition"
description = "Cluster definition"
type = list(object({
name = optional(string, "K3s demo cluster")
name = optional(string, "Demo cluster")
metro = optional(string, "FR")
plan_control_plane = optional(string, "c3.small.x86")
plan_node = optional(string, "c3.small.x86")
node_count = optional(number, 0)
k3s_ha = optional(bool, false)
ha = optional(bool, false)
os = optional(string, "debian_11")
control_plane_hostnames = optional(string, "k3s-cp")
node_hostnames = optional(string, "k3s-node")
custom_k3s_token = optional(string, "")
control_plane_hostnames = optional(string, "cp")
node_hostnames = optional(string, "node")
custom_token = optional(string, "")
ip_pool_count = optional(number, 0)
k3s_version = optional(string, "")
kube_version = optional(string, "")
metallb_version = optional(string, "")
rancher_version = optional(string, "")
rancher_flavor = optional(string, "")
custom_rancher_password = optional(string, "")
}))
default = [{}]
}
15 changes: 9 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ locals {
}

################################################################################
# K3S Cluster In-line Module
# K8s Cluster In-line Module
################################################################################

module "k3s_cluster" {
source = "./modules/k3s_cluster"
module "kube_cluster" {
source = "./modules/kube_cluster"

for_each = { for cluster in var.clusters : cluster.name => cluster }

Expand All @@ -18,14 +18,17 @@ module "k3s_cluster" {
plan_control_plane = each.value.plan_control_plane
plan_node = each.value.plan_node
node_count = each.value.node_count
k3s_ha = each.value.k3s_ha
ha = each.value.ha
os = each.value.os
control_plane_hostnames = each.value.control_plane_hostnames
node_hostnames = each.value.node_hostnames
custom_k3s_token = each.value.custom_k3s_token
k3s_version = each.value.k3s_version
custom_token = each.value.custom_token
kube_version = each.value.kube_version
metallb_version = each.value.metallb_version
ip_pool_count = each.value.ip_pool_count
rancher_flavor = each.value.rancher_flavor
rancher_version = each.value.rancher_version
custom_rancher_password = each.value.custom_rancher_password
metal_project_id = var.metal_project_id
deploy_demo = var.deploy_demo
global_ip_cidr = local.global_ip_cidr
Expand Down
4 changes: 0 additions & 4 deletions modules/k3s_cluster/outputs.tf

This file was deleted.

Loading

0 comments on commit 0b0ac79

Please sign in to comment.