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