Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add container requirements section under Labels #3144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/navigation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Learn
[/learn/develop/multicontainer]
Develop with Apps[/learn/develop/apps]
[/learn/develop/blocks]
[/learn/develop/container-contracts]
[/learn/develop/runtime]
[/learn/develop/hardware]
[/learn/develop/hardware/gpio]
Expand Down
124 changes: 0 additions & 124 deletions pages/learn/develop/container-contracts.md

This file was deleted.

60 changes: 59 additions & 1 deletion pages/learn/develop/multicontainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,60 @@ In addition to the settings above, there are some {{ $names.company.lower }} spe

{{> "general/labels" }}

[docker-compose]:https://docs.docker.com/compose/overview/
### Container requirements

**Note** Container requirements are available when using balenaCLI >= 21.1.0

An additional set of labels allows to ensure the compatibility of a device when it comes to run a service. For example, before updating to a new release, it may be desirable to ensure that the device is running a specific version of [Supervisor][supervisor] or has a specific version of the [NVIDIA Tegra Linux Driver Package][l4t] (L4T).

The following set of requirement labels are enforced via the supervisor. Each service may define one or more requirements and if any of them is not met for any non-[optional](#optional-containers) service, then the release will be **rejected** and no changes will be performed for the new release.

| Label | Description | Valid from Supervisor |
| -------------------------------------------------------------- | ------------------------------------------------------------------------- | --------------------- |
| io.{{ $names.company.short }}.features.requires.sw.supervisor | Device Supervisor version (specified as a [version range][version-range]) | 10.16.17 |
| io.{{ $names.company.short }}.features.requires.sw.l4t | [L4T][l4t] version (specified as a [version range][version-range]) | 10.16.17 |
| io.{{ $names.company.short }}.features.requires.hw.device-type | The [device type][device-type] as given by `BALENA_MACHINE_NAME` | 11.1.0 |
| io.{{ $names.company.short }}.features.requires.arch.sw | The [architecture][arch] as given by `BALENA_ARCH` | 14.10.11 |

For example, the following composition defines requirements on the supervisor and l4t version on the first service, and on the device type and architecture on the second service.

```yaml
version: '2'
services:
first-service:
build: ./first-service
labels:
io.balena.features.requires.sw.supervisor: '>=14'
io.balena.features.requires.sw.l4t: '>=32.2.0'
second-service:
image: my-second-image
labels:
io.balena.features.requires.hw.device-type: 'jetson-nano'
io.balena.features.requires.arch.sw: 'aarch64'
```

#### Optional containers

By default, when a container requirement is not met, none of the services are deployed to the device. However, in a multi-container release, it is possible to ignore those services that do not meet requirements with the other services being deployed as normal. To do so, we make use of the `io.balena.features.optional: 1` label to indicate which services should be considered optional.

In the `docker-compose.yml` file, add the `io.balena.features.optional: 1` to the labels list for each service you wish to mark as optional. In the following example, even if the `first-service` requirements fail, the `second-service` service will still be deployed.

```Dockerfile
version: '2'
services:
first-service:
build: ./first-service
labels:
io.balena.features.requires.hw.device-type: 'jetson-nano'
io.balena.features.optional: '1'
second-service:
build: ./second-service
```

**Note** When updating between releases, if the new version of and optional service has unmet requirements, the old version of the service will still be killed.

[docker-compose]: https://docs.docker.com/compose/overview/

[simple-app]:{{ $links.githubLabs }}/multicontainer-getting-started
[compose-features]:https://docs.docker.com/compose/compose-file/compose-file-v2/
[compose-support]:/reference/supervisor/docker-compose
Expand All @@ -124,3 +177,8 @@ In addition to the settings above, there are some {{ $names.company.lower }} spe
[services-masterclass]:/learn/more/masterclasses/services-masterclass/
[core-dump-link]:https://en.wikipedia.org/wiki/Core_dump
[feature-labels]:/learn/develop/multicontainer/#labels
[l4t]: https://developer.nvidia.com/embedded/linux-tegra
[supervisor]: /reference/supervisor/supervisor-api/
[device-type]:/reference/base-images/devicetypes/
[arch]: /reference/base-images/balena-base-images/#supported-architectures-distros-and-languages
[version-range]: https://www.npmjs.com/package/semver