Skip to main content
Version: 3.0 (beta)

Space Templates

Loft allows you to create templates for spaces. Unlike Space Constraints which are enforced for a space, space templates are optional templates that a user can choose to apply when creating a space.

Common use cases for space templates may be:

  • Adding development tooling to a namespace
  • Deploying pre-populated databases with test data
  • Equipping new namespaces with optional credentials such as image pull secrets
Security Templates

Do not use space templates for setting up security-related resources such as NetworkPolicies or LimitRanges. Instead, use Space Constraints to enforce tenant isolation and other security measures.

Working with Space Templates

1. Create Space Template
  1. Go to the Spaces view using the menu on the left
  2. Switch to the Space Templates tab
  3. Click the button to create a new space template
  4. In the drawer that appears on the right, use the field Display Name to specify a Name for your space template
  5. Specify sleep mode settings as well as enforced labels and annotations for the spaces that will be created from this template
  6. Expand the Deploy Apps section to specify which apps should be deployed as part of this template
  7. On the very bottom, click on the button to create this space template
2. Use Space Template To Create A Space

To use a space template to create a space using Loft CLI, run:

loft create space [space-name] --template [template-name]
Kube-Context

Running loft create space will automatically add a kube-context to your kube-config file, so you can immediately run kubectl commands right after creating a space.

Configuration

Metadata

Display Name

JSONPath in CRD:
 spec.displayName (type: string)

Kubernetes Name

JSONPath in CRD:
 metadata.name (type: string)

Description

JSONPath in CRD:
 spec.description (type: string)

Labels

JSONPath in CRD:
 metadata.labels (type: map[string]string)

Annotations

JSONPath in CRD:
 metadata.annotations (type: map[string]string)

Template For Spaces

Labels

JSONPath in CRD:
 spec.template.metadata.labels (type: map[string]string)

Annotations

JSONPath in CRD:
 spec.template.metadata.annotations (type: map[string]string)

Sleep Mode

Inactivity Timeout

JSONPath in CRD:
 spec.template.metadata.annotations["sleepmode.loft.sh/sleep-after"] (type: string)

Auto-Delete Timeout

JSONPath in CRD:
 spec.template.metadata.annotations["sleepmode.loft.sh/delete-after"] (type: string)

Sleep Schedule

JSONPath in CRD:
 spec.template.metadata.annotations["sleepmode.loft.sh/sleep-schedule"] (type: string)

Wake-Up Schedule

JSONPath in CRD:
 spec.template.metadata.annotations["sleepmode.loft.sh/wakeup-schedule"] (type: string)

Scheduling Timezone

JSONPath in CRD:
 spec.template.metadata.annotations["sleepmode.loft.sh/timezone"] (type: string)

Apps

JSONPath in CRD:
 spec.template.apps (type: AppRef[])

Access To Space Template

JSONPath in CRD:
 spec.access (type: Access[])

CRDs

SpaceTemplate

apiVersion
string

APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

kind
string

Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

object (io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta)

ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.

object (com.github.loft-sh.api.pkg.apis.management.v1.SpaceTemplateSpec)

SpaceTemplateSpec holds the specification

object (com.github.loft-sh.api.pkg.apis.management.v1.SpaceTemplateStatus)

SpaceTemplateStatus holds the status

{
  • "apiVersion": "string",
  • "kind": "string",
  • "metadata": {
    },
  • "spec": {
    },
  • "status": {
    }
}