Cluster Access
Globally defined cluster access. You can allow users or teams to access certain clusters here and define their cluster roles in those clusters.
Example Cluster Access
An example Cluster Access:
apiVersion: management.loft.sh/v1
kind: ClusterAccess
metadata:
creationTimestamp: null
name: my-cluster-access
spec:
clusters:
- '*'
description: Defines cluster access for the global admins
displayName: Global Admins
localClusterAccessTemplate:
metadata:
creationTimestamp: null
spec:
clusterRoles:
- name: loft-cluster-admin
priority: 1000000
users:
- team: loft-admins
status: {}
Cluster Access 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: Cluster Accesses
You can either use curl or kubectl to retrieve Cluster Accesses.
- kubectl
- curl
Retrieve a list of Cluster Accesses
Run the following command to list all Cluster Accesses:
kubectl get clusteraccesses.management.loft.sh -o yaml
Retrieve a single Cluster Access by name
Run the following kubectl command to get Cluster Access my-cluster-access
:
kubectl get clusteraccesses.management.loft.sh my-cluster-access -o yaml
Retrieve a list of Cluster Accesses
Run the following curl command to list all Cluster Accesses:
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusteraccesses" \
-X GET --insecure \
-H "Authorization: Bearer $ACCESS_KEY"
Get a single Cluster Access by name
Run the following curl command to get Cluster Access my-cluster-access
:
# Exchange my-cluster-access in the url below with the name of the Cluster Access
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusteraccesses/my-cluster-access" \
-X GET --insecure \
-H "Authorization: Bearer $ACCESS_KEY"
Create: Cluster Access
You can either use curl or kubectl to create a new Cluster Access.
- kubectl
- curl
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: ClusterAccess
metadata:
creationTimestamp: null
name: my-cluster-access
spec:
clusters:
- '*'
description: Defines cluster access for the global admins
displayName: Global Admins
localClusterAccessTemplate:
metadata:
creationTimestamp: null
spec:
clusterRoles:
- name: loft-cluster-admin
priority: 1000000
users:
- team: loft-admins
status: {}
Then create the Cluster Access my-cluster-access
with:
kubectl create -f object.yaml
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: ClusterAccess
metadata:
creationTimestamp: null
name: my-cluster-access
spec:
clusters:
- '*'
description: Defines cluster access for the global admins
displayName: Global Admins
localClusterAccessTemplate:
metadata:
creationTimestamp: null
spec:
clusterRoles:
- name: loft-cluster-admin
priority: 1000000
users:
- team: loft-admins
status: {}
Run the following curl command to create a new Cluster Access my-cluster-access
:
curl -s -X POST --insecure \
"https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusteraccesses" \
--data-binary "$(cat object.yaml)" \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY"
Update: Cluster Access
You can either use curl or kubectl to update Cluster Accesses.
- kubectl
- curl
Update Cluster Access
Run the following command to update Cluster Access my-cluster-access
:
kubectl edit clusteraccesses.management.loft.sh my-cluster-access
Then edit the object and upon save, kubectl will update the resource.
Patch Cluster Access
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 Access my-cluster-access
via a patch:
kubectl patch clusteraccesses.management.loft.sh my-cluster-access \
--type json \
-p '[{"op": "add", "path": "/metadata/annotations/my-annotation", "value": "my-value"}]'
Update Cluster Access
First retrieve the current object into a file object.yaml
. This could look like:
apiVersion: management.loft.sh/v1
kind: ClusterAccess
metadata:
creationTimestamp: "2023-04-03T00:00:00Z"
generation: 12
name: my-cluster-access
resourceVersion: "66325905"
uid: af5f9f0f-8ab9-4b4b-a595-a95a5921f3c2
spec:
clusters:
- '*'
description: Defines cluster access for the global admins
displayName: Global Admins
localClusterAccessTemplate:
metadata:
creationTimestamp: null
spec:
clusterRoles:
- name: loft-cluster-admin
priority: 1000000
users:
- team: loft-admins
status: {}
Run the following curl command to update a single Cluster Access my-cluster-access
:
# Replace the my-cluster-access in the url below with the name of the Cluster Access you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusteraccesses/my-cluster-access" \
-X PUT --insecure \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY" \
--data-binary "$(cat object.yaml)"
Patch Cluster Access
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 Access my-cluster-access
via a patch:
# Replace the my-cluster-access in the url below with the name of the Cluster Access you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusteraccesses/my-cluster-access" \
-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 Access
You can either use curl or kubectl to delete Cluster Accesses.
- kubectl
- curl
Run the following command to delete Cluster Access my-cluster-access
:
kubectl delete clusteraccesses.management.loft.sh my-cluster-access
Run the following curl command to delete Cluster Access my-cluster-access
:
# Replace the my-cluster-access in the url below with the name of the Cluster Access you want to delete
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/clusteraccesses/my-cluster-access" \
-X DELETE --insecure \
-H "Authorization: Bearer $ACCESS_KEY"