Definitions and deployments
A service definition supplies reusable image and runtime configuration. A deployment declaration instantiates it as a service in the target project, named by the declaration. Several declarations can instantiate one definition, each as its own service. Deploying the project includes the service of every deployment declaration. A service’s replicas are its running containers. Its identity persists across replica replacements and deployment versions. Stateless services can run multiple container replicas behind the same service identity. A singleton service runs at most one replica at a time: during replacement, the previous replica stops before its successor starts. Data that must outlive a replica is written to a volume bound to the service.Required and optional configuration
A start command is split into arguments with shell-style quoting, and its
first argument is executed directly.
Build source
A build source identifies the source tree, build context, Dockerfile, and target stage. Each setting has a default:
Paths are relative and checked lexically:
root must stay within the
defining package directory, and context and dockerfile within the root.
In a workspace, each included manifest keeps its own source directory, and its
build context stays within that package.
Networking and endpoints
Within its project, a service is addressable by its name, such ascache, on
any port its application listens on; internal communication needs no port
declarations. A service is private to its project until it declares a public
endpoint.
The application chooses its listen port, and each public endpoint names that
port. An application that reads PORT gets it from a declared
environment variable.
Public endpoints
A public endpoint forwards incoming traffic to the application’s listen port. Endpoints are declared with the service’s deployment declaration, independently of its reusable definition.
Public exposure is optional. Each requested endpoint specifies:
Each service can have one
http and one tcp endpoint, on ports 1–65535.
Environment and references
Environment variables provide runtime configuration to a service’s containers. Their values can refer to the service’s own configuration or to another service declared in the same package. The platform resolves declared values when the deployment is created and injects them at container start. Other environment defaults are the image’s own. Environment configuration is optional. Each declared variable requires a name and a plaintext string value, optionally containing references. Names match^[A-Za-z_][A-Za-z0-9_]*$; host is reserved for the builtin reference.
A service accepts at most 64 declared variables, with names up to 128
characters and values up to 4096 characters.
Declared values are stored with the deployment as written, and the dashboard
shows the serving deployment’s values. Changing a declared value deploys a new
version.
References
A reference’s scope names a service, independently of its definition name.${{self.VAR}} names a variable on the declaring service.
The one builtin, host, is the referenced service’s internal hostname, which
is its name: ${{cache.host}} is cache.
References have this grammar:
self remains bound to the
service that declared each value. Every ${{ opener must form a valid
reference.
Resolution
References toself must name a builtin or a declared variable. Composition
checks references to the other services declared in the package against their
declared variables and builtins. Unknown names, cross-package
references, and ungrounded value-reference cycles fail locally.
Remote references use services with a serving deployment. For those services,
host supplies the internal hostname without requiring a running replica;
a custom-variable reference requires that variable in the service’s resolved
environment.
A reference resolves when the declaring service’s version is created,
against the services serving at that moment, and the resolved values stay with
that version. A deployment compares a service’s declared values as written,
so a reference whose value changes elsewhere leaves the declaration unchanged:
the service picks up a new or changed value from another service with its own
next new version, which a change to its own declaration makes. A variable whose
referenced service is not yet serving is omitted with a warning and filled in
by that new version.
Size
A service’s size sets the CPU and memory of each of its containers. The vCPU count is a ceiling on the node’s shared CPU, and it sets the container’s process limit at 4096 per vCPU. Memory is a hard limit for the container’s processes together: past it, a process is OOM-killed. Each replica’s memory is reserved on the node that runs it, so a replica is placed only on a node with that much memory unreserved. The size belongs to a deployment version: a deployment that declares another size makes a new version, one whose declaration omits a value keeps the service’s current value, and a new service gets 1 vCPU and 512 MiB. A version deployed before sizing runs with 1 vCPU and 256 MiB; a new version that omits memory moves it to 512 MiB. A replica that no node has room for waits with its instancestarting, and
its deployment stays in progress until a node has room. Deleting the service
always ends the wait. A replica count set in the dashboard replaces a waiting
change to the serving version’s count, so a lower count that fits ends that
wait. A new singleton deployment replaces the waiting one; a new stateless
deployment replaces it only once the new version is running, so it needs room
beside the serving version and any replicas the waiting deployment has
already placed. A stateless deployment needs room for its new version beside
the previous one. A singleton’s previous replica stops first, so the service
can stay stopped until room appears, even at the same size, when replicas
already waiting take the freed room first.
YAML composition example
In YAML composition,type: service selects
stateless execution and type: singleton selects singleton execution. Exactly
one of image or build supplies the container source; image: "" counts
as absent. Optional configuration uses env, the start_command string,
the vcpu and memory_mib integers, and the volumes list. env maps
variable names to string values. A vcpu or memory_mib that is not an
integer fails locally; one outside its
range is rejected at deployment.
build accepts a string naming the build root or an object containing the
build fields above. An empty string selects the default root; build: null
is invalid. Each build root is relative to the directory containing its
definition’s uniac.yaml.
A deployment declaration’s optional replicas is an integer. Omitted or
null, the service keeps its current count on deployment.
A deployment declaration’s public_ports is an optional list of mappings,
each with port and type. It states the service’s whole public exposure on
deployment:
The
web-code and cache-code resources are definitions, and the web and
cache deployment declarations instantiate them as the services web and
cache. The from field connects each declaration to its definition in this
package.
The stateless web service runs two replicas and receives the URL declared by
cache, which uses cache’s own internal hostname. The web service’s port
8080 is exposed through HTTPS and a separately allocated raw TCP endpoint. The
singleton cache service starts Redis with 1024 MiB of memory and
append-only persistence on a 1 GiB volume mounted at /data.
container.source.ref for image and
container.source.build for build. type: singleton adds kind: singleton,
while type: service omits kind. Build paths are normalized and omitted at
their defaults; an all-defaults build is {}.
Runtime and deployment versions
In live state, a deployment is a version of one service, with its own lifecycle and running containers. Redeploying a declaration updates its service, and a service keeps its execution type across versions; a deployment that changes the type is rejected. Eachuniac deploy compares every declared service’s declaration, as
written, with the service’s newest version:
A new version runs the declaration’s
replicas count. Without one, it keeps
the requested count of the serving version, or of the newest active version
when none is serving, including zero; a service with neither starts with one
replica. The new version replaces the running replicas; a singleton’s previous
replica stops first.
A deployment succeeds once the platform has started the containers it adds and
stopped and removed those it replaces or drops. It does not judge how the
application runs: a container that exits after it starts does not fail the
deployment, and its instance status shows the exit. A deployment
whose container cannot be started fails. A deployment to zero replicas
completes once the containers are removed.
Instances
Each replica runs as an instance. An instance ishealthy while its
container’s process runs, and it receives new connections only while it is
healthy; connections that arrive before the application listens on its port
are refused. The platform restarts a container whose process exits, and the
instance is unhealthy until the process runs again. After five consecutive
restarts that each ran for less than a minute, the container stays stopped
and the instance is failed.
An instance also reports when its container started.
Each instance has a key, a UUID the platform assigns, which it keeps for its
life. The platform can move an instance to another node, and the instance
keeps its key. A new deployment version, a size change, a scale-up and the
replacement of a
failed instance start instances with new keys.
Logs
The platform keeps what each instance writes to stdout and stderr, line by line, with the stream and the time the platform received the line. A run is one start of the instance’s container: its first start, a restart after its process exits, and a restart after its node reboots. An instance keeps its current run, which is the latest, and the run before it. Both are kept across restarts and while the instance isfailed. Each run keeps its last 8 MiB of
output. An instance whose container never started has no run.
Logs belong to the instance’s placement on its node and are removed with it:
when a deployment replaces the instance’s version, when a scale-down, a pause
at zero replicas or the service’s deletion removes the instance, and when the
platform replaces it after it is failed. When the platform moves an instance
to another node, the instance’s runs start over there.
Exec
An exec runs one command in a running instance’s container and returns the command’s output and outcome. The command runs as the container’s own process: the image’s user, the instance’s environment and the image’s working directory, with the container’s capabilities, no-new-privileges, seccomp and AppArmor, and without a terminal. Its CPU, memory and processes count against the instance’s size, so a command that exhausts memory can stop the instance’s own process.
At the timeout, and when the caller disconnects, the command’s own process
receives SIGTERM and, 5 seconds later, SIGKILL. Processes it started are not
signalled and keep running in the container: the other commands of a shell’s
pipeline or script, and processes it leaves in the background. Output they
hold open is read for at most 2 seconds after the command exits.
An exec ends with one of these outcomes, unless its stream is cut first, as
when a platform component on its path restarts; the platform then stops the
command as it does on a disconnect, and no outcome is reported:
After
timeout and container_stopped, the outcome carries the status the
command ended with when the platform observed it. An exec runs only while the
instance’s container is running; in an instance that is starting,
unhealthy, failed or terminating, it is refused with that state. Each
exec runs its command once, so running it again runs the command again. When
the platform cannot run an exec at the moment, it refuses it, and the refusal
can follow a command that started and was stopped.
The platform records every exec for its operators: who ran which command and
how it ended. The command’s standard input and output are not recorded.
Terminal
A terminal runs a program interactively in a running instance’s container, over one connection. The program runs as an exec’s command does, with the instance’s environment andTERM=xterm, and its CPU, memory and processes
count against the instance’s size. A pseudo-terminal of the
requested size is its standard input, output and error: Ctrl-C is a byte the
terminal turns into SIGINT for the program in the foreground.
A terminal ends when its program exits, after 15 minutes without input,
after 1 hour, or when its connection closes or is lost, including through the
platform’s own updates and after 45 seconds without any message from the
client. The program then receives SIGHUP, and SIGKILL 5 seconds later.
Processes it leaves in the background keep running. Nothing resumes a
terminal; run
tmux or screen inside the container to keep a session
across connections.
A terminal ends with one of these outcomes, unless its connection closes
first; the platform then stops its program, and no outcome is reported:
A terminal runs only while the instance’s container is running; in an
instance that is
starting, unhealthy, failed or terminating, it is
refused with that state. It is also refused at either cap, for a command
over 512 bytes or a size out of range, and when the platform cannot start it
at the moment. That last refusal can follow a program that started and was
stopped.
The platform records every terminal for its operators: who opened which
program, its size, and how it ended. What was typed and the output are not
recorded.
Observed state
Dashboard and removal
A service’s dashboard page shows its state, public endpoints, deployment activity and resource usage. It sets the replica count (0 to 4 for a stateless service, 0 or 1 for a singleton), which later deployments keep unless their declaration setsreplicas. It also changes public endpoints, which the next
deployment replaces with its declaration’s public_ports, and offers
Delete service, confirmed by typing the service’s name.
The project’s Logs page, beside its graph, shows a service’s
logs for one instance or all of them: Follow adds output as it
is written, and Previous run shows the run before the current one. A
service’s Console opens a terminal in an instance, running
bash where the image has it and sh otherwise. A terminal lasts while the
service’s window stays open; choosing another instance ends it and opens one
there. After a terminal ends, New terminal opens another.
Deleting a service stops its replicas and removes its deployments, images and
public endpoints. The service reports terminating until the removal
completes, and is then gone. Its volume is unbound and keeps its data; the
volume lifecycle governs its retention and
deletion.
