Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbreak AWS cluster naming #30

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions darts/aws_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ tofu_variables:
# bastion_host_ami: ami-0e55a8b472a265e3f # openSUSE-Leap-15-5-v20230608-hvm-ssd-arm64

# upstream_cluster:
# name_prefix: upstream
# server_count: 1
# agent_count: 0
# distro_version: v1.26.9+k3s1
Expand All @@ -31,7 +30,6 @@ tofu_variables:

# deploy_tester_cluster: true
# tester_cluster:
# name_prefix: tester
# server_count: 1
# agent_count: 0
# distro_version: v1.26.9+k3s1
Expand All @@ -44,7 +42,6 @@ tofu_variables:

# downstream_cluster_templates:
# - cluster_count: 0
# name_prefix: downstream
# server_count: 1
# agent_count: 0
# distro_version: v1.26.9+k3s1
Expand Down
17 changes: 10 additions & 7 deletions tofu/main/aws/locals.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
locals {
downstream_clusters = flatten([
unnamed_downstream_clusters = flatten([
for i, template in var.downstream_cluster_templates : [
for j in range(template.cluster_count) : merge(template, { name = "${template.name_prefix}${i}-${j}" })
for j in range(template.cluster_count) : template
] if template.cluster_count > 0 ])
all_clusters = flatten(concat([var.upstream_cluster],

downstream_clusters = [for i, cluster in local.unnamed_downstream_clusters : merge(cluster, {name = "downstream-${i}"})]

all_clusters = flatten(concat(
[merge(var.upstream_cluster, {name = "upstream"})],
local.downstream_clusters,
var.deploy_tester_cluster ? [var.tester_cluster] : []
var.deploy_tester_cluster ? [[merge(var.tester_cluster, {name = "tester"})]] : []
))


k3s_clusters = [for i, cluster in local.all_clusters : merge(cluster, {name = "${cluster.name_prefix}-${i}"}) if strcontains(cluster.distro_version, "k3s")]
rke2_clusters = [for i, cluster in local.all_clusters : merge(cluster, {name = "${cluster.name_prefix}-${i}"}) if strcontains(cluster.distro_version, "rke2")]
k3s_clusters = [for i, cluster in local.all_clusters : cluster if strcontains(cluster.distro_version, "k3s")]
rke2_clusters = [for i, cluster in local.all_clusters : cluster if strcontains(cluster.distro_version, "rke2")]
}
6 changes: 0 additions & 6 deletions tofu/main/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ variable "ssh_bastion_user" {
# Upstream cluster specifics
variable "upstream_cluster" {
type = object({
name_prefix = string // Prefix to append to objects created for this cluster
server_count = number // Number of server nodes in the upstream cluster
agent_count = number // Number of agent nodes in the upstream cluster
distro_version = string // Version of the Kubernetes distro in the upstream cluster
Expand All @@ -59,7 +58,6 @@ variable "upstream_cluster" {
ami = string // AMI for upstream cluster nodes
})
default = {
name_prefix = "upstream"
server_count = 1
agent_count = 0
distro_version = "v1.26.9+k3s1"
Expand All @@ -80,7 +78,6 @@ variable "upstream_cluster" {
variable "downstream_cluster_templates" {
type = list(object({
cluster_count = number // Number of downstream clusters that should be created using this configuration
name_prefix = string // Prefix to append to objects created for this cluster
server_count = number // Number of server nodes in the downstream cluster
agent_count = number // Number of agent nodes in the downstream cluster
distro_version = string // Version of the Kubernetes distro in the downstream cluster
Expand All @@ -96,7 +93,6 @@ variable "downstream_cluster_templates" {
}))
default = [{
cluster_count = 0 // defaults to 0 to keep in-line with previous behavior
name_prefix = "downstream"
server_count = 1
agent_count = 0
distro_version = "v1.26.9+k3s1"
Expand All @@ -116,7 +112,6 @@ variable "downstream_cluster_templates" {
# Tester cluster specifics
variable "tester_cluster" {
type = object({
name_prefix = string // Prefix to append to objects created for this cluster
server_count = number // Number of server nodes in the tester cluster
agent_count = number // Number of agent nodes in the tester cluster
distro_version = string // Version of the Kubernetes distro in the tester cluster
Expand All @@ -131,7 +126,6 @@ variable "tester_cluster" {
ami = string // AMI for tester cluster nodes
})
default = {
name_prefix = "tester"
server_count = 1
agent_count = 0
distro_version = "v1.26.9+k3s1"
Expand Down
Loading