Skip to main content
Version: 3.4

Templates

Space templates are, as the name implies, templates that you can create which can then be applied when creating a space. These templates can be used to configure any space settings that you would configure on an individual space object.

Space templates are used for creating a standard developer environment for a given team or organization or to template out pre-built environments to be used in continuous integration and testing.

As regular project users can only deploy new spaces via template, templates provide a mechanism for Loft administrators to expose acceptable space configurations to end users.

Templates can include settings such as:

  • Isolation relevant objects, such as resource quotas, limit ranges and network policies.
  • Kubernetes objects. This could include development tooling, pre-populated databases with test data, or any other useful resources.
  • Custom defined Apps

Create Space Template

Space templates can be created directly in the Loft UI.

  1. In the Loft UI, select the Templates field on the left-most menu bar.
  2. From the Templates sub-menu, select the button.
  3. Click button.
  4. In the drawer that appears from the right, give your space template a name by replacing the 'my-template' placeholder name, or by updating the manifest YAML 'metadata.name' field.
  5. [Optional] Update the template with any additional desired configuration options.
    1. The Definition tab contains settings relating to the space deployment itself, primarily related to sleeping, see the Sleep Mode section for more details.
    2. Objects is where you can define Kubernetes manifests that should be created in the virtual cluster.
    3. Apps allows you to select any pre-defined 'applications' (ex: Cert Manager) that should be installed into the virtual cluster.
    4. Parameters provides a mechanism for exposing values that users should be able to modify when deploying a virtual cluster from this template.
    5. Permissions are additional access rules that can be defined for the virtual cluster instance.
    6. Finally, Template Permissions are the permissions that are applied to the template itself -- that is, who has permission to view/edit this template.
  6. Click on the button at the very bottom.

Using Templates (UI & CLI)

Once you have created a space template you can then refer to that template when creating a new space. All template configurations will be automatically applied to the newly created space. Spaces referring to templates can be created in the UI or via the Loft CLI.

  1. Select the Projects field on the left menu bar.
  2. From the project drop-down menu, select the project you'd like to create the space in.
  3. Click the Spaces option on the project pane.
  4. Click the button on the right side of the page.
  5. In the pop-up box, select your template from the template drop down menu.
  6. [Optional] select the cluster in which to create the virtual cluster.
  7. Click the to continue.
  8. In the drawer that appears from the right, give your space a name by replacing the my-space placeholder name, or by updating the manifest YAML metadata.name field.
  9. Click the button.

Versioning

Space templates can be versioned. Versioning a space template allows you to make changes over time to a template while retaining the current version/iteration. Spaces that are deployed with templates that have updated versions will show up with a warning indicating that a newer template version is available.

Parameters

Parameters are a very powerful component of space templates. These parameters allow for giving users that may consume your space template a bit of flexibility with configuration options for certain applications, while still maintaining control over the possible values the users can select.

When deploying a space referring to a template with parameters configured, Loft will prompt the user for their selection for the given parameters. For example, with a parameters configuration as shown below, the user will get a dialog box where they can select 'one' or 'two' as the value for the mylabelvalue variable.

- variable: mylabelvalue
label: SpaceLabelValue
description: Please select the value for the Space "my-label" key
options:
- one
- two
section: Labels

The final value of this variable can then be used throughout the template. For example, this value can be used within space label and annotations section. In the example below, this value is being set as a label on the created space object.

my-label: "{{ .Values.mylabelvalue }}"
Apps, Parameters, Oh my!

Check out the Apps section of the docs, especially the Parameters section for more details on Parameters generally, and in relation to Apps!