Article · 3 min read · Getting started
kubespin: Servers that join by themselves
For ephemeral servers that can be replaced easily, such as scale sets and autoscaled VMs: a join key in cloud-init adds each new machine to kubespin with no code to type.
For ephemeral servers that can be replaced easily, such as scale sets and autoscaled VMs: a join key in cloud-init adds each new machine to kubespin with no code to type.
Make a join key
- Go to Servers › Auto-join and choose New join key.
- Give it a name, such as “web spot fleet”.
- Choose the group its servers join, for example
web-spot. - Choose how long it works: 1 hour, 1 day, 7 days, 30 days, 90 days or no expiry.
- Optionally limit how many servers it may add, and the networks they may come from (a CIDR range, such as your VPC’s public range or a NAT address).
The key (it starts ksj_) is shown once, with a cloud-init snippet and the same as a shell script, ready to copy. kubespin keeps only a hash of it.
Use it in cloud-init
The snippet kubespin fills in looks like this:
#cloud-config
write_files:
- path: /etc/kubespin/join-key
permissions: "0600"
content: ksj_…
runcmd:
- curl -fsSL https://kubespin.io/api/v1/cli/install | sh
- kubespin register --key-file /etc/kubespin/join-key --slot "$(hostname)"
The key goes in a root-only file, and the command deletes it once the machine has joined.
User data can be read from inside the instance, so give keys a short expiry, a server limit and a network range.
Groups and slots
- A group is a set of servers that stand in for each other. An app put on a group’s server belongs to the group: if its server goes, the app waits for the group’s next server.
- A slot (
--slot NAME) names the place a machine fills, such asweb-1. A new machine with the same slot as a server that’s gone takes its place and its apps. - A machine with no slot picks up all the group’s apps that are waiting for a server.
Ephemeral groups
Mark a group ephemeral for servers that come and go. Its servers are retired by themselves once they’ve been silent for 10 minutes, their apps wait for the group’s next server, and you get one notification.
An app moved this way starts from its settings. A stateless app loses nothing. An app with data starts empty on the new machine, and its page says so.
What a key can and can’t do
A join key can only add a machine to its own group, as your server. It can’t read or change anything else. Each use is recorded on the key’s page: when, from which address, the hostname and the server made. Revoke stops it at once; servers already joined keep working.
Plan limits still apply. See kubespin: Acceptable usage limits.
Planned
- Requiring an AWS instance identity document with the key.
- Reacting to AWS’s two-minute spot interruption notice.
- Restoring an app’s newest off-server backup when it moves to a new machine in a group.