A Kubernetes mutation webhook that automatically redirects container image pulls through Amazon ECR's pull-through cache, optimizing performance and reducing costs.
This webhook intercepts pod creation requests in your Kubernetes cluster and automatically modifies container image references to use Amazon ECR's pull-through cache. This means:
- ⚡ Faster image pulls through local caching
- 💰 Reduced network egress costs
- 🔄 Seamless integration with existing deployments
-
ECR Pull-Through Cache Configuration
You must manually configure pull-through cache for these registries:ghcr.io
docker.io
registry.k8s.io
quay.io
⚠️ Important: Use registry-matching names for your configurations as required by this webhook. -
IAM Configuration
Check theaws-policies
folder for:- Example lifecycle policies for Creation Templates
- ECR Registry policy examples
- Role configurations for EKS nodes
📚 For detailed ECR Pull-Through setup, see the AWS documentation.
-
Clone the repository:
-
Install the chart:
helm install ecr-pull-through -n kube-system chart/ecr-pull-through \
--set awsAccount=123456789012 \
--set awsRegion=us-west-2
📝 Prerequisites:
- cert-manager must be installed in your cluster
- The chart uses cert-manager to generate TLS certificates for the webhook
Note: docker.io support is limited in Kyverno configuration
- Find policies for
docker.io
,quay.io
,registry.k8s.io
, andghcr.io
in thekyverno
folder - Update AWS account ID in policies
- Apply to your cluster
- Clone this repository
- Go to
manifests
folder - Configure manifests/configmap.yaml
- Ensure your kubectl context points to the target cluster
- Run
./install.sh
🔑 Note: By default, the webhook only processes namespaces labeled with
pull-through-enabled: "true"
. Modify manifests/bundle.yaml to change this behavior.
Use the sample pod manifests in the tests
folder to verify the webhook's operation.
This might be useful if you are testing ECR Pull-through and want to occasionally cleanup pull-through registries.
Use ecr-cleanup.sh to remove pull-through generated repositories:
./ecr-cleanup.sh
This project is open-source and available under the MIT License.