Space Constraints in Loft
Space Constraints allow you to define restrictions for namespaces such as enforced resources that will be deployed to each new namespace a user creates (e.g. NetworkPolicies) or other enforced settings such as mandatory labels, annotations, or any sleep mode configurations.
Working with Space Constraints
1. Create Space Constraints
- Go to the Clusters view using the menu on the left
- Switch to the Space Constraints tab
- Click the button to create a new space constraints object
- In the drawer that appears on the right, use the field Display Name to specify a Name for your space constraints object
- Expand the section to specify manifests that should be deployed to and enforced in each namespace that is affected by these space constraints
- Expand the section to specify other space settings such as sleep mode, auto-delete, labels and annotations that should be enforced for each namespace that is affected by these space constraints
- On the very bottom, click on the button to create this space constraints object
2. Enforce Space Constraints For Users & Teams
- Go to the Clusters view using the menu on the left
- Switch to the Cluster Access tab
- Hover over the cluster access that you want to apply these space constraints to and click on the button to Edit the cluster access
- In the drawer that appears on the right, expand the section
- Use the Enforce Space Constraints field to select the Space Constraint that you want to enforce for all spaces created using this cluster access
- On the very bottom, click on the or button to save the changes
- Switch to the Cluster Access tab
- Hover over the cluster access of the user or team that you want to configure automatic sleep mode for and click on the button to Edit the cluster access
- In the drawer that appears on the right, expand the section
- Use the Enforce Space Constraints field to select the Space Constraint you edited or created in Step 3 above
- On the very bottom, click on the button to save the changes
Test with Impersonation
After following the steps above, all spaces created using the cluster access in step 7 will now enforce these space constraints. You can test this behavior by impersonating a user that uses this cluster access.
Configuration
Metadata
Display Name
JSONPath in SpaceConstraint CRD:
spec.displayName (type: string)
Kubernetes Name
JSONPath in SpaceConstraint CRD:
metadata.name (type: string)
Description
JSONPath in SpaceConstraint CRD:
spec.description (type: string)
Labels
JSONPath in SpaceConstraint CRD:
metadata.labels (type: map[string]string)
Annotations
JSONPath in SpaceConstraint CRD:
metadata.annotations (type: map[string]string)
Enforce Resources
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.spec.spaceTemplate.objects (type: {})
Enforce Sleep Mode
Inactivity Timeout
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.metadata.annotations["sleepmode.loft.sh/sleep-after"] (type: string)
Auto-Delete Timeout
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.metadata.annotations["sleepmode.loft.sh/delete-after"] (type: string)
Sleep Schedule
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.metadata.annotations["sleepmode.loft.sh/sleep-schedule"] (type: string)
Wake-Up Schedule
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.metadata.annotations["sleepmode.loft.sh/wakeup-schedule"] (type: string)
Scheduling Timezone
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.metadata.annotations["sleepmode.loft.sh/timezone"] (type: string)
Enforce Labels & Annoations
Labels
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.metadata.labels (type: map[string]string)
Annotations
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.metadata.annotations (type: map[string]string)
Advanced Options
Clusters
JSONPath in SpaceConstraint CRD:
spec.clusters (type: string[])
Sync Constraint Changes
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.spec.sync (type: string)
Owner's Cluster Role
JSONPath in SpaceConstraint CRD:
spec.localSpaceConstraintTemplate.spec.spaceTemplate.clusterRole (type: map[string]string)
Access To Space Constraints
JSONPath in SpaceConstraint CRD:
spec.access (type: Access[])