Skip to main content

Full Stack Previews

Overview

info

Your services need to support Header Propagation for full stack previews. Dynamic routing also needs to be setup.

Using Signadot you can test and preview the impact of a change anywhere in your stack on end-to-end flows from your frontend. You get a high degree of confidence that your change has not regressed any existing functionality. Moreover you can share previews of your change with product managers, quality engineers or user interface designers to get early feedback.

You use the Signadot dashboard or the SDKs to create ad-hoc Sandboxes by only forking the workloads that have changed. The endpoint URL is typically set to the frontend service for end-to-end Previews.

This example uses the HotROD demo application to create a Sandbox by forking 2 deployments: frontend and route.

Creating multiple forks

Creating a fork of the Route Deployment

The following code snippet shows creating a forks of the route deployment with a custom image. No endpoints are created here.

# Define the spec for the fork of route service
route_fork = SandboxFork(
# This tells the application to create a fork of route service/deployment in hotrod namespace.
fork_of=SandboxForkOf(
kind="Deployment",
name="route",
namespace="hotrod"
),
# Define the various customizations we want to apply on the fork
customizations=SandboxCustomizations(
# The image(s) we want to apply on the fork. This assumes that the updated Route service code has been
# packaged as an image and published to docker.
# Sample value: signadot/hotrod-route:540fadfd2fe619e20b794d56ce404761ce2b45a3
images=[
SandboxImage(image=cls.HOTROD_TEST_IMAGE)
],
# Environment variable changes. Here, we can define new environment variables, or update/delete the
# ones existing in the baseline deployment.
env=[
SandboxEnvVar(name="abc", value="xyz", operation="upsert")
],
)
)

Creating a fork of the Frontend Deployment

The following code snippet shows creating a forks of the frontend deployment with a custom image. An endpoint is created that points to the frontend service on port 8080.

# Define the spec for the fork of frontend service
frontend_fork = SandboxFork(
fork_of=SandboxForkOf(
kind="Deployment",
name="frontend",
namespace="hotrod"
),
customizations=SandboxCustomizations(
images=[
SandboxImage(image=cls.HOTROD_TEST_IMAGE)
],
# Environment variable changes. Here, we can define new environment variables, or update/delete the
# ones existing in the baseline deployment.
env=[
SandboxEnvVar(name="pqr", value="stu")
]
),
# Spec to create an endpoint to fork (of frontend service) serving HTTP traffic on port 8080. This requires
# a name (valid name can include alphabet, numbers and hyphens, and starts with an alphabet).
endpoints=[
SandboxForkEndpoint(
name="hotrod-frontend",
port=8080,
protocol="http"
)
]
)

Creating a Sandbox with multiple Forks

You create a Sandbox by passing in a specification as below.

# Specification for the sandbox. We will pass the spec for the forks of route and frontend services.
request = Sandbox(
spec=SandboxSpec(
description="...",
cluster=cls.CLUSTER_NAME,
forks=[route_fork, frontend_fork]
)
)


sandbox_name="sandbox-name"
try:
sandbox = cls.sandboxes_api.apply_sandbox(cls.SIGNADOT_ORG, sandbox_name, request)
except ApiException as e:
print("Exception creating a sandbox: %s\n" % e)

Waiting for the Sandbox to be ready

You loop on the readiness of a sandbox in its status until it returns true. Readiness implies that the pods corresponding to the forked workloads need to be ready in the cluster.

# Code block to wait until sandbox is ready
while not sandbox.status.ready:
time.sleep(5)
sandbox = cls.sandboxes_api.get_sandbox(cls.SIGNADOT_ORG, cls.sandbox_name)

Using the Endpoint URL

The Endpoint URL corresponding to the frontend service is retrieved from the response to the create_new_sandbox call. You can use this URL to test the application end-to-end that include the changes to the frontend and route services.

for ep in sandbox.endpoints:
if ep.name != "hotrod-frontend":
continue
print("Frontend Service endpoint URL: {}".format(ep.url))