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
- Go to the Spaces view using the menu on the left
- Switch to the Space Templates tab
- Click the button to create a new space template
- In the drawer that appears on the right, use the field Display Name to specify a Name for your space template
- Specify sleep mode settings as well as enforced labels and annotations for the spaces that will be created from this template
- Expand the section to specify which apps should be deployed as part of this template
- On the very bottom, click on the button to create this space template
2. Use Space Template To Create A Space
- UI
- CLI
- Go to the Spaces view using the menu on the left
- Click on the button
- Use the field Space Template to select a template to use for creating this space
- Use the field Display Name to define the name of this space and optionally specify other settings
- Click on the button at the very bottom
Retrieve a kube-context for this space using Loft CLI:
loft use space [space-name]
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[])