Skip to content
DocsAll docs
Console

Desk capsules

Run short-lived capsules in a desk, so that their command reaches the services of its environment.

Last updated

On this page

Overview

A capsule is a disposable container that runs one command or one shell and is deleted when it exits. See Capsules. A capsule created through a desk is part of that desk from its start. The desk manages it, like the other workspaces of the desk.

ItemCapsule in a desk
CreatedThrough the desk, with desks create-capsule.
EnvironmentThe services of the desk environment resolve by name inside the capsule. A desk is the only way to reach an environment.
UseA running capsule keeps the desk in use.
EndedWhen its command exits, at its time limit, by an end request, or when the desk is deleted. It cannot start again.
Direct controlRefused with 409. Use the desk.

A capsule is for one run. It is not stopped or started with the desk. It runs until it ends, and its files are gone with it. An ended capsule cannot start again. To run again, create a new capsule.

Environment access

A capsule reaches the environment that the desk is connected to. A capsule created from a copy of a workspace does not inherit the desk of that workspace.

A capsule does not intercept services. Only a workspace takes over a service. See Intercepts.

Use with workspaces

TaskWorkspaceCapsule
Edit code and keep itYes. The home is kept.No. Files are gone at the end.
Run a test or a script against the servicesYes.Yes. The script is the command.
Run many runs in parallelSlow to prepare.Yes. Each run has its own new capsule.
Receive the traffic of a serviceYes, with an intercept.No.

Quota

A running capsule counts against the owner's quota with the CPU, memory, and disk that it asks for. The record of an ended capsule stays for 90 days.

Tasks

Run a capsule in a desk

Reason for the task

Run a command that needs the services of the desk environment, without a workspace.

Job set-up

Procedure

  1. Create the capsule through the desk. The team is the team of the desk.

    Python
    sb = kl.desks.create_capsule(desk="acme/review", cmd=["python3", "test.py"], timeout_s=600)
    TypeScript
    const sb = await kl.desks.createCapsule({ desk: "acme/review", cmd: ["python3", "test.py"], timeoutS: 600 });
    Go
    sb, err := kl.Desks.CreateCapsule(kloudlite.CreateDeskCapsule{Desk: "acme/review", CreateCapsule: kloudlite.CreateCapsule{Cmd: []string{"python3", "test.py"}, Timeout: 600 * time.Second}})if err != nil {    log.Fatal(err)}
    Ruby
    sb = kl.desks.create_capsule(desk: "acme/review", cmd: ["python3", "test.py"], timeout_s: 600)
    Java
    var sb = kl.desks().createCapsule("acme/review", new Kloudlite.CreateCapsule().cmd(List.of("python3", "test.py")).timeout(Duration.ofSeconds(600)));
    CLI
    kode desks create-capsule --desk acme/review --timeout-s 600 -- python3 test.py
  2. Wait for the command to exit, then read its output as in Run a command.

Close-out

  1. Make sure that the capsule is in the list of the desk's workspaces.
  2. Make sure that the capsule ends when the command exits, at its time limit, or with the desk.

Troubleshooting

SymptomPossible causeCorrective action
409 with {id} is managed by desk {name}; use the deskThe call ends or deletes a capsule that belongs to a desk.Delete the desk, or wait for the time limit of the capsule.
A service name does not resolve in the capsuleThe desk has no environment, or the environment is stopped.Connect an environment to the desk. Wait until the environment runs.
The capsule is terminated and does not answerA capsule runs once. The command, a time limit, an end request, or the end of the desk ended it.Create a new capsule.
422 with create a desk's capsule with POST /v1/desks/{id}/capsulesThe call is POST /v1/capsules with desk.Create the capsule through the desk, as in the task above.
404 with not found for deskThe desk is not yours, or is in another team.Check the name. Use team/name for a team.