Skip to main content

Sandbox Service References

A sandbox may contain one or more forked workloads within itself. In some cases, it may be desirable to have one forked workload be configured dynamically to reference the other. This document details how this can be done using Signadot Sandboxes.

For configuring references to one fork from another, we make use of dynamic expressions. These expressions are special values that can be specified as one of the environment variables on a fork. At runtime, these values are computed and made available to the forked workloads.

Usage

# file: cross-forks-refs.yaml
# usage: signadot sandbox apply -f cross-fork-refs.yaml
name: cross-fork-sandbox
spec:
cluster: ...
forks: # create 2 forks, "frontend" and "customer"
- forkOf:
kind: Deployment
namespace: hotrod
name: frontend
customizations:
images:
- image: frontend:dev
- forkOf:
kind: Deployment
namespace: hotrod
name: customer
customizations:
env:
name: FRONTEND_DEV
valueFrom: # set FRONTEND_DEV env var to the host:port of the forked frontend workload.
fork:
forkOf:
kind: Deployment
namespace: hotrod
name: frontend
expression: "{{ .Service.Host }}:{{ .Service.Port }}"

In the example shown above, there are two services being forked called frontend and route. We are adding a dynamic environment variable parameter to the fork of the service frontend that points dynamically to the address of the forked service called route. In this case, we can expect to find the environment variable named ROUTE_ADDR that will point to the address of the forked route service within the same sandbox at runtime. The dynamic expressions that can be used are documented below.

Template VariableResolves To
{{ .Service.Host }}DNS host name of the specified forked workload
{{ .Service.Port }}First container port of the specified forked workload