Owned Access Key
Access keys let you authenticate with Loft API endpoints and Loft CLI in non-interactive environments such as from within CI/CD pipelines.
Example Owned Access Key
An example Owned Access Key:
apiVersion: management.loft.sh/v1
kind: OwnedAccessKey
metadata:
creationTimestamp: null
name: my-access-key
spec:
displayName: My Access Key
ttl: 1728000
type: User
user: my-user
status: {}
Owned Access Key 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 Create: Owned Access Key
You can either use curl or kubectl to create a new Owned Access Key.
- kubectl
- curl
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: OwnedAccessKey
metadata:
creationTimestamp: null
name: my-access-key
spec:
displayName: My Access Key
ttl: 1728000
type: User
user: my-user
status: {}
Then create the Owned Access Key my-access-key
with:
kubectl create -f object.yaml
Create a file object.yaml
with the following contents:
apiVersion: management.loft.sh/v1
kind: OwnedAccessKey
metadata:
creationTimestamp: null
name: my-access-key
spec:
displayName: My Access Key
ttl: 1728000
type: User
user: my-user
status: {}
Run the following curl command to create a new Owned Access Key my-access-key
:
curl -s -X POST --insecure \
"https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/ownedaccesskeys" \
--data-binary "$(cat object.yaml)" \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY"
Update: Owned Access Key
You can either use curl or kubectl to update Owned Access Keys.
- kubectl
- curl
Update Owned Access Key
Run the following command to update Owned Access Key my-access-key
:
kubectl edit ownedaccesskeys.management.loft.sh my-access-key
Then edit the object and upon save, kubectl will update the resource.
Patch Owned Access Key
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 Owned Access Key my-access-key
via a patch:
kubectl patch ownedaccesskeys.management.loft.sh my-access-key \
--type json \
-p '[{"op": "add", "path": "/metadata/annotations/my-annotation", "value": "my-value"}]'
Update Owned Access Key
First retrieve the current object into a file object.yaml
. This could look like:
apiVersion: management.loft.sh/v1
kind: OwnedAccessKey
metadata:
creationTimestamp: "2023-04-03T00:00:00Z"
generation: 12
name: my-access-key
resourceVersion: "66325905"
uid: af5f9f0f-8ab9-4b4b-a595-a95a5921f3c2
spec:
displayName: My Access Key
ttl: 1728000
type: User
user: my-user
status: {}
Run the following curl command to update a single Owned Access Key my-access-key
:
# Replace the my-access-key in the url below with the name of the Owned Access Key you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/ownedaccesskeys/my-access-key" \
-X PUT --insecure \
-H "Content-Type: application/yaml" \
-H "Authorization: Bearer $ACCESS_KEY" \
--data-binary "$(cat object.yaml)"
Patch Owned Access Key
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 Owned Access Key my-access-key
via a patch:
# Replace the my-access-key in the url below with the name of the Owned Access Key you want to update
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/ownedaccesskeys/my-access-key" \
-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: Owned Access Key
You can either use curl or kubectl to delete Owned Access Keys.
- kubectl
- curl
Run the following command to delete Owned Access Key my-access-key
:
kubectl delete ownedaccesskeys.management.loft.sh my-access-key
Run the following curl command to delete Owned Access Key my-access-key
:
# Replace the my-access-key in the url below with the name of the Owned Access Key you want to delete
curl -s "https://$LOFT_DOMAIN/kubernetes/management/apis/management.loft.sh/v1/ownedaccesskeys/my-access-key" \
-X DELETE --insecure \
-H "Authorization: Bearer $ACCESS_KEY"