App Networks
Nomatron is in early access. Some advanced workflows may not be covered in the public docs.
An app network is a named, host-local Docker network that belongs to one app. Bind app jobs to it, and Nomatron attaches their Docker tasks to that network on every eligible client. Bind several jobs to one network so they share it, or give a job a network of its own.
App networks work in every Application Networking mode, and need healthy Host Agents on the app’s cluster. Connecting the cluster is not required; app networks need only a Host Agent deployment.
Network Modes
--mode | What you get |
|---|---|
private (default) | A Docker bridge network that Nomatron creates and owns. |
internal | A Docker bridge network created with Docker’s internal option, so attached containers have no outside connectivity. |
existing | A Docker network that already exists on the clients. Give its name with --existing-name. Nomatron uses it but never creates or deletes it. |
Addressing is automatic (Docker picks the subnet) or custom with --cidr set to a canonical IPv4 or IPv6 network, such as 192.0.2.0/24. Custom ranges cannot overlap another app network’s range on the same cluster. Existing networks only accept automatic.
Nomatron-created networks are named nomatron-<network-id> on each client and labelled io.nomatron.managed=true.
Create A Network And Bind Jobs
nomatron apps networks create \
--organization acme \
--app api \
--name backend \
--mode private \
--job-slugs web,worker--slugis optional; it defaults to a slug of--name.- Binding jobs (
--job-slugs) needs theapplication_networksbindpermission as well as permission to manage app networks. - A job can be bound to only one app network.
What Happens At Plan Time
When you plan a bound job, Nomatron sets each Docker task’s network_mode to the app network and records the network in the job’s metadata (nomatron.io/application-network-id), so the change is visible in the plan. On apply, Host Agents make sure the network exists on the eligible clients.
The plan is rejected if:
- the job has no Docker tasks;
- a task group sets a network mode other than
host, or a Docker task already sets a differentnetwork_mode; - the job uses managed overlay networking (a job cannot use both); or
- network validation has not passed. Validation needs healthy Host Agents with recent inventory on every eligible client.
List, Read, Update And Delete
nomatron apps networks list --organization acme --app api
nomatron apps networks read --organization acme --app api --network-id <NETWORK_ID>read prints the network as JSON, including name, mode, addressing_mode, custom_cidr, existing_network_name and job_slugs.
Update a network with apps networks update. Read the known issue below first.
Delete a network once no jobs are bound to it:
nomatron apps networks delete --organization acme --app api --network-id <NETWORK_ID> --yesDeleting a Nomatron-created network removes the Docker network from each client, and fails while containers are still attached. Deleting an existing network removes only Nomatron’s record and leaves the Docker network in place. It is also refused while containers are still attached to that network.
Known Issue: apps networks update Overwrites Settings You Do Not Pass
In Nomatron v0.1.7, nomatron apps networks update does not keep a network’s current settings for flags you leave out:
--nameis required, even if you are not renaming the network.- If you leave out
--mode, the network is set toprivate. - If you leave out
--addressing, addressing is set toautomaticand any custom CIDR is removed. - If you leave out
--job-slugs, all jobs are unbound from the network. Because the job list is always sent, every update also needs theapplication_networksbindpermission.
Workaround: read the network first, then pass every setting you want to keep.
Read the current settings:
nomatron apps networks read --organization acme --app api --network-id <NETWORK_ID>Run
updatewith the current values for--name,--modeand--addressing. Add--cidrif addressing iscustom,--existing-nameif the mode isexisting, and--job-slugswith every job that should stay bound:nomatron apps networks update \ --organization acme \ --app api \ --network-id <NETWORK_ID> \ --name backend \ --mode private \ --addressing automatic \ --job-slugs web,workerRun
readagain and check thatmode,addressing_mode,custom_cidrandjob_slugsare what you expect.
Leave out --job-slugs only if no jobs should be bound to the network.
In v0.1.7, a change to the mode or addressing of a network that already exists on clients is not applied in place, and the next deployment fails on those clients. To change either one, create a new app network, move the job bindings to it, then delete the old network.
Alternatively, use the API. A PATCH request keeps every field you leave out, including job bindings:
curl --fail -X PATCH \
"$NOMATRON_ADDR/api/v1/organizations/acme/apps/api/networks/<NETWORK_ID>" \
-H "Authorization: Bearer $NOMATRON_TOKEN" \
-H "Content-Type: application/json" \
--data '{"name":"backend-v2"}'The request body uses name, mode, addressing (an object with mode and cidr), existing_network_name and job_slugs. These names differ from the fields that read prints. To change custom addressing, send addressing.mode and addressing.cidr together.