File tree Expand file tree Collapse file tree 4 files changed +101
-3
lines changed
tools/aws-cluster-autoscaler Expand file tree Collapse file tree 4 files changed +101
-3
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ output "secretAccessKey" {
24
24
value = try (" ${ aws_iam_access_key . edns [0 ]. secret } " , " " )
25
25
}
26
26
27
+ output "oidc_provider_arn" {
28
+ sensitive = false
29
+ value = module. eks . oidc_provider_arn
30
+ }
31
+
32
+ output "cluster_id" {
33
+ sensitive = false
34
+ value = module. eks . cluster_id
35
+ }
36
+
27
37
output "cert_manager_issuer" {
28
38
value = try ({
29
39
region = var.region
Original file line number Diff line number Diff line change
1
+ variable "kubeconfig" {
2
+ description = " Path to the KUBECONFIG file to connect to the cluster"
3
+ default = " ./kubeconfig"
4
+ }
5
+
6
+ variable "region" {}
7
+ variable "cluster_name" {}
8
+ variable "cluster_id" {}
9
+ variable "oidc_provider_arn" {}
10
+
11
+ provider "helm" {
12
+ kubernetes {
13
+ config_path = var. kubeconfig
14
+ }
15
+ }
16
+
17
+ module "cluster_autoscaler_irsa_role" {
18
+ source = " terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
19
+ version = " ~> 4.12"
20
+
21
+ role_name_prefix = " cluster-autoscaler"
22
+ attach_cluster_autoscaler_policy = true
23
+ cluster_autoscaler_cluster_ids = [var . cluster_id ]
24
+
25
+ oidc_providers = {
26
+ ex = {
27
+ provider_arn = var.oidc_provider_arn
28
+ namespace_service_accounts = [" kube-system:cluster-autoscaler" ]
29
+ }
30
+ }
31
+ }
32
+
33
+ # AWS cluster auto-scaler Deployment using Helm
34
+ resource "helm_release" "cluster_autoscaler" {
35
+ name = " cluster-autoscaler"
36
+ repository = " https://kubernetes.github.io/autoscaler"
37
+ chart = " cluster-autoscaler"
38
+ version = " 9.20.1"
39
+ namespace = " kube-system"
40
+
41
+ values = [
42
+ jsonencode ({
43
+ cloudProvider = " aws"
44
+ awsRegion = var.region
45
+ autoDiscovery = {
46
+ clusterName = var.cluster_name
47
+ }
48
+
49
+ serviceAccount = {
50
+ name = " cluster-autoscaler"
51
+ annotations = {
52
+ " eks\\.amazonaws\\.com/role-arn" = module.cluster_autoscaler_irsa_role.iam_role_arn
53
+ }
54
+ create = true
55
+ }
56
+ securityContext = {
57
+ fsGroup = 65534
58
+ }
59
+ extraArgs = {
60
+ skip-nodes-with-local-storage = false
61
+ balance-similar-node-groups = true
62
+ }
63
+
64
+ })
65
+ ]
66
+
67
+ }
Original file line number Diff line number Diff line change @@ -26,7 +26,11 @@ plan-cluster:
26
26
@terraform plan -target=module.eks
27
27
28
28
.PHONY : plan-tools
29
- plan-tools : plan-cm-edns plan-cluster-issuer
29
+ plan-tools : plan-cm-edns plan-cluster-issuer plan-cluster-autoscaler
30
+
31
+ .PHONY : plan-cluster-autoscaler
32
+ plan-cluster-autoscaler :
33
+ @terraform plan -target=module.cluster-autoscaler
30
34
31
35
.PHONY : plan-cm-edns
32
36
plan-cm-edns :
@@ -41,7 +45,11 @@ apply-cluster:
41
45
@terraform apply -target=module.eks --auto-approve
42
46
43
47
.PHONY : apply-tools
44
- apply-tools : install-cm-edns install-cluster-issuer
48
+ apply-tools : install-cm-edns install-cluster-issuer install-cluster-autoscaler
49
+
50
+ .PHONY : install-cluster-autoscaler
51
+ install-cluster-autoscaler :
52
+ @terraform apply -target=module.cluster-autoscaler --auto-approve
45
53
46
54
.PHONY : install-cm-edns
47
55
install-cm-edns :
@@ -56,7 +64,11 @@ destroy-cluster:
56
64
@terraform destroy -target=module.eks --auto-approve
57
65
58
66
.PHONY : destroy-tools
59
- destroy-tools : destroy-cluster-issuer destroy-cm-edns
67
+ destroy-tools : destroy-cluster-issuer destroy-cm-edns destroy-cluster-autoscaler
68
+
69
+ .PHONY : destroy-cluster-autoscaler
70
+ destroy-cluster-autoscaler :
71
+ @terraform destroy -target=module.cluster-autoscaler --auto-approve
60
72
61
73
.PHONY : destroy-cm-edns
62
74
destroy-cm-edns :
Original file line number Diff line number Diff line change @@ -20,3 +20,12 @@ module "cluster-issuer" {
20
20
secretAccessKey = module. eks . secretAccessKey
21
21
issuer_name = " route53"
22
22
}
23
+
24
+ module "cluster-autoscaler" {
25
+ source = " ../../modules/tools/aws-cluster-autoscaler"
26
+ kubeconfig = var. kubeconfig
27
+ region = var. region
28
+ cluster_name = var. cluster_name
29
+ cluster_id = module. eks . cluster_id
30
+ oidc_provider_arn = module. eks . oidc_provider_arn
31
+ }
You can’t perform that action at this time.
0 commit comments