Skip to content

EKS Auto Mode and maintenance window for "Drifted" nodes

3 minute read
Content level: Advanced
4

Nodes launched by EKS Auto Mode have a maximum lifetime of 21 days. This article shows how to set a maintenance window to allow controlled node replacement

This guide provides configuration guidance for scheduling drifted node maintenance in EKS Auto Mode clusters, specifically allowing updates during a controlled maintenance window while restricting updates at other times.

EKS Auto Mode utilises the concept of Amazon EC2 managed instances and for security reasons Auto Mode enforces a maximum lifetime of 21 days for those instances, see Auto Mode Features.

EKS Auto Mode releases a new Auto Mode AMI frequently, sometimes once per week.

Under the hood Karpenter is used to provision compute capacity and manage the lifecycle of the corresponding nodes. When a new AMI is available , Karpenter nodeclaims are marked "AmiDrifted" (see nodeclaim status section).

Karpenter NodePool CRD is responsible to steer disruption using disruption budgets and schedules. It is possible to allow or prohibit disruption per so-called reason, with "Drifted" being one of them. If undefined, Karpenter will default to one budget with nodes: 10%, i.e. allow 10% of nodes to be disrupted for any reason at any time, see Karpenter docs NodePool Disruption Budgets.

The following NodePool disruption specification allows replacement of 10% of "Drifted" nodes for 2 hours on every Monday, starting at 6 PM, completely prohibiting disruption for "Drifted" outside of this schedule, while allowing disruption of up to 20% of "Empty" nodes at all times.

apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: your-nodepool-name  # Replace with your desired nodepool name
spec:
  disruption:
    budgets:
    # General protection: Allows empty node removal up to 20% at any time
    - nodes: "20%" # up to 20% of empty nodes at any time
      reasons:
      - Empty
    # Blocks drifted node updates on Sunday and Tuesday through Saturday
    - schedule: "0 0 * * sun,tue-sat"
      duration: 24h
      nodes: "0"
      reasons:
      - Drifted
    # Blocks drifted node updates on Monday from 00:00 to 18:00
    - schedule: "0 0 * * mon"
      duration: 18h
      nodes: "0"
      reasons:
      - Drifted
    # Maintenance window: Allows drifted node updates on Monday 18:00-20:00 (6-8 PM)
    - schedule: "0 18 * * mon"
      duration: 2h # make duration long enough to allow rotation
      nodes: "10%" # Allows up to 10% of nodes to be updated during this window
      reasons:
      - "Drifted"
    # Blocks drifted node updates on Monday from 20:00 to 24:00
    - schedule: "0 20 * * mon"
      duration: 4h
      nodes: "0"
      reasons:
      - Drifted

Notes:

  • If no budget is specified for a given period of time, disruption will be unrestricted
  • sun is defined as day 0, so it has to come first in the schedule definition schedule: "0 0 * * sun,tue-sat"
  • Timezones are not currently supported. Schedules are always in UTC, see Schedule in Karpenter docs.
  • Modify schedule, duration and nodes to meet your application and business needs.

Disruption is still subject to other levers like terminationGracePeriod and proper considerations need to be done to match those. See Karpenter Provider AWS issue Document behaviour when terminationGracePeriod is longer then budget schedule duration #8526 for additional information.

Carefully test this configuration in a non-production environment first. Monitor the first few maintenance windows to ensure proper operation.

AWS
EXPERT

published 9 months ago1.7K views

4 Comments

Hello, I would like to confirm whether this guide is valid also to help schedule the time of EKS AutoMode managed nodes version upgrade (let's say from 1.32 to 1.33)? It is mentioned in the post "specifically allowing updates during a controlled maintenance window while restricting updates at other times.", just want to confirm.

I mean we are interested to control the day and time window of our EKS AutoMode managed nodes upgrade because we want to real time monitor the deployments, perform tests and sync our teams: NOC, developers, SRE/DevOps, PO.

Let's say we upgrade the control plane on day X, 11:00. If we set the EKS AutoMode managed nodes to be automatically upgraded on day X, between 12:00 - 15:00, can we be sure that the nodes will upgrade? Or we have to wait a minumum number of hours between control plane upgrade and AutoMode managed nodes upgrade? Like I mentioned this is important for us to involve several teams during the worker nodes upgrade: NOC, SRE, developers.

If in the AutoMode managed nodes upgrade schedule we choose a day and time window, let's say 11:00 - 15:00. Will the upgrade of the nodes start around 11:00 (11:15, 11:30) or it can even start at 14:00 ? This is important to us because we (again) need to allocate people for workloads monitoring (deploys, daemon sets, ....). We prefer not to have them stand-by for 2 hours and the upgrade of the nodes start in the 3rd hour.

Thank you.

replied 7 months ago

I can confirm that a new EKS version marks the nodeclaim as "Drifted" as well. You can't predict when nodes are exactly terminated within the maintenance window. Please note, that pod shutdownGracePeriodSeconds and nodepool terminationGracePeriod can further impact when nodes are terminated. Pods blocking eviction like PDBs and do-not-disrupt will be respected during draining until the terminationGracePeriod is reached, where those pods will be forcibly deleted. The "nodes" value determines the number or percentage of nodes considered disruption candidates at any time during the maintenance window. This value together with duration and the above will determine, if all nodes could be updated during the window. You should experiment with different values to make sure it works like required.

AWS
EXPERT

replied 7 months ago

Related to the maintenance window set for Drifted nodeclaims, does EKS AutoMode guarantees that the nodes will be terminated during this maintenance window considering no pod PDB/do-not-disrupt and no pod shutdownGracePeriodSeconds exists or no nodepool terminationGracePeriod exists? Thank you.

replied 7 months ago

Terminating disruption candidates is default Karpenter behaviour. If nodes and durationallows enough candidates to get terminated during the maintenance schedule, it will work.

AWS
EXPERT

replied 7 months ago