Cluster
Connected Kubernetes clusters that can be managed through Loft. You can allow users and teams to access those clusters and they can create new spaces and virtual clusters inside them.
Example Cluster
An example Cluster:
apiVersion: management.loft.sh/v1
kind: Cluster
metadata:
creationTimestamp: null
name: my-cluster
spec:
config:
secretName: my-kube-config-secret
secretNamespace: my-kube-config-secret-namespace
description: My AWS Cluster
displayName: My Cluster
status: {}
Cluster 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: Clusters
You can either use curl or kubectl to retrieve Clusters.
- kubectl
- curl
Retrieve a list of Clusters
Run the following command to list all Clusters:
kubectl get clusters.management.loft.sh -o yaml
Retrieve a single Cluster by name
Run the following kubectl command to get Cluster my-cluster
:
kubectl get clusters.management.loft.sh my-cluster -o yaml
Retrieve a list of Clusters
Run the following curl command to list all Clusters:
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusters" \
-X GET --insecure \
-H "Authorization: Bearer $ACCESS_KEY"
Get a single Cluster by name
Run the following curl command to get Cluster my-cluster
:
# Exchange my-cluster in the url below with the name of the Cluster
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusters/my-cluster" \
-X GET --insecure \
-H "Authorization: Bearer $ACCESS_KEY"
Create: Cluster
You can either use curl or kubectl to create a new Cluster.
- kubectl
- curl
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: Cluster
metadata:
creationTimestamp: null
name: my-cluster
spec:
config:
secretName: my-kube-config-secret
secretNamespace: my-kube-config-secret-namespace
description: My AWS Cluster
displayName: My Cluster
status: {}
Then create the Cluster my-cluster
with:
kubectl create -f object.yaml
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: Cluster
metadata:
creationTimestamp: null
name: my-cluster
spec:
config:
secretName: my-kube-config-secret
secretNamespace: my-kube-config-secret-namespace
description: My AWS Cluster
displayName: My Cluster
status: {}
Run the following curl command to create a new Cluster my-cluster
:
curl -s -X POST --insecure \
"https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusters" \
--data-binary "$(cat object.yaml)" \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY"
Update: Cluster
You can either use curl or kubectl to update Clusters.
- kubectl
- curl
Update Cluster
Run the following command to update Cluster my-cluster
:
kubectl edit clusters.management.loft.sh my-cluster
Then edit the object and upon save, kubectl will update the resource.
Patch Cluster
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 Cluster my-cluster
via a patch:
kubectl patch clusters.management.loft.sh my-cluster \
--type json \
-p '[{"op": "add", "path": "/metadata/annotations/my-annotation", "value": "my-value"}]'
Update Cluster
First retrieve the current object into a file object.yaml
. This could look like:
apiVersion: management.loft.sh/v1
kind: Cluster
metadata:
creationTimestamp: "2023-04-03T00:00:00Z"
generation: 12
name: my-cluster
resourceVersion: "66325905"
uid: af5f9f0f-8ab9-4b4b-a595-a95a5921f3c2
spec:
config:
secretName: my-kube-config-secret
secretNamespace: my-kube-config-secret-namespace
description: My AWS Cluster
displayName: My Cluster
status: {}
Run the following curl command to update a single Cluster my-cluster
:
# Replace the my-cluster in the url below with the name of the Cluster you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusters/my-cluster" \
-X PUT --insecure \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY" \
--data-binary "$(cat object.yaml)"
Patch Cluster
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 Cluster my-cluster
via a patch:
# Replace the my-cluster in the url below with the name of the Cluster you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusters/my-cluster" \
-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: Cluster
You can either use curl or kubectl to delete Clusters.
- kubectl
- curl
Run the following command to delete Cluster my-cluster
:
kubectl delete clusters.management.loft.sh my-cluster
Run the following curl command to delete Cluster my-cluster
:
# Replace the my-cluster in the url below with the name of the Cluster you want to delete
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusters/my-cluster" \
-X DELETE --insecure \
-H "Authorization: Bearer $ACCESS_KEY"