Space Instance
Spaces are regular Kubernetes namespaces managed by Loft that are owned by a user or team. In Kubernetes, namespaces provide a mechanism for isolating groups of resources within a single cluster.
Example Space
An example Space:
apiVersion: management.loft.sh/v1
kind: SpaceInstance
metadata:
creationTimestamp: null
name: my-space
namespace: loft-p-my-project
spec:
clusterRef: {}
displayName: my-display-name
owner:
user: my-user
parameters: 'my-parameter: my-value'
templateRef:
name: my-space-template
status: {}
Space Reference
kind
required 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
kind
required string apiVersion
required 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
apiVersion
required string metadata
required object
metadata
required object spec
required object
spec
required object status
required object
status
required object Retrieve: Spaces
You can either use curl or kubectl to retrieve Spaces.
- kubectl
- curl
Retrieve a list of Spaces
Run the following command to list all Spaces in project my-project
:
kubectl get spaceinstances.management.loft.sh -n loft-p-my-project -o yaml
Retrieve a single Space by name
Run the following kubectl command to get Space my-space
in project my-project
:
kubectl get spaceinstances.management.loft.sh my-space -n loft-p-my-project -o yaml
Retrieve a list of Spaces
Run the following curl command to list all Spaces in project my-project
:
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/namespaces/loft-p-my-project/spaceinstances" \
-X GET --insecure \
-H "Authorization: Bearer $ACCESS_KEY"
Get a single Space by name
Run the following curl command to get Space my-space
in project my-project
:
# Exchange my-space in the url below with the name of the Space
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/namespaces/loft-p-my-project/spaceinstances/my-space" \
-X GET --insecure \
-H "Authorization: Bearer $ACCESS_KEY"
Create: Space
You can either use curl or kubectl to create a new Space.
Make sure to set the project in the metadata.namespace
field you want to create the Space in. If your project has the id my-project
, the corresponding namespace would be loft-p-my-project
.
- kubectl
- curl
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: SpaceInstance
metadata:
creationTimestamp: null
name: my-space
namespace: loft-p-my-project
spec:
clusterRef: {}
displayName: my-display-name
owner:
user: my-user
parameters: 'my-parameter: my-value'
templateRef:
name: my-space-template
status: {}
Then create the Space my-space
in project my-project
with:
kubectl create -f object.yaml -n loft-p-my-project
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: SpaceInstance
metadata:
creationTimestamp: null
name: my-space
namespace: loft-p-my-project
spec:
clusterRef: {}
displayName: my-display-name
owner:
user: my-user
parameters: 'my-parameter: my-value'
templateRef:
name: my-space-template
status: {}
Run the following curl command to create a new Space my-space
in project my-project
:
curl -s -X POST --insecure \
"https://$LOFT_DOMAIN/kuberentes/management/apis/management.loft.sh/v1/namespaces/loft-p-my-project/spaceinstances" \
--data-binary "$(cat object.yaml)" \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY"
Update: Space
You can either use curl or kubectl to update Spaces.
- kubectl
- curl
Update Space
Run the following command to update Space my-space
in project my-project
:
kubectl edit spaceinstances.management.loft.sh my-space -n loft-p-my-project
Then edit the object and upon save, kubectl will update the resource.
Patch Space
Patching a resource is useful if you want to generically exchange only a small portion of the object instead of retrieving the whole object first and then modifying it. To learn more about patches in Kubernetes, please take a look at the official docs.
Run the following kubectl command to add a new annotation my-annotation: my-value
to the Space my-space
in project my-project
via a patch:
kubectl patch spaceinstances.management.loft.sh my-space -n loft-p-my-project \
--type json \
-p '[{"op": "add", "path": "/metadata/annotations/my-annotation", "value": "my-value"}]'
Update Space
First retrieve the current object into a file object.yaml
. This could look like:
apiVersion: management.loft.sh/v1
kind: SpaceInstance
metadata:
creationTimestamp: "2022-12-06T08:53:04Z"
generation: 12
name: my-space
namespace: loft-p-my-project
resourceVersion: "66325905"
uid: af5f9f0f-8ab9-4b4b-a595-a95a5921f3c2
spec:
clusterRef: {}
displayName: my-display-name
owner:
user: my-user
parameters: 'my-parameter: my-value'
templateRef:
name: my-space-template
status: {}
Run the following curl command to update a single Space my-space
in project my-project
:
# Replace the my-space in the url below with the name of the Space you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/namespaces/loft-p-my-project/spaceinstances/my-space" \
-X PUT --insecure \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY" \
--data-binary "$(cat object.yaml)"
Patch Space
Patching a resource is useful if you want to generically exchange only a small portion of the object instead of retrieving the whole object first and then modifying it. To learn more about patches in Kubernetes, please take a look at the official docs.
Run the following curl command to add a new annotation my-annotation: my-value
to the Space my-space
in project my-project
via a patch:
# Replace the my-space in the url below with the name of the Space you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/namespaces/loft-p-my-project/spaceinstances/my-space" \
-X PATCH --insecure \
-H "Content-Type: application/json-patch+json" \
-H "Authorization: Bearer $ACCESS_KEY" \
--data '[{"op": "add", "path": "/metadata/annotations/my-annotation", "value": "my-value"}]'
Delete: Space
You can either use curl or kubectl to delete Spaces.
- kubectl
- curl
Run the following command to delete Space my-space
in project my-project
:
kubectl delete spaceinstances.management.loft.sh my-space -n loft-p-my-project
Run the following curl command to delete Space my-space
in project my-project
:
# Replace the my-space in the url below with the name of the Space you want to delete
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/namespaces/loft-p-my-project/spaceinstances/my-space" \
-X DELETE --insecure \
-H "Authorization: Bearer $ACCESS_KEY"