Skip to content

Commit 08f189a

Browse files
authored
refactor: do not use templates/cluster-autoscaler-values.yaml and set necessary values in the eks-cluster-autoscaler.tf file (#200)
1 parent b89f9a4 commit 08f189a

File tree

3 files changed

+43
-59
lines changed

3 files changed

+43
-59
lines changed

terraform/layer2-k8s/eks-cluster-autoscaler.tf

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,51 @@ locals {
44
enabled = local.helm_releases[index(local.helm_releases.*.id, "cluster-autoscaler")].enabled
55
chart = local.helm_releases[index(local.helm_releases.*.id, "cluster-autoscaler")].chart
66
repository = local.helm_releases[index(local.helm_releases.*.id, "cluster-autoscaler")].repository
7-
chart_version = local.helm_releases[index(local.helm_releases.*.id, "cluster-autoscaler")].version
7+
chart_version = local.helm_releases[index(local.helm_releases.*.id, "cluster-autoscaler")].chart_version
88
namespace = local.helm_releases[index(local.helm_releases.*.id, "cluster-autoscaler")].namespace
99
}
10-
}
10+
cluster_autoscaler_values = <<VALUES
11+
image:
12+
tag: ${var.cluster_autoscaler_version}
13+
awsRegion: ${local.region}
14+
rbac:
15+
create: true
16+
serviceAccount:
17+
annotations:
18+
eks.amazonaws.com/role-arn: ${local.cluster_autoscaler.enabled ? module.aws_iam_autoscaler[0].role_arn : ""}
19+
autoDiscovery:
20+
clusterName: ${local.eks_cluster_id}
21+
extraArgs:
22+
expander: priority
23+
expanderPriorities: |
24+
10:
25+
- eks-${local.eks_cluster_id}-ondemand.*
26+
50:
27+
- eks-${local.eks_cluster_id}-spot.*
1128
12-
data "template_file" "cluster_autoscaler" {
13-
count = local.cluster_autoscaler.enabled ? 1 : 0
29+
serviceMonitor:
30+
enabled: true
31+
interval: 10s
32+
namespace: monitoring
33+
path: /metrics
1434
15-
template = file("${path.module}/templates/cluster-autoscaler-values.yaml")
16-
vars = {
17-
role_arn = module.aws_iam_autoscaler[count.index].role_arn
18-
region = local.region
19-
cluster_name = local.eks_cluster_id
20-
version = var.cluster_autoscaler_version
21-
}
35+
affinity:
36+
nodeAffinity:
37+
requiredDuringSchedulingIgnoredDuringExecution:
38+
nodeSelectorTerms:
39+
- matchExpressions:
40+
- key: eks.amazonaws.com/capacityType
41+
operator: In
42+
values:
43+
- ON_DEMAND
44+
resources:
45+
limits:
46+
cpu: 100m
47+
memory: 512Mi
48+
requests:
49+
cpu: 100m
50+
memory: 320Mi
51+
VALUES
2252
}
2353

2454
#tfsec:ignore:kubernetes-network-no-public-egress tfsec:ignore:kubernetes-network-no-public-ingress
@@ -151,7 +181,7 @@ resource "helm_release" "cluster_autoscaler" {
151181
max_history = var.helm_release_history_size
152182

153183
values = [
154-
data.template_file.cluster_autoscaler[count.index].rendered,
184+
local.cluster_autoscaler_values
155185
]
156186

157187
depends_on = [helm_release.prometheus_operator]

terraform/layer2-k8s/helm-releases.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ releases:
3939
enabled: true
4040
chart: cluster-autoscaler
4141
repository: https://kubernetes.github.io/autoscaler
42-
version: 9.10.5
42+
chart_version: 9.10.5
4343
namespace: cluster-autoscaler
4444
- id: elk
4545
enabled: false

terraform/layer2-k8s/templates/cluster-autoscaler-values.yaml

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)