Deployment templates

Save a deployment's setup as a template, start new deployments from it, and update the deployments made from it one version at a time.

A template is a named setup that starts a deployment: the apps it runs, the services they use, how it gets snapshots, where it runs by default, and what happens when it is made for a pull request. Several deployments made from one template start alike, and when the template changes Wardn offers the change to each of them. Deployments explains what a deployment is.

Editing a template never changes a deployment on its own. Each deployment records the template and the version it came from, and a newer version is offered to it. Someone compares, then updates.

What a template holds

PartWhat it says
AppsThe apps the deployment runs. Each one follows a branch or a pinned version (a tag or a commit), and lists values files.
ServicesThe organization services the apps use, and whether a new deployment shares each one or gets an own copy.
SettingsHow the deployment gets new snapshots (Tracking a branch or By request) and how long it watches its health after a sync.
Default environment and clusterWhere a deployment made from it starts. Either may be left empty.
Name patternNames the deployment a pull request gets. The default is <template>-pr-<n>, so payments-stack gives payments-stack-pr-142. The name is also the namespace.
Pull request defaultsWhether the deployment sets the commit status, the View deployment button and the comment on a pull request, and how long after the last linked pull request closes it is removed. See Pull request deployments.
Auto-add to clustersOptional. Adds a deployment of the template to every cluster whose labels match. See below.

Values files are saved with the template and shown with each app. Wardn does not read them when it renders yet: an app renders with its default values and the values set on the deployment.

Make a template

There are two ways in.

  • On New deployment, tick Save as template under Template, give it a name, and choose Create deployment. The deployment is made, and the template is saved from the form as version 1.
  • On an existing deployment, save it as a template from its page. The template takes the deployment's apps, the services it uses and where it runs, and the deployment records it as where it came from.

Deployments, then the Templates tab, lists every template: its latest version, its apps and services, how many deployments came from it, the labels it adds automatically to, and when it last changed.

A template name is 1 to 48 lowercase letters, digits and dashes.

Versions

Saving an edit makes the next version. A version never changes after it is saved: the page for a template lists every version, newest first, with who saved it, what changed and when. Leave the summary out and Wardn writes it from the difference ("Added payments-worker. Health watch 600s."). Compare versions shows the difference between any two.

api -X PUT "$WARDN_API_URL/api/v1/deployment-templates/$TEMPLATE_ID" -d @template.json
api "$WARDN_API_URL/api/v1/deployment-templates/$TEMPLATE_ID/versions"
api "$WARDN_API_URL/api/v1/deployment-templates/$TEMPLATE_ID/diff?from=3&to=4"

A template keeps at most 500 versions.

Start a deployment from a template

On New deployment, Start from lists Blank and every template with its version and how many deployments use it. Choosing a template fills in the apps, services and settings, and a version menu picks an older version. Everything stays editable until you choose Create deployment. The deployment records the template and version it started from.

Updates

A deployment made from a template shows the version it came from. When a newer version exists it shows v4 available with two buttons:

  • Compare lists what updating would change in this deployment: apps added, removed or following something else, services that switch between shared and an own copy, and settings.
  • Update applies exactly that difference, then records the new version. The change is made through the same use cases as any edit to the deployment, so the same permission (deployment:manage) and the same limits apply.

The template's page lists every deployment made from it, the version each is at, and Update for the ones that are behind. A deployment is never updated without someone choosing it.

api "$WARDN_API_URL/api/v1/deployments/$DEPLOYMENT_ID/template"
api "$WARDN_API_URL/api/v1/deployments/$DEPLOYMENT_ID/template/changes"
api -X POST "$WARDN_API_URL/api/v1/deployments/$DEPLOYMENT_ID/template/update" -d '{}'   # or {"version": 3}

An update applies the difference between the two versions, so what someone changed by hand in the deployment stays unless the difference touches it. Apps added by an update follow the branch or the pinned version the template names.

Delete a template

Deleting a template removes it and its versions. Its deployments are left exactly as they are; each keeps the name and version it recorded, and shows no update.

Auto-add to clusters

Auto-add to clusters is an optional setting of a template. Turn on Add automatically and give it labels: Wardn adds a deployment of the template to every cluster whose labels include all of them. A cluster's labels are set when it is registered or changed (Environments).

  • The deployment is named after the template and the cluster (regional-gateway-eu-1), runs in a namespace named after the template, and follows the template's latest version when it is added.
  • A cluster gets a deployment from the template once. If someone deletes it, it is not made again.
  • Paused clusters are skipped.
  • A deployment added this way holds the template's apps and settings. Its services are set on the deployment afterwards.

Permissions

PermissionAllowsHeld by
template:readSee templates and their versions.Owner, Admin, Organization reader
template:manageSave, edit and delete templates.Owner, Admin

Updating a deployment to a template version needs deployment:manage on that deployment, like any change to it. Starting a deployment from a template needs template:read to see it and the permissions to create the deployment.

On this page