Skip to content

Forks

Running multiple versions of a runtime with recursive forks.

Build with agents
On this page

In this guide, we will start a runtime, make some changes in it and create a fork and a child to compare.

Forking state

Fork state between agent runs.

Install the client tools and sign in

Beams is a Teleport project and uses official Teleport client tools.

The client tools include tsh to sign in and run commands, and tctl to administer your cluster if you have permission.

Cluster: example.beams.run. Edit this example to use your cluster name.

Install version 18.11.10 of the client:

Operating system
macOS

Download and open the macOS installer, then follow its instructions.

CLI
curl -O https://cdn.teleport.dev/teleport-tools-18.11.10.pkg
open teleport-tools-18.11.10.pkg
Linux

For Linux x86-64, download and install the client tools:

CLI
curl -O https://cdn.teleport.dev/teleport-v18.11.10-linux-amd64-bin.tar.gz
tar -xzf teleport-v18.11.10-linux-amd64-bin.tar.gz
sudo ./teleport/install
Windows

For Windows x86-64, run these commands in PowerShell. Add the extraction directory ($env:LOCALAPPDATA\Teleport) to your user PATH to use tsh in future terminals; the last command adds it to this terminal's PATH.

PowerShell
Invoke-WebRequest -Uri https://cdn.teleport.dev/teleport-v18.11.10-windows-amd64-bin.zip -OutFile teleport.zip
Expand-Archive -Path teleport.zip -DestinationPath "$env:LOCALAPPDATA\Teleport" -Force
$env:Path += ";$env:LOCALAPPDATA\Teleport"

Follow the official client tools install guide for other versions and architectures.

Check that you’re running v18.11.10 of the client with tsh version.

CLI
tsh version
Sign-in method
Passwordless

I sign in without a password (e.g. a passkey).

CLI
tsh login --proxy='example.beams.run' --auth=passwordless
Password & MFA

I have a password & MFA set up for my account:

Replace you@example.com with your Teleport username.

CLI
tsh login --proxy='example.beams.run' --user=you@example.com
SSO

I sign in with SSO (e.g. Okta, GitHub, SAML).

CLI
tsh login --proxy='example.beams.run'

Start a beam

This command creates a build beam. Any snapshots to it’s /home will be saved to a phase image with the same name:

CLI · Local terminal
# create a build beam workspace and associated phase with the same name
tsh phase add workspace

Save one file:

CLI · Build beam: workspace
printf 'v1\n' > ~/example.txt
tsh phase snapshot --final

--final saves the files, ends the build beam and returns you to your local terminal.

The new phase’s parent defaults to default:v1 phase image.

Create a child

Create a child of workspace:

CLI · Local terminal
tsh phase add child --from=workspace

Save without changing any files:

CLI · Build beam: child
tsh phase snapshot --final

The child’s parent phase is workspace. It follows workspace’s published images. We will revisit child later.

Create a fork

To compare, let’s create a fork of a workspace.

Fork workspace’s saved files:

CLI · Local terminal
tsh phase add fork --fork-from=workspace

Save the fork:

CLI · Build beam: fork
tsh phase snapshot --final

The fork copies workspace’s saved v1 file but keeps workspace’s parent, default:v1. It does not follow workspace.

Change the source

Let’s re-open workspace’s build beam to change the workspace phase:

CLI · Local terminal
tsh phase edit workspace

Change the file and snapshot:

CLI · Build beam: workspace
printf 'v2\n' > ~/example.txt
tsh phase snapshot --final

Fork vs child

A child keeps a parent relationship with workspace. A fork takes a one-time copy of workspace’s saved files, but keeps workspace’s parent, default:v1.

When workspace publishes v2, the child inherits that file after refresh. The fork keeps its copied v1. Both phases still follow their own parent’s updates, and existing running beams do not change.

Here is the end state:

Phase Parent ~/example.txt in a new beam after refresh
workspace default:v1 v2
child workspace v2
fork default:v1 v1
Fork vs child
default:v1
workspace Parent: default:v1
~/example.txt: v1 v2
child Parent: workspace
~/example.txt: v1 v2
fork Parent: default:v1
~/example.txt: v1
One-time file copy
Solid arrows: parent relationships. Dashed arrow: one-time file copy.

Forks only copy files, not running processes or memory. See the fork restrictions.

A fork or a child?

Goal Command Relationship
Make an independent copy of saved work tsh phase add experiment --fork-from=workspace Copies the snapshot and follows the source’s parent.
Capture current work in a build beam tsh phase add experiment --fork Copies the running filesystem into a new phase with the same parent.
Add another stage that follows a phase’s updates tsh phase add app-work --from=app-tools Creates a child of app-tools.

Search docs

Loading search and AI…

Skills

Install all available skills. All Beams and Teleport skills are hosted in our OSS Teleport repository.

npx skills add https://github.com/gravitational/teleport