# Registries

Point Platforma to registry mirrors in the company, and allow the registries of custom Blocks.

The Backend (The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs.), the nodes of the cluster and the Desktop App (The program that each user installs on their own computer to work with Platforma. It is a client of the Backend.) get the Blocks (A small application for one step of an analysis, for example the import of reads or clustering. It can combine several tools.), the tools and the reference data from the registries of MiLaboratories. You can point each of them to a mirror in the company, so that Platforma works with the access to the internet that the company allows:

- [Software images of the jobs](/configuration-registries/#software-images-of-the-jobs): containers of the tools.
- [Software packages and assets](/configuration-registries/#software-packages-and-assets): tools and reference data.
- [Registries of custom Blocks](/configuration-registries/#registries-of-custom-blocks): allow more image registries.
- [Block registries in the Desktop App](/configuration-registries/#block-registries-in-the-desktop-app): where users get Blocks.
- [Credentials of a mirror](/configuration-registries/#credentials-of-a-mirror): mirrors that need a sign-in (To show the Backend who you are, with a sign-in provider or a single-user token. The verb is "sign in"; the noun and the adjective are "sign-in".).

For how to make each mirror, and why a restricted network needs a mirror of each registry, see [Registries mirroring](/registries-mirroring/). For what Platforma expects from a mirror, see [Registries and mirrors](/infrastructure-contract-identity/#registries-and-mirrors). For the full list of hosts, see [Outbound connections](/security-outbound-connections/).

For an installation made with an installer, see [Install in cloud with installer](/install-cloud-installer/).

## Software images of the jobs

The jobs (One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster.) run the tools from software images in `containers.pl-open.science/milaboratories/pl-containers`. When you set a default Docker registry, the Backend replaces this prefix in each image name with the value that you set, and keeps the tag. The Backend always trusts the registry that you set. With a cache or a mirror inside the cloud or the corporate network, the images come faster and the nodes do not need access to the internet.

**Example:**

With the default Docker registry `registry.example.com/pl-containers`, the image `containers.pl-open.science/milaboratories/pl-containers:<tag>` becomes `registry.example.com/pl-containers:<tag>`.

#### Variant: Kubernetes cluster

| Helm value                         | Terraform input                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Default         |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| `registries.defaultDockerRegistry` | `infrastructure.registries.default_docker_registry` of `platforma-tf-services`; with the cloud-specific Terraform modules (The Terraform modules platforma-tf-cloud-base and platforma-tf-cloud-cluster. There is one pair for each cloud, AWS and Google Cloud. The roots cloud and cluster apply them. They make the network, the Kubernetes cluster, the storage, the cloud identities and the registry caches. They give the hand-off file cluster_config to the cloud-agnostic Terraform modules.), `registries.default_docker_registry` of `platforma-tf-cloud-base` | `""`: no change |

When you leave this value empty, the cloud-specific modules set it to their software cache: see [Caches of the cloud-specific modules](/install-cloud-terraform/#caches-of-the-cloud-specific-modules). A value that you set always wins.

*Inputs of platforma-tf-cloud-base*

```hcl
registries = {
  default_docker_registry = "registry.example.com/pl-containers"
}
```

*platforma-tf-services*

```hcl
locals {
  infra = jsondecode(file("infrastructure.json"))
}


module "platforma" {
  # ...
  infrastructure = merge(local.infra, {
    registries = merge(try(local.infra.registries, {}), {
      default_docker_registry = "registry.example.com/pl-containers"
    })
  })
}
```

The inner `merge` keeps the other registry settings of the file.

*values.yaml*

```yaml
registries:
  defaultDockerRegistry: registry.example.com/pl-containers
```

For how to make the mirror, see [Software images of the tools](/registries-mirroring-tool-images/).

This setting does not change the images of the cleanup job and of the other helper pods: set their mirror apart, see [Backend and controller images](/registries-mirroring-images/).

#### Variant: Single Server

The setting is used only when the jobs run in Docker. Start the Backend with `--default-docker-registry <registry>`, or set the environment variable `PL_DEFAULT_DOCKER_REGISTRY`.

The new value applies to the jobs that start after the Backend starts again. A job whose image is not in the mirror fails. The mirror must hold the same tags as the original.

## Software packages and assets

The Backend downloads the assets, for example reference genomes, from `bin.pl-open.science`. In Single Server mode (The mode in which the Backend and all its jobs run on one Linux machine, the server, with no Kubernetes cluster.), when the jobs run without Docker, it also downloads the software packages of the tools from this host. Point them to a mirror, so that the Backend does not need this host.

**Assets.** The assets registry (A service from which the Backend downloads the assets that Blocks need, for example reference genomes. The default is bin.pl-open.science, the same host as the software registry; a mirror replaces it with its own URL.) URL replaces `https://bin.pl-open.science/` in the addresses of the assets.

**Software packages.** A Kubernetes (A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster.) cluster does not use them: its jobs run in containers. The software packages come from the package registries `platforma-open` and `milaboratories`. The option `--package-registry NAME=URL` gives a registry its address: `http://` or `https://` for a mirror, `dir://` for a folder on the Backend. When `NAME` is `platforma-open`, the Backend does not use the public address any more, and `milaboratories` gets the same address. Repeat the option with the same name to give more addresses: the Backend tries them in order. A new name adds the package registry of a custom Block.

#### Variant: Kubernetes cluster

| Helm value                     | Terraform input                                                                                                                                                                      |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `registries.assetsRegistryURL` | `infrastructure.registries.assets_registry_url` of `platforma-tf-services`; with the cloud-specific Terraform modules, `registries.assets_registry_url` of `platforma-tf-cloud-base` |

*Inputs of platforma-tf-cloud-base*

```hcl
registries = {
  assets_registry_url = "https://bin-mirror.example.com/"
}
```

*values.yaml*

```yaml
registries:
  assetsRegistryURL: https://bin-mirror.example.com/
```

For `platforma-tf-services`, see the example in [Static assets](/registries-mirroring-assets/).

#### Variant: Single Server

Start the Backend with these options. `--package-registry` is needed only when the jobs run without Docker:

```sh
platforma --assets-registry-url https://bin-mirror.example.com/ \
          --package-registry platforma-open=https://bin-mirror.example.com/ \
          <other options>
```

For the assets, the environment variable `PL_ASSETS_REGISTRY_URL` does the same as the option. The environment variable `PL_PACKAGE_REGISTRY` sets one package registry (`NAME=URL`).

After a change, restart the Backend.

## Registries of custom Blocks

The Backend runs a software image only from a registry that it trusts: `containers.pl-open.science` and the default Docker registry, when you set one. A job that asks for an image from another registry fails, and running it again does not help. Thus a custom Block, for example a Block that the company develops, can use its own image registry only when you add this registry to the trusted list. Each item is a registry host, the part of the image name before the first `/`. For the registry that gives the Blocks of the company to users, see [Own Block registry](/configuration-block-registry/).

| Helm value                           | Terraform input                                                                                                                                                                                  | Default |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
| `registries.trustedDockerRegistries` | `infrastructure.registries.trusted_docker_registries` of `platforma-tf-services`; with the cloud-specific Terraform modules, `registries.trusted_docker_registries` of `platforma-tf-cloud-base` | `[]`    |

*Inputs of platforma-tf-cloud-base*

```hcl
registries = {
  trusted_docker_registries = ["registry.example.com"]
}
```

*values.yaml*

```yaml
registries:
  trustedDockerRegistries:
    - registry.example.com
```

A registry that you add is trusted for the images of all Blocks. For how MiLaboratories checks its own images, see [Vulnerability management](/security-vulnerability-management/).

## Block registries in the Desktop App

The Desktop App gets the Blocks from the Block registry (A service from which the Desktop App downloads Blocks. MiLaboratories runs the main one; a company can add its own.) of MiLaboratories, `blocks.pl-open.science`. Each computer keeps its own Block registry settings, in the settings of the Desktop App: give users the values that the company chose.

- **Override Main Registry**: the address of a mirror of the main Block registry. Empty means the main registry of MiLaboratories. This field cannot be changed while “Use Global Access Registry” is on.
- **Additional Registries**: more Block registries, one address on each line, for example the registry of the Blocks that the company develops. Users see the Blocks of these registries next to the Blocks of the main registry. For how to set up such a registry, see [Own Block registry](/configuration-block-registry/).
- **Use Global Access Registry**: get the Blocks from `blocks-ga.pl-open.science`, on two fixed IP addresses. See [Desktop App](/configuration-proxy-and-custom-ca/#clients).

The Blocks that a registry gives can run tools on the Backend: add only the registries that the company trusts. The Backend also reads the Block registry: it gets the workflow (The part of a Block that runs in the Backend. It starts the tools on the data and collects the results. Users do not edit it.) template packs of the Blocks from it. A mirror of the main Block registry must serve the Backend too: see [Block registry mirror for the Backend](/configuration-registries/#block-registry-mirror-for-the-backend). When a Block of an additional registry uses its own image registry, add it to the trusted registries of the Backend (see [Registries of custom Blocks](/configuration-registries/#registries-of-custom-blocks)). In Single Server mode without Docker, when it uses its own software package registry, set this registry on the Backend too (see [Software packages and assets](/configuration-registries/#software-packages-and-assets)).

## Block registry mirror for the Backend

The Backend gets the workflow template packs of the Blocks from the Block registry. To point the Backend to a mirror of the Block registry, give it the option `--blocks-registry-url` with the address of the mirror. In each address that the Backend imports, it then replaces `https://blocks.pl-open.science/` with this address. End the address with `/`, the same as `https://blocks.pl-open.science/`. Otherwise the Backend does not start. The option also applies in the restricted network mode: then the Backend uses the mirror, not `blocks-ga.pl-open.science`.

#### Variant: Kubernetes cluster

The chart and the Terraform modules (The Terraform code that MiLaboratories provides to install Platforma. The cloud-specific Terraform modules make the cluster and its cloud parts in AWS or Google Cloud; the cloud-agnostic Terraform modules install Platforma into the cluster.) do not have a value or an input of their own for this option. Give it in the extra options of the Backend: the Helm value `extraArgs`, or the input `backend_service.extra_args` of `platforma-tf-services`.

*values.yaml*

```yaml
extraArgs:
  - --blocks-registry-url=https://blocks-mirror.example.com/
```

*Inputs of platforma-tf-services*

```hcl
backend_service = {
  extra_args = ["--blocks-registry-url=https://blocks-mirror.example.com/"]
}
```

The AWS installer and the Google Cloud installer do not have a parameter for this option.

#### Variant: Single Server

Start the Backend with the option, or set the environment variable `PL_BLOCKS_REGISTRY_URL`:

```sh
platforma --blocks-registry-url https://blocks-mirror.example.com/ <other options>
```

After a change, restart the Backend. The Desktop App has its own setting for the mirror: see [Block registries in the Desktop App](/configuration-registries/#block-registries-in-the-desktop-app).

## Credentials of a mirror

#### Variant: Kubernetes cluster

Give the credentials in one of these ways:

- **Cloud identity (The identity that the cloud gives to the Platforma pod (IAM roles for service accounts on AWS, Workload Identity on Google Cloud). With it, Platforma needs no access keys.) of the nodes** (recommended when the cloud allows it, for example Amazon ECR and Google Artifact Registry): give the identity of the nodes read access to the mirror. The pods then do not need a Secret.

- **Image pull Secret**: make a Secret of type `kubernetes.io/dockerconfigjson` in the namespace of the instance, and give its name to each kind of pod that pulls from the mirror:

  | Pods        | Helm value                              | Terraform input of `platforma-tf-services`                |
  | ----------- | --------------------------------------- | --------------------------------------------------------- |
  | Backend     | `backend.image.pullSecrets`             | `backend_service.backend.image.pull_secrets`              |
  | Jobs        | `jobs.image.pullSecrets`                | `backend_service.jobs.image.pull_secrets`                 |
  | Cleanup job | `cleanup.appWrappers.image.pullSecrets` | `backend_service.cleanup.app_wrappers.image.pull_secrets` |

  ```sh
  kubectl -n platforma create secret docker-registry regcred \
    --docker-server=registry.example.com \
    --docker-username=<user> --docker-password=<password>
  ```

  *platforma-tf-services*

  ```hcl
  backend_service = {
    backend = { image = { pull_secrets = [{ name = "regcred" }] } }
    jobs    = { image = { pull_secrets = [{ name = "regcred" }] } }
    cleanup = { app_wrappers = { image = { pull_secrets = [{ name = "regcred" }] } } }
  }
  ```

  *values.yaml*

  ```yaml
  backend:
    image: { pullSecrets: [{ name: regcred }] }
  jobs:
    image: { pullSecrets: [{ name: regcred }] }
  cleanup:
    appWrappers:
      image: { pullSecrets: [{ name: regcred }] }
  ```

The images of Kueue (A Kubernetes add-on that holds jobs in a queue until the cluster has free CPU, memory and GPU for them.) and the AppWrapper (A Kubernetes add-on that wraps the pods of one job into a single unit, so that Kueue admits and starts them together.) controller run outside the namespace of the instance. For a mirror of them that needs credentials, give the nodes the credentials: the cloud identity of the nodes, or registry credentials in the configuration of the container runtime of the nodes.

#### Variant: Single Server

With Docker, the Backend pulls the images with the Docker credentials of its system user: the file in `$DOCKER_CONFIG`, or `$HOME/.docker/config.json`. Sign in to the mirror as this user:

```sh
sudo -H -u <backend user> docker login registry.example.com
```

The `HOME` of the Backend service must be the home folder of this user. Otherwise Docker does not find the credentials.

## Changes on a running installation

For what a restart of the Backend does, see [Restart of the Backend](/configuration-storage/#restart-of-the-backend).

| Change                                                 | What happens                                                                   | What to do                                                                                                                    |
| ------------------------------------------------------ | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| Switch the software images to a mirror                 | The Backend starts again. New jobs pull from the mirror. Results do not change | Check that the mirror gives the images: a pull-through cache gets them on demand; a sync must hold the tags before the change |
| Switch the software packages or the assets to a mirror | The Backend starts again. New downloads come from the mirror                   | Check that the mirror gives the files: a caching proxy gets them on demand; a copy must hold them before the change           |
| Remove a trusted registry                              | New jobs of the Blocks that use it fail. Results that exist stay               | Remove it only when no Block that users run needs it                                                                          |
| Change the Block registries in the Desktop App         | Users see the Blocks and the updates of the new registries                     | Tell users the new values; each user sets them on each computer                                                               |

## Problems

**A job fails because its image cannot be pulled.** Cause: the mirror does not hold the image with the same tag, or the nodes do not have the credentials of the mirror. Fix: copy the image to the mirror, or give the credentials (see [Credentials of a mirror](/configuration-registries/#credentials-of-a-mirror)), then run the Block again.

**A job of a custom Block fails at once, and running it again does not help.** Cause: its image is in a registry that the Backend does not trust. Fix: add the registry host to the trusted registries (see [Registries of custom Blocks](/configuration-registries/#registries-of-custom-blocks)).

**The cleanup job does not start after its image moves to a mirror that needs credentials.** Cause: the cleanup job does not have the pull Secret. Fix: set `cleanup.appWrappers.image.pullSecrets`.

For other job failures, see [A job waits or hangs](/maintain-troubleshooting-jobs/).

## Next

- [Registries mirroring](/registries-mirroring/)
- [Own Block registry](/configuration-block-registry/)
- [Proxy and custom CA](/configuration-proxy-and-custom-ca/)
- [Outbound connections](/security-outbound-connections/)

Source: https://docs.platforma.bio/configuration-registries/
