Skip to main content

Registry, Images and Artifacts

In order to deploy an application, all images and artifacts referenced in the application specification need to be available in the Control Tower registry. You can either push images and artifacts directly to the Control Tower registry, or let the Control Tower automatically pull them from remote registries into its own registry.

Add remote registry credentials​

If your registry requires credentials, you need to register the remote registry and reference a strongbox vault and secret where credentials are stored.

Credentials are stored as encrypted secrets in the Strongbox key-value store. To add credentials related to a remote registry you need to add them to a path vault/<vault-name>/secrets/<secret-name>.

The following adds a new remote registry key-value map named example-registry for credentials, and adds a user bob with a password.

Configure credentials​

In the UI:

  1. Create a vault names registry-credentials
  2. Create a secret called example-registry.
  3. Add username and password or if you have an access token: token.

Configure remote registry​

The following adds a new remote registry with address registry.example.com listening on the non-standard port 6000, and references the example-registry secret for credentials.

Select Remote Registries in the sidebar, click Connect new registry. Paste the following into the form and click Submit.

address: registry.example.com:6000
credentials:
- repository: '*'
vault: registry-credentials
secret: example-registry
note

Override address should generally be empty. It can be used to map one registry address to another. E.g docker.io to registry-1.docker.io.

Refer to a remote registry in an application specification​

Application specifications refer to container images using a string notation in the image: field. If the first part (before the first /) matches the name of a configured remote registry, the rest of the field will be treated as a path appended to the address of the remote registry when pulling containers.

The following application specification and remote registry configuration will result in attempted container image pulls from registry.gitlab.com/avassa-public/movie-theaters-demo/ticket-blipper.

name: ticket-manager
services:
- name: ticket-manager-service
containers:
- name: ticket-blipper
image: "registry.gitlab.com/avassa-public/movie-theaters-demo/ticket-blipper"
mode: replicated
replicas: 1

Default registry​

Configuring a default remote registry makes unqualified image references in the application specification resolve against this registry:

supctl create image-registry settings <<EOF
default-remote-registry: registry-1.docker.io
EOF

With this setting, the nginx image in the following application specification is fetched from registry-1.docker.io:

name: nginx
services:
- name: nginx-service
containers:
- name: nginx
image: nginx
mode: replicated
replicas: 1

Without a default registry configured, the image would be expected to exist in the Control Tower registry.

To refer explicitly to an image in the Control Tower registry, regardless of the default registry setting, prepend a leading /:

image: /nginx

Push images to the Control Tower registry​

Images and artifacts can be pushed to the Control Tower registry and made available for reference in application specifications.

The container registry hostname is on the form registry.<env>.<org>.avassa.net, where <org> is the organization name configured for your environment <env>. You need to authenticate to the registry using your login credentials.

The following uses the docker client to push a container example-container:latest to a registry at registry.test.acme.avassa.net.

Create a token for docker login

Login using the token

Docker login
docker login -u any -p <generated token> registry.test.acme.avassa.net
Push image
docker tag example-container:latest registry.test.acme.avassa.net/example-container:latest
docker push registry.test.acme.avassa.net/example-container:latest
note

The user used to push images must have the Registry-Push capability through one of the user's policies. The capability can be added to existing policies, or a specific policy can be created and assigned to the user: registry push policy

Upload artifacts to the Control Tower registry​

To upload a single file called mymodel.safetensors and tag it as mymodel with tag v1 in the Control Tower registry:

supctl do image-registry load-file mymodel:v1 --file mymodel.safetensors

To upload multiple files as a bundle and tag them as mycollection with tag v1:

supctl do image-registry load-files mycollection:v1 --files \
mymodel-00001-of-00002.safetensors mymodel-00002-of-00002.safetensors

When pushing artifacts with supctl the file names (in the case of a bundle) and file permissions (for both types of artifacts) are stored as per-layer annotations. See the fundamentals section on artifacts for the details.

