Lease a workstation from a pool
Create a workstation pool, lease one of its workstations for a build, connect to it, and hand it back.
Create a workstation pool, lease one of its workstations for a build, connect to it, and hand it back. Use it when a CI job, a script or a person needs a workstation and shouldn’t wait the minutes a new one takes to build. You can also have the pool clean a workstation and keep it for the next lease instead of deleting it, which takes an edit to the pool’s declaration.
Prerequisites
- Install Ringleader, with the Ringleader application running.
- A cloud workstation to copy as the pool’s template, in the namespace the pool will live in. Cloud workstations (GCP, AWS, Azure) says how to build one.
- The right to lease from the pool. A pool’s owner has it, and Access for a lease holder says who else can.
- The examples use a template workstation named
app-boxin the namespaceacme-dev, a pool namedagents-linuxand a lease namedmy-build. Replace them with your own.
Create a pool
Create a pool whose template is a copy of the workstation’s configuration. This pool builds up to eight members, which are the workstations it owns, and keeps two idle ones running:
rl workstationpool create agents-linux --from-workstation app-box --size-max 8 --warm-running 2 -n acme-devThe command prints the pool it created. On stderr it prints a note that names what it left out of the template. Every lease holder can read the template, as Pool template and owner explains.
Lease a member
A lease is a request for one member. The pool binds a member to your lease as soon as one is available, and the member is yours until you release the lease. On a new pool, the first lease waits while a member builds, which takes minutes. Later leases take an idle member.
Request a member and wait for it:
rl workstationpool lease agents-linux --name my-build --wait -n acme-devWhen the lease is
Ready, the command prints the lease and its member, such asworkstationpoollease/my-build Ready on agents-linux-e5f6a7b8. The lease carries your device’s SSH key.Open a shell on the member, with the member’s name from step 1:
rl shell <member> -n acme-devOptional: If your build runs longer than the lease, renew it before it ends:
rl workstationpoollease renew my-build --expires-in 4h -n acme-devRelease the lease when you are done:
rl workstationpoollease release my-build -n acme-devThe pool deletes the member.
If that’s all you need, you are done. The next task has the pool clean a member and keep it, and the last one deletes the pool.
Recycle members between leases
By default the pool deletes every released member. With a recycle block, a member goes back
to the pool after a cleanup, and the next lease takes it. A recycled member keeps whatever its
last holder left, as
Member recycling
explains.
Open the pool in your editor:
rl workstationpool edit agents-linux -n acme-devAdd a
recycleblock underspec:spec: recycle: maxReuses: 20 # after this many recycles the member is deleted instead timeout: 10m # a recycle that takes longer deletes the member reboot: false # true stops and starts the member after the scriptsOptional: Declare the cleanup you need as
onRecyclescripts in the template, as Setup scripts describes.Save the file and close the editor. Ringleader applies the change to the pool.
Lease a member again, because the last task released
my-build:rl workstationpool lease agents-linux --name my-recycle --wait -n acme-devRelease the lease with
--recycle:rl workstationpoollease release my-recycle --recycle -n acme-devThe pool cleans the member and keeps it for the next lease. When it can’t recycle the member, it deletes it instead.
Optional: Delete the pool
A pool that keeps idle members running costs money until you delete it. Delete the pool when you are done with it:
rl workstationpool delete agents-linux -n acme-devThe command asks you to confirm, because it deletes each member’s virtual machine and disk. Delete a pool says what happens to a member that is still leased.
Troubleshoot
- If the lease stays
Pending, runrl workstationpoollease describe my-build -n acme-dev.status.messagesays what the lease waits for, and Pool leases says how the pool picks a member. - If the lease goes
Failedwith the reasonExpired, nobody renewed it before itsexpiresAt, and the pool deleted the member. Lease another member, and renew before the lease ends.
Next steps
- Pools and leases says how a pool picks a member, keeps idle members, and takes a member out of service.
rl workstationpoollists the pool and lease commands and their flags.- Lease spec fields lists the fields of a lease, for a program that writes its own leases.
- SSH keys for outbound Git lets a member clone private repositories with your key.
- Scripts, files and services
declares the
onRecyclescripts that clean a member.