2 min read

Automatically pull new AWS ECR latest tags from AWS EKS

How to automatically pull latest tag image on Elastic Container Registry (ECR) from Elastic Kubernetes Service (EKS) on AWS and automatically restart pods.
Automatically pull new AWS ECR latest tags from AWS EKS

Problem

A common use case on AWS Elastic Kubernetes Service (EKS) is to automatically pull latest images stored on AWS Elastic Container Registry (ECR) with tag name that doesn't change over time (ex. latest)

Solution

Use Urunner.
URunner is a lightweight Kubernetes utility in order to auto restart pods on image tag digest change.

How it works

Urunner is a standalone pod (running by default on urunner namespace) that continuosly check changes on external container registries that support Docker API V2, for example AWS ECR.
Urunner detects changes from container tags that don't change their names over time (like latest)

When Urunner detects changes on ECR (thanks to sha1 tag digest), automatically restart the specific deployment (the same of kubectl rollout restart deployment/<deployName>)

Urunner stores its state on an internal sqllite db.

How to install Urunner

Prerequisites

Install Urunner

Create urunner-values.yaml file.

image:
  repository: ghcr.io/texano00/urunner
  tag: 0.1.5

config:
  URUNNER_CONF_FREQUENCY_CHECK_SECONDS: 5
  URUNNER_CONF_CONTAINER_REGISTRY_TO_WATCH: <replace-me-ecr>
  URUNNER_CONF_CONTAINER_REGISTRY_TYPE: aws_ecr
secret:
  create: true
  aws:
    access_key_id: <replace-me-access>
    secret_access_key: <replace-me-secret>

<replace-me-ecr> --> <account-id>.dkr.ecr.<region>.amazonaws.com

AWS access and secret key. Assign to this user the following AWS managed role AmazonEC2ContainerRegistryReadOnly
<replace-me-access> --> aws access_key_id
<replace-me-secret --> aws secret_access_key

Helm install

Artifact Hub
helm upgrade --install urunner oci://ghcr.io/texano00/urunner/helm/urunner --version 0.1.0 --values urunner-values.yaml -n urunner --create-namespace

Labeling

Add urunner=enable to all namespaces you want to be watched from Urunner.

kubectl label ns mynamespace urunner=enable

For full documentation --> https://github.com/texano00/urunner#configurable-watcher

Check the installation

Once Urunner detects a tag digest change, it will output the following row

Tweets by YBacciarini