hustshawn / bottlerocket-images-cache

Pre-fetching large container images in Bottlerocket data volume snapshot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caching Container Images for AWS Bottlerocket Instances

The purpose of this solution is to reduce the boot time of containers on AWS Bottlerocket instances that require large container images by caching the images in the data volume.

Data analytics and machine learning workloads often require container images larger than 1 GiB, which can take up to a minute to pull and extract from ECR. To improve the efficiency of booting these containers, reducing the time to pull the image is key.

Bottlerocket is a Linux-based open-source operating system built by AWS specifically for running containers. It has two volumes, an OS volume and a data volume, with the latter used for storing artifacts and container images. This solution will leverage the data volume to pull images and take snapshots for later usage.

To demonstrate the process of caching images in EBS snapshots and launching them in an EKS cluster, this solution will use Bottlerocket for EKS AMI.

How it works

bottlerocket-image-cache drawio

  1. Launch an EC2 instance with Bottlerocket for EKS AMI, then pull images which need to cache in this EC2.
  2. Build the EBS snapshot for the data volume.
  3. Launch instance with the EBS snapshot.

Steps

  1. Set up AWS CLI, eksctl and kubectl in your development environment(Linux or MacOS).
  2. Clone this projects in your local environment.
  3. Run snapshot.sh to build the EBS snapshot.
    ./snapshot.sh -r us-west-2 public.ecr.aws/eks-distro/kubernetes/pause:3.2
    
  4. Modify cluster.sh to set CLUSTER_NAME, EBS_SNAPSHOT_ID and AWS_DEFAULT_REGION
  5. Run cluster.sh to build the testing cluster.
  6. Run kubectl get node to list the worker nodes with cached images.

About

Pre-fetching large container images in Bottlerocket data volume snapshot


Languages

Language:Shell 100.0%