Add a public port to a Workload
Continues from Deploy a Workload from a public image. It uses the api helper from that guide, plus PROJECT_ID and SERVICE_ID. Read Public ports and HTTPS endpoints to choose between the two kinds.
Code
API status
The endpoint routes are used by the console and are tagged console-only in the API reference. They accept your session token or an API token.
A raw TCP or UDP port
Say which port your app listens on inside the container (internal_port) and which protocol. Zaroz assigns the public address and number.
Code
Code
Code
The response carries id, public_ip, public_port and state (active once open). Use "protocol": "tcp_udp" for one public number on both protocols. Raw ports are billed by the hour they are held; a Workload's plan includes none free (see Billing).
If the service is not running yet, the request is refused with not-ready. Wait for the deployment, then retry.
Several units: one shared port, or one per unit
The port above is one address for the whole Workload. If you scale it to several units, new connections to that same address are spread across every ready unit, on whichever server each one runs, and one client keeps reaching the same unit while the set of units stays the same. You do not change anything when you scale. How units join and leave the port is on Public ports.
When a client must reach one particular unit, open a per-unit port instead, with "kind": "unit". Every unit that exists gets its own public address and port for that container port, and a unit added later gets its own:
Code
Code
Code
Each unit's public_endpoints lists its public_ip and public_port, which stay the same across the unit's restarts. In the endpoint list, each per-unit port carries the unit_ordinal it belongs to. Every per-unit port is billed like a port, so four units are four ports, and removing one removes that container port from every unit. A per-unit port is added to a running service; it cannot be asked for at purchase.
A free HTTPS endpoint for a website or API
Your app serves plain HTTP on internal_port; Zaroz handles TLS.
Code
Code
Code
label is optional and picks the first part of the free host, <label>.zone.<zone>.zaroz.cloud. To serve your own domains too, send "domains": ["www.example.com"]; each must be a domain your organization has verified, or a subdomain of one. If one is refused, nothing opens.
List and close
Code
Code
Code
The list shows pending ports first, then every port the service ever held, newest first. A closed port stays listed with its last address so you can match a month's invoice against it. Closing stops billing from that moment.
When it is refused
The details of a refusal begins with a code before the colon: not-ready, port-limit, port_in_use, no_address_available, no_port_available, internal_port_out_of_range, protocol_required, and for HTTPS host_taken, domain_not_verified and others. The full list is in Public ports and HTTPS endpoints.
Units inside your project reach each other without any public port, by private names.
