Project
Projects are used to group virtual clusters and spaces together.
Example Project
An example Project:
apiVersion: management.loft.sh/v1
kind: Project
metadata:
creationTimestamp: null
name: my-project
spec:
allowedClusters:
- name: my-allowed-cluster
allowedTemplates:
- kind: VirtualClusterTemplate
name: '*'
- kind: SpaceTemplate
name: '*'
members:
- clusterRole: project-admin
group: storage.loft.sh
kind: User
name: admin
- clusterRole: project-user
group: storage.loft.sh
kind: Team
name: my-team
quotas: {}
requireTemplate: {}
vault: {}
status: {}
Project 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: Projects
You can either use curl or kubectl to retrieve Projects.
- kubectl
- curl
Retrieve a list of Projects
Run the following command to list all Projects:
kubectl get projects.management.loft.sh -o yaml
Retrieve a single Project by name
Run the following kubectl command to get Project my-project
:
kubectl get projects.management.loft.sh my-project -o yaml
Retrieve a list of Projects
Run the following curl command to list all Projects:
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/projects" \
-X GET --insecure \
-H "Authorization: Bearer $ACCESS_KEY"
Get a single Project by name
Run the following curl command to get Project my-project
:
# Exchange my-project in the url below with the name of the Project
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/projects/my-project" \
-X GET --insecure \
-H "Authorization: Bearer $ACCESS_KEY"
Create: Project
You can either use curl or kubectl to create a new Project.
- kubectl
- curl
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: Project
metadata:
creationTimestamp: null
name: my-project
spec:
allowedClusters:
- name: my-allowed-cluster
allowedTemplates:
- kind: VirtualClusterTemplate
name: '*'
- kind: SpaceTemplate
name: '*'
members:
- clusterRole: project-admin
group: storage.loft.sh
kind: User
name: admin
- clusterRole: project-user
group: storage.loft.sh
kind: Team
name: my-team
quotas: {}
requireTemplate: {}
vault: {}
status: {}
Then create the Project my-project
with:
kubectl create -f object.yaml
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: Project
metadata:
creationTimestamp: null
name: my-project
spec:
allowedClusters:
- name: my-allowed-cluster
allowedTemplates:
- kind: VirtualClusterTemplate
name: '*'
- kind: SpaceTemplate
name: '*'
members:
- clusterRole: project-admin
group: storage.loft.sh
kind: User
name: admin
- clusterRole: project-user
group: storage.loft.sh
kind: Team
name: my-team
quotas: {}
requireTemplate: {}
vault: {}
status: {}
Run the following curl command to create a new Project my-project
:
curl -s -X POST --insecure \
"https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/projects" \
--data-binary "$(cat object.yaml)" \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY"
Update: Project
You can either use curl or kubectl to update Projects.
- kubectl
- curl
Update Project
Run the following command to update Project my-project
:
kubectl edit projects.management.loft.sh my-project
Then edit the object and upon save, kubectl will update the resource.
Patch Project
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 Project my-project
via a patch:
kubectl patch projects.management.loft.sh my-project \
--type json \
-p '[{"op": "add", "path": "/metadata/annotations/my-annotation", "value": "my-value"}]'
Update Project
First retrieve the current object into a file object.yaml
. This could look like:
apiVersion: management.loft.sh/v1
kind: Project
metadata:
creationTimestamp: "2023-04-03T00:00:00Z"
generation: 12
name: my-project
resourceVersion: "66325905"
uid: af5f9f0f-8ab9-4b4b-a595-a95a5921f3c2
spec:
allowedClusters:
- name: my-allowed-cluster
allowedTemplates:
- kind: VirtualClusterTemplate
name: '*'
- kind: SpaceTemplate
name: '*'
members:
- clusterRole: project-admin
group: storage.loft.sh
kind: User
name: admin
- clusterRole: project-user
group: storage.loft.sh
kind: Team
name: my-team
quotas: {}
requireTemplate: {}
vault: {}
status: {}
Run the following curl command to update a single Project my-project
:
# Replace the my-project in the url below with the name of the Project you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/projects/my-project" \
-X PUT --insecure \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY" \
--data-binary "$(cat object.yaml)"
Patch Project
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 Project my-project
via a patch:
# Replace the my-project in the url below with the name of the Project you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/projects/my-project" \
-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: Project
You can either use curl or kubectl to delete Projects.
- kubectl
- curl
Run the following command to delete Project my-project
:
kubectl delete projects.management.loft.sh my-project
Run the following curl command to delete Project my-project
:
# Replace the my-project in the url below with the name of the Project you want to delete
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/projects/my-project" \
-X DELETE --insecure \
-H "Authorization: Bearer $ACCESS_KEY"