Skip to main content
Docs

One endpoint,
every model.

Tare is an OpenAI-compatible gateway in front of every model you use — ours and the ones you bring yourself. One base URL, one key, and every token accounted for.

Upstream channelsContainers & multiple nodes

Containers & multiple nodes

What this solves: Run the Local Node in Docker, docker compose or Kubernetes, and run as many nodes as you need behind your own load balancer. Installation, registration tokens and channel settings are covered in Local Nodes.

The image and manifests here need node 0.4.40 or later.

Choosing a deployment

OptionFitsDepends on
A single containerOne machine, one nodeNothing
docker composeSeveral nodes on one machine, nginx in frontOptional Redis
KubernetesAny number of replicas in a clusterOptional Redis

Redis is the only component nodes can share, and it is optional. One node does not need it. Several nodes work without it too; the difference is described under "Load balancing and shared state". Nodes need no database and no message queue.

Building the image

The image is built from a released node version. The build files are at https://www.jamerly.ai/tare-local-node/docker/:

Code / Terminal
mkdir tare-node && cd tare-node
for f in Dockerfile compose.yaml compose.dlp.yaml nginx.conf kubernetes.yaml Dockerfile.dlp-sidecar; do
  curl -fsSLO "https://www.jamerly.ai/tare-local-node/docker/$f"
done

VERSION=0.4.40
docker build --build-arg VERSION=$VERSION -t tare-local-node:$VERSION .

The build downloads that version's release from s.jamerly.ai, checks the Ed25519 signature of the release manifest and the SHA-256 of the package, and fails if either does not match. The signature is checked against the same public key the node uses for automatic updates.

  • The image tag is the node version. Upgrade by changing the tag.
  • To push to your own registry for both amd64 and arm64: docker buildx build --platform linux/amd64,linux/arm64 --build-arg VERSION=$VERSION -t <your registry>/tare-local-node:$VERSION --push .
  • The process runs as a non-root user (uid 10001). Everything it writes is under /var/lib/tare-local-node.
  • Automatic updates are off in the image (TARE_AUTO_UPDATE=off).

Variables already set in the image:

VariableValue in the image
TARE_CONTROL_BASE_URLhttps://tare.jamerly.ai
TARE_TUNNEL_ADDRtare-grpc.jamerly.ai:443
TARE_NODE_LISTEN0.0.0.0:8090
TARE_NODE_CREDENTIALS_PATH/var/lib/tare-local-node/credentials.json
TARE_NODE_SHUTDOWN_GRACE_SECONDS300
TARE_AUTO_UPDATEoff

A single container

Code / Terminal
docker volume create tare-node-1

docker run -d --name tare-node-1 --restart unless-stopped \
  --stop-timeout 330 \
  -v tare-node-1:/var/lib/tare-local-node \
  -p 127.0.0.1:8090:8090 \
  -e TARE_API_KEY=<an inference key of your account> \
  -e TARE_REGISTRATION_TOKEN=<registration token> \
  tare-local-node:$VERSION

On first start the node redeems the registration token for its identity and writes it to credentials.json in the volume. Later restarts and new images read that file, so the token can be dropped from the command. The node is registered when the log shows tunnel connected as node … and Local Nodes in the console shows it Online.

Point the business at http://<this machine>:8090/v1 with its own Tare API key. -p 127.0.0.1:8090:8090 allows only the local machine; change the address to serve other machines. Callers that reach the port still need a valid API key.

The reason for --stop-timeout 330 is under "Shutdown and upgrades". Docker waits only 10 seconds by default, which cuts long streaming calls.

What must persist

/var/lib/tare-local-node needs a persistent volume, one per node, never shared.

FileHoldsIf it is lost
credentials.jsonThe node identity (node id and secret)The node does not start. It needs a new registration token and becomes a new node; the old one stays offline in the console until you revoke it in Local Nodes
usage-wal/Usage not yet confirmed by TareThose calls never appear in Call Traces or the bill and do not count against the key's limit. A normal shutdown sends them first; leftovers only come from a power cut or a forced kill
keys.jsonKeys kept only on the nodeChannels using those keys are skipped on this node
peer-identity.pemThe certificate for node-to-node (P2P) connectionsGenerated again at start; until the other side has the new certificate, direct calls through this node go through Tare
logs/The local request logOnly local troubleshooting is affected