Upload a single-layer image artifact​

Another possibility to mount a collection of files is to build a single-layer image and upload it with docker push just like any image:

Dockerfile
FROM scratch
COPY mymodel-00001-of-00002.safetensors mymodel-00002-of-00002.safetensors /
docker build -t registry.test.acme.avassa.net/myimage:v1 .

After logging in with Docker:

docker push registry.test.acme.avassa.net/myimage:v1

Upload artifacts to an external registry​

Currently supctl is only able to push artifacts to the Control Tower registry. If the intention is to store artifacts in an external registry, then the oras tool can be used for that purpose. It is important to specify the corresponding artifact type.

Push a single file to registry.example.com as mymodel with tag v1:

oras push --artifact-type application/vnd.avassa.file.v1 \
registry.example.com/mymodel:v1 \
mymodel.safetensors:application/octet-stream

Push a collection of files to registry.example.com as mycollection with tag v1:

oras push --artifact-type application/vnd.avassa.bundle.v1 \
registry.example.com/mycollection:v1 \
mymodel-00001-of-00002.safetensors:application/octet-stream \
mymodel-00002-of-00002.safetensors:application/octet-stream

By default oras does not store the file permissions, and the files are mounted with mode 0444. To set the permissions, an annotation file with an io.avassa.file.mode annotation for each file can be created and passed using the --annotation-file option.

A single-layer image can also be pushed to an external registry like any other image. It embeds the file permissions in its layer, so pushing the files in this way does not require a separate annotations file when permissions are important.

Choosing between the Control Tower registry and an external registry​

Container images are often built as part of CI/CD pipelines and pushed to the image registry integrated with the CI/CD system. Another use case is images built by external suppliers and available in a registry under the supplier's control. In both cases there is little reason to build an extra integration that copies the image to the Control Tower registry; instead, let the Control Tower pull images from the external registry as needed.

In other cases, however, there might not be an existing integration between a CI/CD system and a container image registry. If there is no such integration, it makes sense to push the images directly into the Control Tower registry by issuing a token with the registry-push policy and letting the CI/CD system use this token to upload the image.

Another use case, specific to artifacts, is that an artifact may not be readily available as an OCI artifact in an image registry, but instead via some other protocol, for example via HTTP(S). Such an artifact must be re-uploaded to an image registry, and in this case it would be sensible to upload it directly to the Control Tower registry if uploading it to an external registry serves no other purpose.

Disk space and cleanup considerations​

Regardless of whether images and artifacts are pushed to the Control Tower registry or stored in an external registry to be pulled by the Control Tower, the Control Tower must have enough disk space in its registry to hold all images and artifacts required by all applications on all sites. The edge sites never pull directly from an external registry, so if an image or artifact is stored in an external registry, it is first copied to the Control Tower registry before being distributed to the relevant edge sites.

One difference worth noting, however, is that the images and artifacts pushed to the Control Tower are never cleaned up automatically. This means that as new versions of an image are pushed to the Control Tower registry, or as images become unused, it is the user's responsibility to explicitly delete them from the registry to free up disk space:

supctl do image-registry repositories myimage tags 1.0 delete

It is also possible to delete all versions of a no longer used image:

supctl do image-registry repositories myimage delete

There is an auto-delete action to facilitate the cleanup (per tenant) which deletes all unused images:

supctl do image-registry auto-delete --all

Leaving the --all option out makes this action clean up only the images that are both unused and untagged.

Backup considerations​

It is also worth noting that while the images and artifacts are always replicated between multiple nodes in the Control Tower, there is no external backup of them. So, while they survive the loss of a single host within the Control Tower cluster, if the entire Control Tower is lost or accidentally deleted, all images and artifacts stored in it are lost. To protect against this, make sure that all images and artifacts stored in the Control Tower registry can be recovered from another source, for example by keeping them reproducible from their sources or by backing them up externally.