dynk8s-provisioner/terraform/asg.tf

106 lines
2.2 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"]
}
}
data "aws_ami" "latest-fedora" {
most_recent = true
owners = ["125523088429"]
filter {
name = "name"
values = ["Fedora-Cloud-Base-38-1.*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
filter {
name = "architecture"
values = ["arm64"]
}
}
resource "aws_launch_template" "k8s-aarch64" {
name = "k8s-aarch64"
update_default_version = true
image_id = "${data.aws_ami.latest-fedora.id}"
instance_type = "t4g.medium"
security_group_names = [aws_security_group.k8s-node.name]
key_name = "dustin@rosalina"
user_data = filebase64("${path.module}/userdata.yml")
instance_market_options {
market_type = "spot"
}
private_dns_name_options {
hostname_type = "resource-name"
}
block_device_mappings {
device_name = "/dev/sda1"
ebs {
volume_size = 64
}
}
}
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 = "$Default"
}
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
}
tag {
key = "k8s.io/cluster-autoscaler/node-template/resources/github.com/fuse"
value = "1"
propagate_at_launch = false
}
}