dynk8s-provisioner/terraform/asg.tf

72 lines
1.6 KiB
HCL

resource "aws_security_group" "k8s-node" {
name = "k8s-node"
description = "Kubernetes Node"
egress {
from_port = 19998
to_port = 19998
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
egress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
egress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
}
resource "aws_launch_template" "k8s-aarch64" {
name = "k8s-aarch64"
update_default_version = true
image_id = "ami-000ec96ccb51eb679"
instance_type = "t4g.medium"
security_group_names = [aws_security_group.k8s-node.name]
user_data = filebase64("${path.module}/userdata.yml")
instance_market_options {
market_type = "spot"
}
private_dns_name_options {
hostname_type = "resource-name"
}
}
resource "aws_autoscaling_group" "k8s-aarch64" {
name = "k8s-aarch64"
availability_zones = ["us-east-2a", "us-east-2b", "us-east-2c"]
min_size = 0
max_size = 1
launch_template {
id = aws_launch_template.k8s-aarch64.id
version = "$Latest"
}
tag {
key = "k8s.io/cluster-autoscaler/enabled"
value = "true"
propagate_at_launch = true
}
tag {
key = "k8s.io/cluster-autoscaler/kubernetes"
value = "owned"
propagate_at_launch = true
}
}