Spaces
Spaces are virtual resources that represent regular Kubernetes namespaces. Typically, non-admin users to not have the permission to list, create or delete namespaces in a shared Kubernetes clusters. That's why Loft adds the space resource to Kubernetes. Spaces are not stored in etcd but rather abstract from regular namespaces. Deleting a space will effectively delete the underlying namespace, for example. In turn, any labels and annotations set on a namespace will show up on the corresponding space as well.
Working with Spaces
Space and namespaces are directly coupled via a 1:1 relationship. But unlike with namespaces, it is safe to give non-admin users the permission to create and manage their own spaces.
Create Spaces
- UI
- CLI
- kubectl
- Go to the Spaces view using the menu on the left
- Click on the button
- Use the field Kubernetes 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 create a space using Loft CLI, run:
loft create space [space-name]
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.
If you do not have a kube-context for the cluster where this space should be created in, you can set up a kube-context using:
loft use cluster [cluster-name]
Create a file named
space.yaml
with the following content:apiVersion: cluster.loft.sh/v1
kind: Space
metadata:
name: space-name # Set the name for your space hereCreate the space using kubectl:
kubectl apply -f space.yaml
Retrieve a kube-context for this space using Loft CLI:
loft use space [space-name]
Delete Spaces
- UI
- CLI
- kubectl
- In the Spaces view, hover over the row of the space that you want to delete.
- While hovering over the row, you will see buttons appear on the right in the Actions column
- Click on the button to Delete the space
loft delete space [space-name]
Deleting spaces with Loft CLI has the advantage that Loft CLI will also delete the kube-context for this space from your local kube-config file to keep everything cleaned up.
If you do not have a kube-context for the cluster where this space is located in, you can set up a kube-context using:
loft use cluster [cluster-name]
Delete the space using kubectl:
kubectl delete space [space-name]
# Alternatively:
# kubectl delete -f space.yaml
List Spaces
- UI
- CLI
- kubectl
To see a list of spaces, go to the Spaces view using the main menu on the left.
If you are admin in one of the clusters connected to Loft, you will have permission to view all namespaces in the cluster. Since spaces and namespaces have a 1:1 relationship and Loft is often relying on regular Kubernetes RBAC, you will be able to see all namespaces in the Spaces view rather than just namespaces created via Loft.
Run this command using Loft CLI to get a list of all spaces you have access to across all clusters:
loft list spaces
If you want to retrieve a kube-context for any of your spaces, run:
loft use space [space-name]
If you do not have a kube-context for the cluster where you want to list spaces in, you can set up a kube-context using:
loft use cluster [cluster-name]
Run this kubectl command to get a list of spaces:
kubectl get spaces
Prevent Space Deletion
You can prevent space deletion, by setting the annotation loft.sh/non-deletable
to true
.
Configuration
Owner
spec.user (type: string) # default: name of current user
Template
Metadata
Name
metadata.name (type: string)
Labels
metadata.labels (type: map[string]string)
Annotations
metadata.annotations (type: map[string]string)
Sleep Mode
Inactivity Timeout
metadata.annotations["sleepmode.loft.sh/sleep-after"] (type: string)
Auto-Delete Timeout
metadata.annotations["sleepmode.loft.sh/delete-after"] (type: string)
Sleep Schedule
metadata.annotations["sleepmode.loft.sh/sleep-schedule"] (type: string)
Wake-Up Schedule
metadata.annotations["sleepmode.loft.sh/wakeup-schedule"] (type: string)
Scheduling Timezone
metadata.annotations["sleepmode.loft.sh/timezone"] (type: string)
Apps
Access To Space
spec.access (type: Access[])