Skip to content

Commit

Permalink
Merge pull request #83 from equinix/metros
Browse files Browse the repository at this point in the history
add support for metros
  • Loading branch information
displague authored Sep 30, 2021
2 parents c0fd522 + b70a853 commit ee073d0
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ jobs:
TF_VERSION: ${{ matrix.tf }}
TF_VAR_control_plane_node_count: 0
TF_VAR_count_x86: 1
TF_VAR_count_arm: 1
TF_VAR_count_arm: 0
KUBERNETES_VERSION: 1.21.0
TF_VAR_kubernetes_version: 1.21.0-00
# TODO only provide this to terraform steps that need it
TF_VAR_auth_token: ${{ secrets.METAL_AUTH_TOKEN }}
strategy:
matrix:
os: [ubuntu-latest]
tf: [0.13.2]
tf: [0.14.10]
steps:
- name: Checkout from Github
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
tf: [0.13.2]
tf: [0.14.10]
steps:
- name: Checkout from Github
uses: actions/checkout@v2
Expand Down
48 changes: 34 additions & 14 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This project configures your cluster with:

The only required variables are `auth_token` (your [Equinix Metal API](https://metal.equinix.com/developers/api/) key), `count_x86` (the number of x86 devices), and `count_arm` (ARM devices).

Other options include `secrets_encryption` (`"yes"` configures your controller with encryption for secrets--this is disabled by default), and fields like `facility` (the Equinix Metal location to deploy to) and `plan_x86` or `plan_arm` (to determine the server type of these architectures) can be specified as well. Refer to `vars.tf` for a complete catalog of tunable options.
Other options include `secrets_encryption` (`"yes"` configures your controller with encryption for secrets--this is disabled by default), and fields like `facility` and `metro` (the Equinix Metal location to deploy to) and `plan_x86` or `plan_arm` (to determine the server type of these architectures) can be specified as well. Refer to `vars.tf` for a complete catalog of tunable options.

## Getting Started

Expand Down
1 change: 1 addition & 0 deletions examples/controller_pool.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module "controller_pool_primary" {
count_gpu = var.count_gpu
plan_primary = var.plan_primary
facility = var.facility
metro = var.metro
cluster_name = var.cluster_name
kubernetes_lb_block = metal_reserved_ip_block.kubernetes.cidr_notation
project_id = var.project_id
Expand Down
1 change: 1 addition & 0 deletions examples/gpu-node_pool.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module "node_pool_gpu_green" {
count_gpu = var.count_gpu
plan_gpu = var.plan_gpu
facility = var.facility
metro = var.metro
cluster_name = var.cluster_name
controller_address = metal_device.k8s_primary.network.0.address
project_id = var.project_id
Expand Down
1 change: 1 addition & 0 deletions examples/new_node_pool.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module "node_pool_green" {
plan_x86 = var.plan_x86
plan_arm = var.plan_arm
facility = var.facility
metro = var.metro
cluster_name = var.cluster_name
controller_address = metal_device.k8s_primary.network.0.address
project_id = metal_project.kubernetes_multiarch.id
Expand Down
6 changes: 4 additions & 2 deletions kubernetes-controller-pool.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ resource "metal_ssh_key" "kubernetes-on-metal" {

resource "metal_reserved_ip_block" "kubernetes" {
project_id = var.metal_create_project ? metal_project.new_project[0].id : var.project_id
facility = var.facility
facility = var.facility != "" ? var.facility : null
metro = var.metro != "" ? var.metro : null
quantity = 4
}

Expand All @@ -43,6 +44,7 @@ module "controllers" {
count_gpu = var.count_gpu
plan_primary = var.plan_primary
facility = var.facility
metro = var.metro
cluster_name = var.cluster_name
kubernetes_lb_block = metal_reserved_ip_block.kubernetes.cidr_notation
project_id = var.metal_create_project ? metal_project.new_project[0].id : var.project_id
Expand All @@ -53,7 +55,7 @@ module "controllers" {
workloads = var.workloads
skip_workloads = var.skip_workloads
control_plane_node_count = var.control_plane_node_count
ssh_private_key_path = local_file.cluster_private_key_pem.filename
ssh_private_key_path = abspath(local_file.cluster_private_key_pem.filename)
ccm_enabled = var.ccm_enabled
loadbalancer_type = var.loadbalancer_type
}
2 changes: 2 additions & 0 deletions kubernetes-node-pool.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module "node_pool_blue" {
plan_x86 = var.plan_x86
plan_arm = var.plan_arm
facility = var.facility
metro = var.metro
cluster_name = var.cluster_name
controller_address = module.controllers.controller_addresses
project_id = var.metal_create_project ? metal_project.new_project[0].id : var.project_id
Expand All @@ -26,6 +27,7 @@ module "node_pool_gpu_green" {
count_gpu = var.count_gpu
plan_gpu = var.plan_gpu
facility = var.facility
metro = var.metro
cluster_name = var.cluster_name
controller_address = module.controllers.controller_addresses
project_id = var.metal_create_project ? metal_project.new_project[0].id : var.project_id
Expand Down
6 changes: 4 additions & 2 deletions modules/controller_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ resource "metal_device" "k8s_primary" {
hostname = "${var.cluster_name}-controller-primary"
operating_system = "ubuntu_18_04"
plan = var.plan_primary
facilities = [var.facility]
facilities = var.facility != "" ? [var.facility] : null
metro = var.metro != "" ? var.metro : null
user_data = data.template_file.controller-primary.rendered
tags = ["kubernetes", "controller-${var.cluster_name}"]

Expand All @@ -56,7 +57,8 @@ resource "metal_device" "k8s_controller_standby" {
hostname = format("${var.cluster_name}-controller-standby-%02d", count.index)
operating_system = "ubuntu_18_04"
plan = var.plan_primary
facilities = [var.facility]
facilities = var.facility != "" ? [var.facility] : null
metro = var.metro != "" ? var.metro : null
user_data = data.template_file.controller-standby.rendered
tags = ["kubernetes", "controller-${var.cluster_name}"]
billing_cycle = "hourly"
Expand Down
8 changes: 7 additions & 1 deletion modules/controller_pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ variable "kubernetes_version" {

variable "facility" {
type = string
description = "Equinix Metal Facility"
description = "Equinix Metal Facility (conflicts with metro)"
}

variable "metro" {
type = string
description = "Equinix Metal Metro (conflicts with facility)"
}

variable "cluster_name" {
Expand All @@ -26,6 +31,7 @@ variable "project_id" {
variable "auth_token" {
type = string
description = "Your Equinix Metal API token"
sensitive = true
}

variable "secrets_encryption" {
Expand Down
4 changes: 2 additions & 2 deletions modules/controller_pool/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ terraform {
required_providers {
metal = {
source = "equinix/metal"
version = "1.0.0"
version = ">= 2.1, <4"
}
template = {
source = "hashicorp/template"
}
}
required_version = ">= 0.13"
required_version = ">= 0.14"
}
3 changes: 2 additions & 1 deletion modules/gpu_node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ resource "metal_device" "gpu_node" {
operating_system = "ubuntu_18_04"
count = var.count_gpu
plan = var.plan_gpu
facilities = [var.facility]
facilities = var.facility != "" ? [var.facility] : null
metro = var.metro != "" ? var.metro : null
user_data = data.template_file.gpu_node.rendered
tags = ["kubernetes", "pool-${var.cluster_name}-${var.pool_label}-gpu"]

Expand Down
7 changes: 6 additions & 1 deletion modules/gpu_node_pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ variable "plan_gpu" {

variable "facility" {
type = string
description = "Equinix Metal Facility"
description = "Equinix Metal Facility (conflicts with metro)"
}

variable "metro" {
type = string
description = "Equinix Metal Metro (conflicts with facility)"
}

variable "cluster_name" {
Expand Down
4 changes: 2 additions & 2 deletions modules/gpu_node_pool/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ terraform {
required_providers {
metal = {
source = "equinix/metal"
version = "1.0.0"
version = ">= 2.1, <4"
}
template = {
source = "hashicorp/template"
}
}
required_version = ">= 0.13"
required_version = ">= 0.14"
}
8 changes: 8 additions & 0 deletions modules/kube-token/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
template = {
source = "hashicorp/random"
}
}
required_version = ">= 0.14"
}
6 changes: 4 additions & 2 deletions modules/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ resource "metal_device" "x86_node" {
operating_system = "ubuntu_18_04"
count = var.count_x86
plan = var.plan_x86
facilities = [var.facility]
facilities = var.facility != "" ? [var.facility] : null
metro = var.metro != "" ? var.metro : null
user_data = data.template_file.node.rendered
tags = ["kubernetes", "pool-${var.cluster_name}-${var.pool_label}-x86"]

Expand All @@ -28,7 +29,8 @@ resource "metal_device" "arm_node" {
operating_system = "ubuntu_18_04"
count = var.count_arm
plan = var.plan_arm
facilities = [var.facility]
facilities = var.facility != "" ? [var.facility] : null
metro = var.metro
user_data = data.template_file.node.rendered
tags = ["kubernetes", "pool-${var.cluster_name}-${var.pool_label}-arm"]

Expand Down
7 changes: 6 additions & 1 deletion modules/node_pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ variable "plan_arm" {

variable "facility" {
type = string
description = "Equinix Metal Facility"
description = "Equinix Metal Facility (conflicts with metro)"
}

variable "metro" {
type = string
description = "Equinix Metal Metro (conflicts with facility)"
}

variable "cluster_name" {
Expand Down
4 changes: 2 additions & 2 deletions modules/node_pool/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ terraform {
required_providers {
metal = {
source = "equinix/metal"
version = "1.0.0"
version = ">= 2.1, <4"
}
template = {
source = "hashicorp/template"
}
}
required_version = ">= 0.13"
required_version = ">= 0.14"
}
15 changes: 5 additions & 10 deletions terraform.tfvars.sample
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
auth_token = ""

project_id = ""

count_arm = 2

count_x86 = 1

auth_token = ""
project_id = ""
count_arm = 2
count_x86 = 1
secrets_encryption = false

facility = "ewr1"
metro = "dc"
11 changes: 9 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
variable "auth_token" {
type = string
description = "Your Equinix Metal API key"
sensitive = true
}

variable "facility" {
type = string
description = "Equinix Metal Facility"
default = "dc13"
description = "Equinix Metal Facility (conflicts with metro)"
default = ""
}

variable "metro" {
type = string
description = "Equinix Metal Metro (conflicts with facility)"
default = "dc"
}

variable "project_id" {
Expand Down
4 changes: 2 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ terraform {
required_providers {
metal = {
source = "equinix/metal"
version = "1.0.0"
version = ">= 2.1, <4"
}
}
required_version = ">= 0.13"
required_version = ">= 0.14"
}

0 comments on commit ee073d0

Please sign in to comment.