Sharing data between apps
Apps are isolated from each other by default: each app runs in its own Kubernetes namespace, and network policies only allow traffic within the app. To let another app use yours, expose a permission; to use another app, request its permission.
Exposing a service
The app that provides something declares a permission in its metadata.yml:
# metadata.yml of the app "bitcoin-core"
version: 2
metadata:
implements: bitcoin
exposes_permissions:
- id: access-rpc
name: JSON-RPC API
description: Interact with the Bitcoin Core JSON-RPC API
services:
gateway:
- 8332Using another app's service
The app that uses it requests the permission and, if it can't work without the other app, depends on it:
# metadata.yml of a consuming app
version: 2
metadata:
dependencies:
- bitcoin
has_permissions:
- bitcoin/access-rpcWhen the user grants the permission, n5i allows traffic from the consuming app to the listed services and ports.
Services of other apps are reachable under these host names:
| Host name | For |
|---|---|
<service>.<app>.<user>.n5i | Apps installed for a user. |
<service>.<app>.n5i | System apps (installed once for the whole server). |
Inside a template, build the host name from the context, for example gateway.bitcoin..n5i.
Virtual apps
An app can declare implements: <id> to provide a "virtual" app. Other apps then depend on and request permissions of the virtual ID (bitcoin/access-rpc above), and the host name <service>.bitcoin.<user>.n5i resolves to whichever implementation is installed. This lets users choose between interchangeable apps.
Alternatives in dependencies
A dependency can be a list of alternatives, any of which satisfies it:
dependencies:
- [postgres, mariadb]Routing a domain to another app
With an ingress entry, an app can serve another app's service under its own domain. This needs a permission that covers the target service and port, like any other access.
Plugins
For anything that needs more than network access, such as creating accounts in another app at install time, the other app can provide a context plugin.