Skip to content

Commit

Permalink
Merge pull request #56 from rossf7/feat/worker-config
Browse files Browse the repository at this point in the history
feat: Make node labels and plan configurable
  • Loading branch information
rossf7 committed Feb 14, 2024
2 parents 51ffcb2 + b94e9c0 commit 5f3cf07
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
11 changes: 7 additions & 4 deletions infrastructure/equinix-metal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ resource "equinix_metal_device" "control_plane" {
}

resource "equinix_metal_device" "worker" {
for_each = toset(var.worker_nodes)
hostname = "${var.cluster_name}-${each.value}"
plan = var.device_plan
for_each = var.worker_nodes
hostname = "${var.cluster_name}-worker-${each.key}"
plan = each.plan
metro = var.device_metro
operating_system = var.device_os
billing_cycle = var.billing_cycle
Expand All @@ -71,7 +71,10 @@ resource "equinix_metal_device" "worker" {
depends_on = [equinix_metal_device.control_plane]
user_data = <<EOF
#!/bin/bash
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL="${var.k3s_version}" sh -s - agent --token "${var.k3s_token}" --server "https://${equinix_metal_device.control_plane.access_private_ipv4}:6443"
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL="${var.k3s_version}" sh -s - agent \
--token "${var.k3s_token}" \
--server "https://${equinix_metal_device.control_plane.access_private_ipv4}:6443" \
${join(" \\\n", [for k, v in each.value.labels : "--node-label ${k}=${v}"])}
EOF

behavior {
Expand Down
22 changes: 20 additions & 2 deletions infrastructure/equinix-metal/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ variable "ssh_private_key_path" {

variable "worker_nodes" {
description = "List of worker node names"
type = list(string)
default = ["worker1"]
type = map(object({
labels = map(string)
plan = string
}))
default = {
internal-1 = {
labels = {
cncf-project = "wg-green-reviews"
cncf-project-sub = "internal"
},
plan = "m3.small.x86"
},
falco-a = {
labels = {
cncf-project = "falco"
cncf-project-sub = "falco-driver-modern-ebpf"
},
plan = "m3.small.x86"
}
}
}

0 comments on commit 5f3cf07

Please sign in to comment.