Skip to content

Configuration Sources

Besides the API, streams can be managed from two further sources. All of them change the same set of streams.

File Sync

./tram server --enable-file-sync --config-directory config

Every <name>.json file in the directory describes one stream, in the same format as the API request body ({"stream": {...}}); see setup/config/ for examples. The file name, without .json, is the stream name. The sync works in both directions:

  • Adding, changing or deleting a file creates, updates or deletes the stream
  • Streams created or changed through the API or the Kubernetes operator are written to files (new files are readable only by the owner, mode 0600), and deleted streams have their file removed
  • Streams without a file are deleted when the directory is synced
  • A stream that cannot be created or updated, e.g. because NATS is not reachable yet when Tram starts, is tried again without its file changing: after 1 second, then with a delay that doubles up to 30 seconds, until every stream is applied. Changing a file starts over with the shortest delay. A stream that keeps failing is logged once a minute; one that is applied after failing is logged once more. A file that is invalid for good is tried again as well, so fix or remove it

Kubernetes Operator

kubectl apply -f internal/adapters/k8scrd/config/crd/bases/io.tram.core_streams.yaml
./tram server --enable-k8s-operator

The operator watches Stream resources (io.tram.core/v1) and runs each as a stream named <namespace>.<name>. It uses the in-cluster configuration or the current kubeconfig context; --kubeconfig selects another file. By default every Tram instance runs every Stream resource in the cluster; --watch-namespace and --stream-selector limit an instance to some of them, e.g. to run different streams in several Tram deployments. See setup/k8s/ for an example and the operator documentation for details.