When two node processes start on the same state directory, the second one exits with another tare-local-node process is using …. Two nodes sharing one identity keep pushing each other's connection off.

Several nodes

Every node is its own node identity with its own volume and registers once. Each one gets its own row in the console.

A registration token is single-use and valid for 24 hours. When several nodes share one configuration, give them several tokens, separated by commas or newlines:

Code / Terminal
TARE_REGISTRATION_TOKEN="<token 1>,<token 2>,<token 3>"

On first start each node goes down the list, skips the tokens other nodes have already used, and redeems the next one. The tokens can also live in a file (TARE_REGISTRATION_TOKEN_FILE, one per line), which is how a Kubernetes Secret is mounted. A node that already has an identity does not read the tokens; spent tokens can stay in the list.

Adding node N+1: generate a new token, add it to the list, start a new node with a new volume. The other nodes are not touched.

Removing one: stop it, revoke it in Local Nodes, then delete its volume.

docker compose

compose.yaml starts three nodes, nginx and Redis:

Code / Terminal
export TARE_NODE_VERSION=0.4.40
export TARE_API_KEY=<an inference key of your account>
export TARE_REGISTRATION_TOKENS="<token 1>,<token 2>,<token 3>"
docker compose up -d --build

The business calls http://<this machine>:8090/v1; nginx spreads the calls over the three nodes.

  • Each node has its own volume (node-1, node-2, node-3).
  • The nodes take the client address from nginx's X-Forwarded-For (TARE_NODE_CLIENT_IP_MODE=proxy, trusting only addresses in the compose network), so keys with an IP allowlist keep working.
  • stop_grace_period: 330s; see "Shutdown and upgrades".
  • Adding a node: copy a node-N block and its volume, add it to the upstream in nginx.conf, add a new token to the list, then docker compose up -d.
  • Without Redis: remove the redis service, TARE_NODE_REDIS_URL and depends_on, and switch nginx.conf to the line that hashes on the key.

Kubernetes

kubernetes.yaml is a StatefulSet with a PersistentVolumeClaim per replica, so every replica keeps its own identity and usage records.

  1. Generate one registration token per replica and fill in registration-tokens (one per line) and api-key in the Secret.
  2. Set image to the image you pushed to your own registry.
  3. kubectl apply -f kubernetes.yaml.

What the manifest already sets:

ItemValuePurpose
readinessProbeGET /readyzNo traffic before the first connection to Tare, and none while shutting down
livenessProbeGET /healthzRestart a stuck process
preStopsleep 10The Service and ingress take the pod out before the node stops accepting
terminationGracePeriodSeconds34010 + 300 + 20 + margin
PodDisruptionBudgetmaxUnavailable: 1Node maintenance evicts one replica at a time
securityContextuid / gid / fsGroup 10001Non-root; the volume belongs to the node process

Adding a replica: add a new token line to the Secret, then kubectl scale sts/tare-local-node --replicas=<N+1>. The new pod registers with an unused token.

Removing a replica: scale down first, revoke the extra node, then delete its PVC (node-state-tare-local-node-<ordinal>).

The Service exposes only 8090. Add an Ingress or load balancer the way your cluster does it, with timeouts long enough for streaming calls that run for minutes and with request and response buffering off.

Load balancing and shared state

Behind one load balancer, calls with the same key land on different nodes. For the following, one copy per node is correct:

StateWith several nodes
Session stickiness (a session stays on one channel)A hash of session and channel; every node computes the same result, so upstream prompt caches keep hitting
Channel circuit breaking and healthDecided by Tare and pushed to every node
Key checks, balance, limitsEvery node checks with Tare and caches the answer; changes are pushed to every node
Latency figures for provider.sort: latencyEach node ranks by the latency it measured itself
Rate limiting of invalid keys per sourceCounted per node, so N nodes allow N times as much

