Create a Repository
Create an ECR container image repository with the Repository API.
This guide creates an Amazon ECR repository from Kubernetes with a Repository manifest. You can push container images and OCI Helm charts to it, see Push artifacts to AWS ECR repository.
The platform creates the ECR repository with the cluster-wide defaults for image scanning, tag mutability and lifecycle rules, see EnvironmentConfig. Repositories are protected from deletion by default.
It is good practice to manage Repositories with GitOps, the same way applications are deployed.
Prerequisites
Section titled “Prerequisites”The Repository API is enabled by default. Your Infralib configuration needs:
| Module | Flag | Default | What it does |
|---|---|---|---|
platform-apis |
platform-apis.repository.install |
true |
Installs the Repository API. |
crossplane-aws |
global.createObservers, global.createNamespacedObservers |
false |
Installs the ECR provider. Set both to true, or add ecr to global.extraProviders. |
For the base modules every platform API needs, see Infralib Requirements.
1. Create the Repository
Section titled “1. Create the Repository”A minimal Repository needs only a name:
# Creates <aws-account>.dkr.ecr.<aws-region>.amazonaws.com/example-repositoryapiVersion: artifact.entigo.com/v1alpha1kind: Repositorymetadata: name: example-repositoryspec: {}By default, metadata.name is used as the repository name in ECR and no path (prefix) is used.
Optional settings
Section titled “Optional settings”| Field | Default | What it does |
|---|---|---|
name |
metadata.name |
Name of the repository in ECR. Cannot be changed after creation. |
path |
unset | Prefix path for the repository, for example helm/dev. Cannot be changed after creation. |
deletionProtection |
true |
Blocks deletion, see Delete a Repository. |
lifecycleRules |
cluster default | ECR lifecycle policy rules. Replaces the cluster-wide default when set. |
The repository URI is built from spec.path and spec.name:
# If spec.name is not set<aws-account>.dkr.ecr.<aws-region>.amazonaws.com/<metadata.name>
# If spec.name is set<aws-account>.dkr.ecr.<aws-region>.amazonaws.com/<spec.name>
# If spec.path is set<aws-account>.dkr.ecr.<aws-region>.amazonaws.com/<spec.path>/<metadata.name># or<aws-account>.dkr.ecr.<aws-region>.amazonaws.com/<spec.path>/<spec.name>Each lifecycle rule needs one selector (tagPrefixes, tagPatterns or untagged) and one retention bound (keepCount or expireAfterDays). A rule without a selector matches every image and must be the last rule.
For example, a repository under a path with its own name and lifecycle rules:
# Creates <aws-account>.dkr.ecr.<aws-region>.amazonaws.com/helm/dev/example-repository-name-overrideapiVersion: artifact.entigo.com/v1alpha1kind: Repositorymetadata: name: example-repositoryspec: name: example-repository-name-override path: helm/dev # Replaces the lifecycleRules default from the platform-apis EnvironmentConfig. lifecycleRules: - tagPrefixes: - develop keepCount: 10 - tagPatterns: - "*-cloud" keepCount: 10 - untagged: true expireAfterDays: 7 # A rule without a selector matches every image and must be last. - expireAfterDays: 90For every field, see the Repository API reference.
2. Verify
Section titled “2. Verify”The Repository shows SYNCED and READY as True:
$ kubectl get repositoryNAME SYNCED READY COMPOSITION AGEexample-repository True True repositories.artifact.entigo.com 3m13sThe repository URI for pushing and pulling is in status.repositoryUri:
kubectl get repository example-repository -o jsonpath='{.status.repositoryUri}'The repository appears in the AWS Console:

3. Delete a Repository
Section titled “3. Delete a Repository”Repositories are protected from deletion: spec.deletionProtection defaults to true.
To delete a Repository, first set spec.deletionProtection to false and apply the change:
apiVersion: artifact.entigo.com/v1alpha1kind: Repositorymetadata: name: example-repositoryspec: deletionProtection: falseThen delete the Repository resource:
kubectl delete repository example-repositoryOnce deletion protection is disabled, the repository is deleted even if it still contains images.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause / fix |
|---|---|
no matches for kind "Repository" |
The API is not installed. Check the Prerequisites. |
SYNCED is False |
The platform could not create the ECR repository. kubectl describe repository <name> shows the error under Conditions and Events. Check that the ECR provider is installed, see Prerequisites. |
Changing spec.name or spec.path is rejected |
Both fields are immutable. Create a new Repository instead. |
| The Repository is not deleted | deletionProtection is true by default. Set it to false, apply, then delete. |
EnvironmentConfig
Section titled “EnvironmentConfig”Some Repository defaults are not set on the Repository object itself. They are set once for the whole cluster in the platform-apis EnvironmentConfig, so every Repository gets the same behaviour without developers having to think about it.
| Setting | Default | What it does |
|---|---|---|
lifecycleRules |
[] (no policy) |
Automatic clean-up rules for old images, so repositories do not grow forever. |
scanOnPush |
true |
Scans every pushed image for known vulnerabilities. |
imageTagMutability |
MUTABLE |
Whether an existing tag can be overwritten by a new push. |
tags |
{} |
Cloud tags added to every repository. See Resource Tagging. |
lifecycleRules
Section titled “lifecycleRules”The default ECR lifecycle policy for every repository. Without it, images are kept forever and storage costs grow with every build.
A Repository can replace the whole list through spec.lifecycleRules, see Optional settings. Leave the cluster-wide list empty to create no lifecycle policy at all.
Each rule takes one selector (tagPrefixes, tagPatterns or untagged) and one retention bound (keepCount or expireAfterDays). A rule without a selector matches every image and must be last.
scanOnPush
Section titled “scanOnPush”When enabled, AWS ECR scans every image pushed to the repository for known vulnerabilities and reports the findings in the AWS console. This is a good default to leave on.
imageTagMutability
Section titled “imageTagMutability”Controls whether an image tag can be moved to a different image.
MUTABLE(default) — pushingmyapp:latesta second time replaces the previous image. Convenient for development.IMMUTABLE— a tag can only be pushed once. This guarantees that a deployed tag always refers to exactly the same image, which is what you want for release tags in production. Pipelines that re-push the same tag will start failing, so change this only when your build pipelines produce a unique tag per build.IMMUTABLE_WITH_EXCLUSIONandMUTABLE_WITH_EXCLUSION— the same behaviour with an exception list, configured in AWS.
Infralib Configuration Example
Section titled “Infralib Configuration Example”steps: ... - name: apps type: argocd-apps modules: ... - name: platform-apis source: platform-apis inputs: platform-apis: artifact: environmentConfig: scanOnPush: true imageTagMutability: MUTABLE lifecycleRules: - untagged: true expireAfterDays: 7 - keepCount: 20