Skip to main content

Configuring Service References in Sandboxes

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.


// ... imports and instantiation of the API client

SandboxFork frontendFork = new SandboxFork()
.forkOf(new ForkOf().kind("Deployment").namespace("hotrod").name("frontend"))
.customizations(new SandboxCustomizations()

// dynamic environment variable that points to address of fork of route service.
new EnvOp().name("ROUTE_ADDR").valueFrom(new EnvValueFrom().fork(
new EnvValueFromFork().forkOf(
new ForkOf().kind("Deployment").namespace("hotrod").name("route")
).expression("{{ .Service.Host }}:{{ .Service.Port }}")

SandboxFork routeFork = new SandboxFork()
.forkOf(new ForkOf().kind("Deployment").namespace("hotrod").name("route"))
.customizations(new SandboxCustomizations()

CreateSandboxRequest request = new CreateSandboxRequest()

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