One thing needs Redis or a load balancer setting to work across nodes: replay after a client disconnects. When a client drops mid-call (a network glitch, a proxy timeout), the node does not cut the upstream call; it reads it to the end and bills it in full. If the same key sends an identical request within 30 seconds (the client's retry), the node hands it the response of that call instead of calling the upstream again. The replay is billed the service fee once more on the original call's tokens, with zero upstream cost.

On one node this happens in the node's memory. With several nodes the retry may land on another node, which does not have the original call and calls the upstream again from scratch. Two ways to handle it:

  • Use Redis (recommended). Set the same TARE_NODE_REDIS_URL on every node. A call whose client left writes its response to Redis, and the retry is replayed on whichever node it reaches. The load balancer can then use least-connections or round-robin.
  • No Redis: have the load balancer hash on the API key (the Authorization and x-api-key headers) so a key always reaches the same node. A key with very heavy traffic then uses only one node.
VariableDefaultNotes
TARE_NODE_REDIS_URLemptyredis://[user:password@]host:port/db, or rediss://… for TLS
TARE_NODE_REDIS_PREFIXtare-node:Key prefix, for a Redis shared with other applications

What goes into Redis:

  • The response of a call whose client left, encrypted, expiring 30 seconds after the call ends. The decryption key is derived from the tenant, the caller's API key and the original request; Redis never holds it, so whoever can read Redis cannot read the responses. Channels' upstream keys never go into Redis.
  • Per-second counters for upstreams with a calls-per-second limit (currently Alibaba Cloud Bailian image generation), expiring after 2 seconds. With Redis, all nodes together stay under the upstream's limit; without it each node keeps to a fixed share.

Redis needs no persistence, and a few hundred MB of memory is enough. compose.yaml runs it with --save "" --appendonly no --maxmemory 512mb --maxmemory-policy volatile-ttl. While Redis is unreachable the nodes keep serving and these two features fall back to each node's own behaviour; the log gets at most one shared state: … line a minute.

Keys kept only on the node

For channels with Keep the API key only on my node, the key is in the node's keys.json. Tare hands such a channel to any online node of the account, so every node's keys.json needs the entry.

  • docker compose: mount the same keys.json read-only into every node and point TARE_NODE_HELD_KEYS at it.
  • Kubernetes: create a Secret with one key, keys.json, and mount it with the commented-out held-keys lines in the manifest. Nodes reread it after the Secret changes, without a restart.

Channels pinned to one hosting node (subscription channels, shared local models) run only on that node; other nodes pass calls to it over P2P or through Tare. While that node is down the channel is skipped. Keep such channels on a fixed machine, not in replicas that get recreated or scaled down.

Data protection on the node

When the account has data protection (DLP) on, direct calls are scanned by a scanning service next to the node. If the node cannot reach it, the node refuses the call (503) instead of forwarding unscanned text. Without data protection the scanning service is not needed.

The scanning service listens on 127.0.0.1 only, so it has to share the node's network namespace, one per node:

  • Kubernetes: a second container in the same pod; the manifest has a commented-out dlp-sidecar. Also turn on shareProcessNamespace: true: its preStop waits for the node process to exit first, so calls are still scanned while the node finishes.
  • docker compose: compose.dlp.yaml. Each node joins its scanner's network with network_mode: service:dlp-N and depends on it, so shutdown stops the node before the scanner. Ports and the network belong to the scanner container.

Build the scanner image from Dockerfile.dlp-sidecar (docker build -f Dockerfile.dlp-sidecar -t tare-dlp-sidecar:stable .); it is linux/amd64 only. Give each scanner 1 GB of memory, or 2 GB with person, place and organization detection on (TARE_DLP_SIDECAR_HEAP=2g). Those three types use a model of about 180 MB that is downloaded to /tmp on first use; a volume on /tmp saves the download on every recreate.

Health checks

PathAnswersUsed for
GET /healthz200 while the process is upLiveness probe
GET /readyz200 once the node has connected to Tare; 503 before the first connection and after a shutdown signal, with the reason in the bodyReadiness probe, load balancer health check
GET /metricsPrometheus metrics on a separate port (TARE_NODE_METRICS_LISTEN, e.g. 0.0.0.0:9464)Monitoring

After the first connection, /readyz stays 200 even if the connection to Tare drops: the node keeps serving from the last push and its cache (see "The node is up, but it cannot reach Tare" in Local Nodes). The tare_node_tunnel_connected metric is 0 at that point; alert on it.

The image has a Docker HEALTHCHECK that runs tare-local-node healthcheck (it asks the local /readyz), so docker ps shows healthy. /healthz and /readyz need no API key and /metrics has no authentication; keep them off the public internet.

Shutdown and upgrades

On SIGTERM the node exits in this order:

  1. /readyz answers 503 at once.
  2. With TARE_NODE_DRAIN_DELAY_SECONDS set, it keeps accepting new requests for that many seconds so the load balancer can take it out.
  3. It stops accepting new connections. Calls already running continue for up to TARE_NODE_SHUTDOWN_GRACE_SECONDS (300 in the image); whatever is still running then is cut off.
  4. It sends usage not yet confirmed by Tare, for up to 20 seconds. Anything left stays in usage-wal/ and is sent on the next start.
  5. It disconnects from Tare and exits.

With no calls running, step 3 ends at once and the node exits within seconds.

The platform's kill deadline has to be longer than all of these together:

PlatformSettingValue in the examples
docker run--stop-timeout330
docker composestop_grace_period330s (5 + 300 + 20 + margin)
KubernetesterminationGracePeriodSeconds340 (preStop 10 + 300 + 20 + margin)

TARE_NODE_DRAIN_DELAY_SECONDS is for load balancers that take nodes out by polling /readyz; the compose example uses 5. In Kubernetes the sleep 10 in preStop does the same job, so leave it unset there. To wait longer for long calls, raise TARE_NODE_SHUTDOWN_GRACE_SECONDS and the platform deadline together.

Upgrading means changing the image tag:

  • Kubernetes: change the StatefulSet image. Replicas roll one at a time; the next one is replaced only after the previous one is ready.
  • docker compose: change TARE_NODE_VERSION, rebuild, and replace the nodes one at a time so they do not all stop together: docker compose build, then docker compose up -d --no-deps node-1, wait for it to be healthy, then node-2, and so on.
  • A single container: start a new container from the new image on the same volume after stopping the old one.

The node identity and usage records are in the volume, so a new image does not register again. Do not turn automatic updates on inside the image: they replace the file inside the container, and the next recreate goes back to the image's version.

Sizing

A node mostly waits on upstreams and uses little CPU. Memory and disk go to:

  • Memory: responses waiting to be replayed after a client left stay in memory, at most 32 MB each and 512 MB in total, normally close to zero. The examples request 256 MB per node with a 1 GB limit.
  • Disk: the local request log takes up to 2048 MB by default; the examples lower it to 1024 MB (TARE_NODE_LOG_MAX_TOTAL_MB) on a 2 GB volume. The log and the usage records share the volume, so the log cap has to leave room for the usage records.
  • Scanning service: 1 to 2 GB of memory each, see above.
  • Redis: 512 MB is enough.

Troubleshooting

SymptomCause and fix
Exits at start: no credentials at … and TARE_REGISTRATION_TOKEN is not setThe volume has no identity and no token was given. Give a token; for a node that registered before, check that the volume is mounted
Exits at start: none of the N registration token(s) was acceptedAll tokens are used or expired (24 hours). Generate a new one and add it to the list
Exits at start: another tare-local-node process is using …Two nodes mount the same volume. Give each node its own
Exits at start: cannot store credentials at …The volume is not writable by uid 10001. In Kubernetes set fsGroup: 10001; in Docker use a named volume or chown 10001:10001 the host directory
/readyz stays 503 waiting for the first connection to TareThe node cannot reach tare-grpc.jamerly.ai:443. Check outbound firewall rules and proxies, and the tunnel connection ended: … lines in the log
One node flips between online and offline in the consoleTwo processes use the same credentials.json (copied from one volume, for example). Every node needs its own identity
After a retry the upstream was called twice and billed twiceReplay is not shared between the nodes. Set TARE_NODE_REDIS_URL, or hash on the API key in the load balancer
shared state: … in the logRedis is unreachable or slow. Nodes keep serving; replay and rate limiting fall back to each node's own behaviour for now
A channel with a key kept only on the node returns 503 now and thenSome nodes' keys.json lacks the entry; their log has channel N skipped. Mount the same keys.json on every node
Every call is 503 after turning on data protectionThe scanning service is missing, or not in the node's network namespace. See "Data protection on the node"
Streaming calls are cut during a rolling upgradeThe platform's kill deadline is shorter than TARE_NODE_SHUTDOWN_GRACE_SECONDS plus 20 seconds, or Docker is on its default 10 seconds. Adjust per the table in "Shutdown and upgrades"
Docs last updated Nov 27, 2026, 12:56 (UTC+8)