From 52427a42711671a745d170e0d61f32cc9f1800f0 Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Sun, 14 Aug 2022 21:37:26 -0700 Subject: [PATCH] Refresh instances in autoscaling group when launch configuration changes * Changes to worker launch configurations start an autoscaling group instance refresh to replace instances * Instance refresh creates surge instances, waits for a warm-up period, then deletes old instances * Changing worker_type, disk_*, worker_price, worker_target_groups, or Butane worker_snippets on existing worker nodes will replace instances * New AMIs or changing `os_stream` will be ignored, to allow Fedora CoreOS or Flatcar Linux to keep themselves updated * Previously, new launch configurations were made in the same way, but not applied to instances unless manually replaced --- CHANGES.md | 6 ++++++ aws/fedora-coreos/kubernetes/workers/workers.tf | 8 ++++++++ aws/flatcar-linux/kubernetes/workers/workers.tf | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 05b15bbb..a181cb09 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -32,6 +32,12 @@ version: 1.0.0 ### AWS +* [Refresh](https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-instance-refresh.html) instances in autoscaling group when launch configuration changes + * Changes to worker launch configurations start an autoscaling group instance refresh to replace instances + * Instance refresh creates surge instances, waits for a warm-up period, then deletes old instances + * Changing `worker_type`, `disk_*`, `worker_price`, `worker_target_groups`, or Butane `worker_snippets` on existing worker nodes will replace instances + * New AMIs or changing `os_stream` will be ignored, to allow Fedora CoreOS or Flatcar Linux to keep themselves updated + * Previously, new launch configurations were made in the same way, but not applied to instances unless manually replaced * Rename worker autoscaling group `${cluster_name}-worker` ([#1202](https://github.com/poseidon/typhoon/pull/1202)) * Rename launch configuration `${cluster_name}-worker` instead of a random id diff --git a/aws/fedora-coreos/kubernetes/workers/workers.tf b/aws/fedora-coreos/kubernetes/workers/workers.tf index 2973845e..9508808b 100644 --- a/aws/fedora-coreos/kubernetes/workers/workers.tf +++ b/aws/fedora-coreos/kubernetes/workers/workers.tf @@ -22,6 +22,14 @@ resource "aws_autoscaling_group" "workers" { var.target_groups, ]) + instance_refresh { + strategy = "Rolling" + preferences { + instance_warmup = 120 + min_healthy_percentage = 90 + } + } + lifecycle { # override the default destroy and replace update behavior create_before_destroy = true diff --git a/aws/flatcar-linux/kubernetes/workers/workers.tf b/aws/flatcar-linux/kubernetes/workers/workers.tf index fe298b4d..576de30b 100644 --- a/aws/flatcar-linux/kubernetes/workers/workers.tf +++ b/aws/flatcar-linux/kubernetes/workers/workers.tf @@ -22,6 +22,14 @@ resource "aws_autoscaling_group" "workers" { var.target_groups, ]) + instance_refresh { + strategy = "Rolling" + preferences { + instance_warmup = 120 + min_healthy_percentage = 90 + } + } + lifecycle { # override the default destroy and replace update behavior create_before_destroy = true