-
Notifications
You must be signed in to change notification settings - Fork 0
/
asg-workers.tf
71 lines (62 loc) · 1.95 KB
/
asg-workers.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
resource "aws_autoscaling_group" "k8s_worker_asg" {
name = "${var.name}-worker-asg"
launch_template {
id = aws_launch_template.k8s_worker_lc.id
version = "$Latest"
}
target_group_arns = [
aws_lb_target_group.k8s_ingress_http.arn,
aws_lb_target_group.k8s_ingress_https.arn
]
min_size = var.computing.workers.min_size
max_size = var.computing.workers.max_size
desired_capacity = var.computing.workers.desired_capacity
vpc_zone_identifier = aws_subnet.public[*].id
tag {
key = "Name"
value = "${var.name}-worker-node"
propagate_at_launch = true
}
tag {
key = "k8s.io/cluster-autoscaler/enabled"
value = "true"
propagate_at_launch = true
}
tag {
key = "k8s.io/cluster-autoscaler/${var.name}"
value = "owned"
propagate_at_launch = true
}
tag {
key = "kubernetes.io/cluster/${var.name}"
value = "owned"
propagate_at_launch = true
}
tag {
key = "k8s.io/cluster-autoscaler/${var.name}/Role"
value = "worker"
propagate_at_launch = true
}
}
resource "aws_launch_template" "k8s_worker_lc" {
name = "${var.name}-worker-lc"
image_id = data.aws_ami.debian.id
instance_type = var.nodes.instance_type
key_name = var.nodes.key_name
network_interfaces {
associate_public_ip_address = true
security_groups = [aws_security_group.k8s_worker_sg.id]
}
lifecycle {
create_before_destroy = true
}
user_data = base64encode(templatefile("${path.module}/k8s_worker_user_data.sh", {
kubernetes_version = "1.31.0"
kubernetes_install_version = "1.31.0-1.1"
containerd_version = "1.7"
s3_bucket_name = aws_s3_bucket.k8s_config.id
}))
iam_instance_profile {
name = aws_iam_instance_profile.k8s_node_profile.name
}
}