Skip to content

Commit c11e4b8

Browse files
committed
Prioritise deploying to the primary pool by default
1 parent c03d9d3 commit c11e4b8

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

main.tf

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ resource "scaleway_k8s_cluster" "main" {
2222
maintenance_window_start_hour = 10
2323
maintenance_window_day = "tuesday"
2424
}
25+
26+
autoscaler_config {
27+
expander = "priority"
28+
scale_down_unneeded_time = "10m"
29+
}
2530
}
2631

27-
resource "scaleway_k8s_pool" "main" {
32+
resource "scaleway_k8s_pool" "primary" {
2833
cluster_id = scaleway_k8s_cluster.main.id
2934
name = "htk-production-pool"
3035
node_type = "PLAY2-NANO"
@@ -50,6 +55,25 @@ resource "scaleway_k8s_pool" "failover" {
5055
tags = ["htk", "production", "failover"]
5156
}
5257

58+
# Prefer to deploy nodes in the primary pool, whenever possible:
59+
resource "kubernetes_config_map_v1" "autoscaler_priority" {
60+
metadata {
61+
name = "cluster-autoscaler-priority-expander"
62+
namespace = "kube-system"
63+
}
64+
65+
data = {
66+
"priorities" = <<-EOT
67+
50:
68+
- .*primary.*
69+
10:
70+
- .*failover.*
71+
EOT
72+
}
73+
74+
depends_on = [scaleway_k8s_pool.primary]
75+
}
76+
5377
module "public_endpoint" {
5478
source = "./modules/k8s-project"
5579
name = "public-endpoint"

0 commit comments

Comments
 (0)