Box to box
Boxes find each other as <name>.kvbox; kvbox vm link lets one reach a port of another.
Boxes are closed to each other by default. To let an app box use a database box, link them:
kvbox vm link api db --port 5432 # api may reach db's port 5432Inside api, the database is db.kvbox:5432:
kvbox exec api -- psql -h db.kvbox -U postgresNames
Every box resolves <name>.kvbox to the box of that name with the same owner. An org's box of another slug is <name>.<slug>.kvbox, and resolves only once it is linked to you. A box on another server resolves once it is linked to you too. A name is not access: without a link the connection is refused.
Names work in boxes made from base image v0.11.0 or later.
Links
kvbox vm link api db --port 5432 # one port per link; link again for another
kvbox vm links # every link: from, box, port
kvbox vm links db --json # [{from, box, port}]
kvbox vm unlink api db --port 5432 -y # open connections close too- A link is one way:
apireachesdb,dbdoes not reachapi. TCP only. - Nothing is published. The internet and other boxes still can't reach
db. - On a self-hosted server, a box made with
--localand a box made through a control plane can't be linked. - With
--org acme, the box being reached isacme's:kvbox vm link api db --org acme --port 5432. - A box other boxes link to never hibernates on its own: a connection would not wake it.
- Removing either box removes its links.
Two servers
Your boxes may be on different servers; link is the same command and db.kvbox the same name. The two servers are joined by an encrypted tunnel, and the link is the same rule as on one server, on both: only the linked port of db answers api, nothing else crosses.
- It goes through the tunnel between the two servers, a little slower than on one server. For a database you query all day, put the two together:
kvbox new api --near dbmakes a box ondb's server. dbseesapi's own address, on one server or two, so database access rules can name it.- Linking a box on another server changes that box too, so in an org you need to be allowed to change both (on one server, reading
apiis enough). - Linking the same two boxes and port again is refused while the link exists:
unlink, thenlink. - Inside
api,db.kvboxisdb's own address, and only the linked port answers there. - A box made before its server had addresses of its own is told to restart first (
kvbox vm restart api).