AWS BottleRocket is an open-source Linux distribution. Think of it like the Alpine of AMI’s (Amazon Machine Image). It is intended to provide a minimal operating system on which to run containerized workloads. The benefits of AWS EKS BottleRocket address some of the most fundamental issues present in the default Amazon Linux 2 distribution, which you are provided by default when you create an EKS (Elastic Kubernetes Service) Cluster on AWS.
Having your EKS workloads on BottleRocket essentially solves many problems just by its OS structure alone, such as improved security and resource usage. The scenario referenced in this article is the creation of an EKS cluster with a BottleRocket node group from scratch, or the migration of an existing one.
What are the benefits of AWS BottleRocket?
AWS BottleRocket is a purpose-built, Linux-based operating system built for running containers. It includes all the necessary software required to run containers while ensuring the underlying software is always secure. In short, it provides the following advantages:
- Increased uptime for container applications by changing the system update mechanism
- Ability to manage the host by an actual HTTP API, interchangeable with TOML configuration file used to define a BottleRocket instance.
- Open-source development model enables custom builds. As you know, errors cannot slip under the radar as easily as enterprise software, and it allows for full control of customization of the source code..
- Lower management overhead and operational costs. This is done by supporting EKS automatic updates.
- Improved security and resource utilization. Fewer packages bloating the OS means fewer resources needed and less attack surface.
- Optimized performance through AWS integrations. Built-in features inserted by AWS allow it to easily integrate with other AWS services.
- 3 years of support, including community support in the open-source Github project. Who doesn’t love support?
There are, however, some hidden inconveniences explained later in this article that only a true implementer of AWS EKS BottleRocket would encounter. These include the OS difference between BottleRocket as a Linux distribution as opposed to other distributions, and its impact on Kubernetes as a resource allocator. After showing the method of installation, I’ll address them.
AWS BottleRocket Installation Guide
First, you’re going to have to define an EC2 Launch Template, which is an AWS resource that will supply the template upon which your EKS cluster will create BottleRocket OS EC2 Nodes. For this example, we will use Terraform, as it is a popular IaC tool for deploying EKS clusters. As for the AWS EKS BottleRocket configuration file, it will also be addressed in this section.
For starters, provide your Terraform code with a reference to the latest (or specific) AWS BottleRocket AMI version, which is present in the AWS AMI catalog available for creating EC2 instances. We can retrieve the Amazon Machine Image (AMI) ID for Amazon EKS optimized AMIs by querying the AWS Systems Manager Parameter Store API. Using this parameter, you don't need to manually look up Amazon EKS optimized AMI IDs:
Now that we got the value of the AMI’s Image ID, we can use it to create a launch template. I’ve also added some default settings, to save you time from ruffling through the docs:
Great! We’ve got an EKS Cluster, a Launch Template, and now we are missing an EKS node group to actually use this launch template:
The Configuration File
The BottleRocket configuration file is written in TOML format. It contains some basic configuration options and allows for tweaking endless knobs regarding the operating system. The variables in curly braces are provided via Terraform templating.
The most important settings in the file are whether to enable a control container and an admin container. AWS BottleRocket does not have SSH access, so there are two mechanisms to connect it via terminal:
- A Control Container. Allows for SSM (AWS Systems Manager) connection from the AWS console, which does this through the container without interacting with the infamously problematic SSH port.
- An Admin Container. If you do require a direct SSH connection, it’s done through an Admin Container that runs on the machine and provides access through it. This is a risky option and should be evaluated a per-need basis.
It is also important to note that BottleRocket OS allows for multiple kernel security settings, which provide elevated access. The integrity is recommended, however, you could go even deeper with the confidentiality mode, which will block even eBPF software. Only use this if you’re very serious about your security and know what you’re doing.
A major difference between Amazon Linux and BottleRocket
There is an extremely specific Linux operating system flag, which has an insanely dramatic effect on containerization. It is the version of the component named cgroups (control groups) - a Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, etc) of a collection of processes. This is the kernel feature that allows Linux to isolate container workloads, and it is being used by container engines such as containerd, which are the engine behind Kubernetes versions 1.24 and up.
Currently, there are two versions of cgroups. cgroup v1 and cgroup v2.
As of writing this article, the default cgroups version of Amazon Linux 2 AMI is v1, while AWS BottleRocket has v2 as the default version.
This might be critical to the stability of your workloads. Without getting into too much technical detail, the algorithm with which Linux (and Kubernetes) calculates the usage of resources, especially Memory, is different between the versions.
The practical implication is that Kubernetes itself might report different CPU/memory usage as to what you’ve seen your application use before the migration. Most of us will be upgrading from Amazon Linux 2 to AWS BottleRocket, so we will automatically receive cgroup v2. If we do not adjust our Kubernetes requests/limits accordingly, our pods might get OOM, get over/under-provisioned, or just lose stability. For some, readjusting your workload Requests and Limits would be passable, but sometimes that means provisioning more nodes for the same amount of previous workload, which might be unacceptable.
(I’ve personally noticed this behavior on NodeJS workloads)
If you want to prevent this from happening, or return to cgruop v1, there is a solution. You’ll have to tweak the kernel settings of the AWS BottleRocket AMI to force the usage of v1. For this, you’ll have to add the following settings to the aforementioned config.toml (0 = 1, 1 = 2):
Now you're all set to experience a clean setup of the BottleRocket-based EKS cluster. AWS BottleRocket is being actively developed by the open-source community but is perfectly safe for Production use, as long as necessary testing is done beforehand. Cheers!
Amitai G is a freelance DevOps consultant with an extensive background in DevOps practices and Kubernetes' ongoing maintenance and operations. As the author of the @elementtech.dev Medium channel, he specializes in writing articles that provide engineers with a deeper understanding and best practice guidance across the various aspects of the Cloud Native landscape.