temperwork Blog Documentation
Guides

Environments and enrollment tokens

An environment is where your work runs. You add your own on the Environments page, and your workers join it with an enrollment token. This guide covers adding and managing an environment, what tokens are for and how to make them, and revoking a token, a worker or a whole environment.

Environments

Every organization has temperwork, the default environment: temperwork's own queues, GPUs and storage. Everything runs there unless you add your own. Your own environment is queues and buckets in your AWS account, and workers you run (Where your data lives).

A run goes to the environment its datasets are in: a dataset added from your bucket runs on your workers, an uploaded one on temperwork's.

Add an environment

An org's owners or admins choose Add environment on the Environments page, then apply the Terraform module and copy its output into the form, as Running on AWS describes. Test on the card checks the queues and the control bucket.

The environment's card shows its whole configuration: queues, buckets, the role temperwork signs in with, and its Certificates. Its ⋯ menu has Test, Edit, Turn off (nothing new runs there until you turn it on; what is running goes on), Make an enrollment token and Delete.

Adding an environment also makes its own certificate, which signs every worker certificate in it. That is the only time one is made.

Enrollment tokens

Your workers run in your account, but temperwork must know a worker is yours before it gives it work. An enrollment token is how a new worker proves that. On its first start the worker sends the token, and gets back a certificate of its own, signed by the environment's certificate. From then on it uses the certificate, not the token.

How a worker joins: the environment's certificate signs a worker certificate, given for an enrollment token; the worker asks for a lease every 5 minutes and takes work only while it holds one
How a worker joins: the environment's certificate signs a worker certificate, given for an enrollment token; the worker asks for a lease every 5 minutes and takes work only while it holds one

Every 5 minutes the worker asks temperwork for a lease on its certificate, which lasts 15 minutes. It takes work only while it holds one. If temperwork can't be reached, the worker finishes out its lease, then waits and asks again. A certificate lasts a year, and the worker renews it by itself before it ends.

In a personal organization you make and revoke tokens; in a shared one, its owners and admins do, and every member sees them.

Make a token

On the environment's card, ⋯ → Make an enrollment token:

Make an enrollment token: a name, how many days it is good for, and how many enrollments it allows
Make an enrollment token: a name, how many days it is good for, and how many enrollments it allows
  • Name: what the token is for, such as the workers that will use it.

  • Good for (days): 1 to 90, 7 by default. After that it enrolls no one.

  • Enrollments it allows: how many workers may enroll with it, or 0 for any number.

Make shows the token once, with every setting your workers start with. Copy it then: temperwork keeps only a hash of it.

The token, shown once, with the settings a worker starts with
The token, shown once, with the settings a worker starts with

Give these settings to your workers. With the module, put the token in the SSM parameter it names (enroll_token_parameter), which its workers read when they start. Treat the token like a password: anyone who has it can enroll a worker into your environment until it expires or you revoke it.

Which settings to choose

  • Workers that keep their disk (an EC2 instance, a server) enroll once and keep their certificate. A token with a short life and as many enrollments as you have workers is enough.

  • Workers that start fresh each time (autoscaled instances, pods with no lasting disk) enroll on every start, each time with a new certificate. Give them a token with any number of enrollments, and make a new one before it expires.

Revoking

Each line under Certificates on the environment's card (the environment's certificate, its tokens and its workers) has Revoke in its ⋯ menu, with an optional reason. A revoked one is marked revoked.

An environment's certificates: its certificate, a token, and a revoked token
An environment's certificates: its certificate, a token, and a revoked token
RevokeWhat happens
A tokenNo new worker can enroll with it. Workers that already enrolled keep working.
A workerIt gets no more leases and stops within 15 minutes (at once if it asks meanwhile). It can't come back without enrolling again with a token.
The environment's certificateEvery worker in the environment stops within 15 minutes, its tokens enroll no one, and no new token can be made.

Revoking can't be undone. Delete on an environment revokes its certificate too. If you add the environment again it gets a new certificate, and its workers need a new token to enroll.

When to revoke what:

  • A token leaked, or you no longer need it: revoke the token and make a new one. Running workers are not affected.

  • A worker's machine was lost or compromised: revoke that worker.

  • You are done with the environment, or don't trust any of its workers any more: delete it, or revoke its certificate.

On this page