Shared deployments
Let several people take turns on one deployment, such as a shared staging namespace, with claims, a waiting line, hand-overs and an end time.
Some environments are too costly to copy for every branch: a staging namespace with a database, a QA cluster, a demo. A shared deployment is one deployment that people take turns to use. Whoever holds it chooses the branch it follows and for how long; everyone else sees who holds it, and can ask for it.
A claim is not a lock on Kubernetes. It points the deployment at the holder's branch, so the same branch tracking that renders and applies every push follows the holder. Deployments explains what a deployment is.
Only a deployment that follows a branch can be shared, since a claim works by choosing the branch. A deployment that takes snapshots on request or from another deployment cannot be shared.
Share a deployment
Open the deployment, then Settings, and find Shared use.
| Field | Meaning | Default |
|---|---|---|
| Shared | Turns claims on. Off while someone holds it is refused. | off |
| Who can claim | Teams whose members may claim or ask, picked from the organization's teams. None means anyone who can sync the deployment. | anyone |
| Longest claim | 15 minutes to 7 days. | 8 hours |
| When a claim ends | Go back to main points the deployment at the branch it had before, or at the default branch you name; Stay leaves it on the last branch. | go back |
| Pushes to other branches | A push to the branch the deployment goes back to is kept as a snapshot and applied when the claim ends. | on |
| Take over | Admins of the deployment may end a claim with a reason. | on |
| Hand-over | The jobs that run when the deployment changes hands. See Hand-over jobs. | none |
| Migration check | How Wardn looks for a database that may be ahead of the branch coming in. See The migration check. | off |
Claim it
On a shared deployment that nobody holds, Claim opens the claim dialog.
- Branch is what the deployment follows while you hold it.
- For how long is up to the longest claim. A claim can be extended once by the same length, within the longest.
- Note tells the others what you are testing.
Before you take it
The claim dialog and the request dialog read the branch you type and show, without changing anything:
- What runs now, and whose it is: the holder's branch while someone holds it, otherwise the snapshot and the branch it came from.
- Apps that move: how many of the deployment's apps would be at another commit. Wardn compares commits; the render after the claim says what changes inside each.
- Migrations: what the migration check found, or Not checked with the reason.
- Jobs that will run: the hand-over jobs and the apps' own jobs, in the order they run.
- Open incidents that affect the deployment and drift.
- Who else is affected: who holds it, until when, and how many wait.
A check that cannot look says so. When the migration check warns and the deployment has reset jobs, you choose Reset the database first or Keep the database as it is.
While you hold it:
- The deployment follows your branch. Pushes to it render and apply as usual.
- A person who syncs, promotes into it or restores it is refused with
deployment.claimed. The web app turns that into Request to use. - What the system sends waits. A promotion that a pipeline stage, an approval or a schedule makes is held back, with the reason
Waiting: <deployment> is in use by <name> until <time>where the release shows blocked snapshots, and is applied when the claim ends. A restore the system runs is refused while the deployment is held. Your own branch keeps rendering and applying. - You see a strip above the tabs with your name, branch and the time left, with Extend and Release.
Pushes while it is claimed
The deployment follows the holder's branch, so a push to the branch it goes back to (the default branch in the settings, otherwise the branch it had before the claim) is not applied. When Pushes to other branches is on, Wardn still renders it into a snapshot of the deployment and keeps it as waiting, with the same reason a held promotion has. The strip says who pushed which branch. The snapshot is applied when the claim ends with nobody next in line, and a snapshot the holder applies themselves is not held back. If someone is next in line, it stays waiting until that claim ends. A newer waiting snapshot, from a push or from what a pipeline sends, replaces the older one. A deployment that stays on the last branch when a claim ends has no branch to keep pushes for.
Hand-over jobs
In Settings, Hand-over lists Kubernetes Jobs that run in the deployment's namespace when it changes hands. Each has a place and a failure choice:
| Place | Runs |
|---|---|
| Before the next holder | First in the apply that follows, ahead of every other job. It is the reset: restore a database, clear data. |
| Before deploy | After the apps' own jobs that run before the first wave. |
| After deploy | After the apps' own jobs that run after the last wave. |
| If it fails | What happens |
|---|---|
| Stop the hand-over | The apply stops at the job. The claim stays with the new holder so they can fix it. |
| Warn and continue | The failure is shown and the apply goes on. |
| Roll back | The apply stops and asks for a rollback. |
The jobs ride on the next apply of the deployment, so they run with the new holder's branch. They run:
- when the deployment goes from one holder to the next (handed over, released, run out or taken over): the reset, the before-deploy jobs and the after-deploy jobs;
- when a claim ends with nobody next and the deployment goes back to its branch: the reset alone, with that apply. A deployment that stays on the last branch has no apply, so nothing runs;
- when a person claims a deployment nobody held: the before-deploy and after-deploy jobs, and the reset only if they chose Reset the database first.
A hand-over job whose name an app's job already has is not added twice. Each job may run up to 30 minutes. The jobs stay pending until an apply of the deployment succeeds, so an apply that stopped at a failed job brings them again. The holder can run them again with Retry or Run reset from the strip. The Claims history lists the hand-over jobs that ran during each claim.
The migration check
Wardn never reads your database and never looks inside images, so the check only reports what it can see:
- Files in git. It lists the files in the migration folder on the commit that runs now and on the commit the branch coming in points to, and compares the names. A file the running commit has and the incoming one lacks says the database may be ahead. A file only the incoming commit has says the branch adds migrations. With no folder named, it looks in
migrations,db/migrations,db/migrate,db/migration,alembic/versions,prisma/migrationsandsrc/main/resources/db/migration. It works for tools that keep one file per migration. - Job names. A job that runs with the deploy and whose name says it migrates (migrate, flyway, liquibase, alembic) is listed as a fact about what runs.
- A status job. An optional Job you set, such as
flyway validateorprisma migrate status. It runs in the hand-over after the reset jobs, always continues, and a non-zero exit warns with its output.
The answers are Migration files match, Adds migration files, Database may be ahead and Not checked. It is Not checked when the check is off, when Wardn cannot read the repository or the branch, or when neither commit has the folder. The result is kept with the claim.
When something goes wrong
Cards above the tabs say what is wrong, and offer what the person's rights allow:
| Card | When | Actions |
|---|---|---|
| Hand-over failed at and the job's name | A hand-over job failed in an apply after the claim began. | Open logs, Retry, Give back to the previous holder (the holder) |
| The database may be ahead of the code | The migration check warned and the holder has not chosen. | Run reset, Keep for this claim (the holder) |
| Health checks failing since the claim began (since the hand-over, when someone handed it over) | The deployment's health went bad after the claim began. | Give back to the previous holder, Keep and debug (the holder) |
| Claim ended during an apply | The claim's time came while an apply runs. The apply finishes first. | |
| A request has no answer | A request waited 30 minutes. | Take over (admins) |
| A push while it is claimed | A push was kept as a snapshot. | Request to use |
Give back to and a name appears when the claim began because the person before handed the deployment over or an admin took it over. It ends your claim and starts one for them, on the branch they were using and for the length they had, with the hand-over jobs of the settings. Keep and debug keeps a deployment whose health failed as it is: the card stops showing for this claim, and nothing is applied or reset.
Ask for it
Request to use puts you in the waiting line with a branch, a length and a note. The holder is told in their notifications and answers:
| Answer | What happens |
|---|---|
| Hand over now | Your claim starts at once. The holder's ends. |
| When I release | You are first in line. You get it when the holder releases or the claim runs out. |
| Decline | You are told why. The reason is required. |
The Claims tab shows who waits, in order, and the history of earlier claims: who held it, for how long, and how it ended (released, ran out, handed over, taken over, given back).
Fifteen minutes before a claim ends, the holder is told and can Extend from the notification. When it ends with nobody waiting, the deployment goes back as you chose in the settings. If someone is waiting, they hold it next. If the job that ends a claim does not run, the controller ends it within a few minutes.
A claim never ends in the middle of an apply. If its time comes while an apply is running, Wardn waits for the apply to finish and then ends the claim.
Take over
When a holder is away and others are blocked, an admin of the deployment (it needs deployment:manage) can Take over with a reason. The holder is told the reason, and the first in line, or the default branch, takes the deployment. The reason is kept in Activity.
Notifications and Activity
Every action is written to Activity: deployment.handover_jobs_run, deployment.migration_kept, deployment.claimed, deployment.claim_requested, deployment.claim_handed_over, deployment.claim_declined, deployment.claim_extended, deployment.claim_released, deployment.claim_expired, deployment.claim_taken_over, deployment.share_settings.
The people involved are told in their inbox, and in Slack when they have connected it and chosen it: the holder when someone asks, when a claim is about to end and when it is taken over, and the person who asked when they are handed the deployment or declined. A request in the inbox carries Hand over now, When I release and Decline.
Use it through the API
api() { curl -fsS -H "Authorization: Bearer $WARDN_TOKEN" -H 'Content-Type: application/json' "$@"; }
D="$WARDN_API_URL/api/v1/deployments/$DEPLOYMENT_ID/share"
api "$D" # settings, who holds it, who waits, what you may do
api -X POST "$D/claims" -d '{"branch":"feature-x","minutes":120,"note":"Checkout flow"}'
api -X POST "$D/requests" -d '{"branch":"feature-y","minutes":60}'
api -X POST "$D/requests/$REQUEST_ID/hand-over" -d '{"when":"now"}'
api -X POST "$D/requests/$REQUEST_ID/decline" -d '{"reason":"Demo at 3pm"}'
api -X POST "$D/claims/$CLAIM_ID/extend"
api -X POST "$D/claims/$CLAIM_ID/release"
api -X POST "$D/take-over" -d '{"reason":"The release needs staging"}'
api "$D/checks?branch=feature-x" # what to know before taking it
api -X POST "$D/claims/$CLAIM_ID/hand-over-jobs/run" # run the hand-over jobs again
api -X POST "$D/claims/$CLAIM_ID/keep-database" # keep the database as it is| Operation | Needs |
|---|---|
| Read, history, checks | deployment:read |
| Claim, request, extend, release, hand over, decline, run the hand-over jobs, keep the database | deployment:sync (the holder for all but the first two) |
| Settings, take over | deployment:manage |
Errors have stable codes: deployment.claimed (409, held by someone else), share.not_shared, share.not_claimed, share.already_requested, share.already_extended, share.claim_ended, share.not_holder (403), share.team_not_allowed (403), share.duration_too_long, share.needs_branch, share.in_use, share.takeover_off, share.no_jobs (no hand-over job is set) and share.nothing_to_apply (nothing has been rendered for the deployment yet).
Services
List the Redis, RabbitMQ and databases your apps use once for the organization, and let each deployment share the running instance or get a copy of its own.
Secret references
Tell Wardn which secrets a deployment needs, from Kubernetes Secrets or External Secrets Operator, and see whether they are there and whether they changed, without Wardn ever holding the values.