ecr-cleanup

by Fairwinds

Helm chartv1.2.9App 0.1.11Verified publisher

A Helm chart to run ecr cleanup controller

About this chart

ECR Cleanup

Cleans up unused ECR images using this

Config

ParameterDescriptionDefaultRequired
controller.dryRunDon't delete any images, just scan and log.falseyes
controller.intervalHow frequently the scan runs.60yes
controller.maxImagesMaximum number of images to keep in ECR.900yes
controller.namespacesNamespaces to check for running images.defaultyes
controller.regionRegion that the ECR repo is in.us-east-1yes
controller.reposECR repo names to delete from.sudermanjr-testyes
controller.registryIDAccount ID (registry ID) to use if it is not the default.""no
controller.verbosityLog verbosity.1yes
controller.keep_filterscomma-separated list of filters or regexes that when matched will preserve the matching images.no
fullnameOverride no
image.pullPolicyLeave this like this.Alwaysno
image.repositoryDocker repo to use.danielfm/kube-ecr-cleanup-controllerno
image.tagImage version0.1.5no
nameOverride no
nodeSelector{}no
rbac.createIf True, create rbac resources for the controller.Trueno
replicaCountShould always be 1. Why run multiple?1no
resources.limits.cpuCPU limit.100mno
resources.limits.memoryMemory limit.128Mino
resources.requests.cpuCPU request100mno
resources.requests.memoryMemory request.128Mino
tolerationsTolerations on controller pod.[]no
affinityAffinity on controller pod.{}no

AWS Policy

The following IAM policy is needed for the controller to work.

{
  "Version": "2008-10-17",
  "Statement": [
    {
      "Sid": "${POLICYNAME}",
      "Effect": "Allow",
      "Principal": {
        "AWS": [
          "arn:aws:iam::${ACCOUNT_ID}:role/${ROLENAME}"
        ]
      },
      "Action": [
        "ecr:BatchDeleteImage",
        "ecr:BatchGetImage",
        "ecr:DescribeImages",
        "ecr:ListImages"
      ]
    }
  ]
}

Deploy ecr-cleanup with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has ecr-cleanup on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartecr-cleanup is pinned at v1.2.9 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply