mirror of
https://github.com/puppetmaster/typhoon.git
synced 2024-12-26 17:49:32 +01:00
5eb11f5104
* Replace os_channel variable with os_image to align naming across clouds. Users who set this option to stable, beta, or alpha should now set os_image to coreos-stable, coreos-beta, or coreos-alpha. * Default os_image to coreos-stable. This continues to use the most recent image from the stable channel as always. * Allow Container Linux derivative Flatcar Linux by setting os_image to `flatcar-stable`, `flatcar-beta`, `flatcar-alpha`
83 lines
2.3 KiB
HCL
83 lines
2.3 KiB
HCL
# Workers AutoScaling Group
|
|
resource "aws_autoscaling_group" "workers" {
|
|
name = "${var.name}-worker ${aws_launch_configuration.worker.name}"
|
|
|
|
# count
|
|
desired_capacity = "${var.count}"
|
|
min_size = "${var.count}"
|
|
max_size = "${var.count + 2}"
|
|
default_cooldown = 30
|
|
health_check_grace_period = 30
|
|
|
|
# network
|
|
vpc_zone_identifier = ["${var.subnet_ids}"]
|
|
|
|
# template
|
|
launch_configuration = "${aws_launch_configuration.worker.name}"
|
|
|
|
# target groups to which instances should be added
|
|
target_group_arns = [
|
|
"${aws_lb_target_group.workers-http.id}",
|
|
"${aws_lb_target_group.workers-https.id}",
|
|
]
|
|
|
|
lifecycle {
|
|
# override the default destroy and replace update behavior
|
|
create_before_destroy = true
|
|
}
|
|
|
|
# Waiting for instance creation delays adding the ASG to state. If instances
|
|
# can't be created (e.g. spot price too low), the ASG will be orphaned.
|
|
# Orphaned ASGs escape cleanup, can't be updated, and keep bidding if spot is
|
|
# used. Disable wait to avoid issues and align with other clouds.
|
|
wait_for_capacity_timeout = "0"
|
|
|
|
tags = [{
|
|
key = "Name"
|
|
value = "${var.name}-worker"
|
|
propagate_at_launch = true
|
|
}]
|
|
}
|
|
|
|
# Worker template
|
|
resource "aws_launch_configuration" "worker" {
|
|
image_id = "${local.ami_id}"
|
|
instance_type = "${var.instance_type}"
|
|
spot_price = "${var.spot_price}"
|
|
|
|
user_data = "${data.ct_config.worker_ign.rendered}"
|
|
|
|
# storage
|
|
root_block_device {
|
|
volume_type = "${var.disk_type}"
|
|
volume_size = "${var.disk_size}"
|
|
}
|
|
|
|
# network
|
|
security_groups = ["${var.security_groups}"]
|
|
|
|
lifecycle {
|
|
// Override the default destroy and replace update behavior
|
|
create_before_destroy = true
|
|
ignore_changes = ["image_id"]
|
|
}
|
|
}
|
|
|
|
# Worker Container Linux Config
|
|
data "template_file" "worker_config" {
|
|
template = "${file("${path.module}/cl/worker.yaml.tmpl")}"
|
|
|
|
vars = {
|
|
kubeconfig = "${indent(10, var.kubeconfig)}"
|
|
ssh_authorized_key = "${var.ssh_authorized_key}"
|
|
k8s_dns_service_ip = "${cidrhost(var.service_cidr, 10)}"
|
|
cluster_domain_suffix = "${var.cluster_domain_suffix}"
|
|
}
|
|
}
|
|
|
|
data "ct_config" "worker_ign" {
|
|
content = "${data.template_file.worker_config.rendered}"
|
|
pretty_print = false
|
|
snippets = ["${var.clc_snippets}"]
|
|
}
|