You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is an example `APIExport` called `example.kcp.io` that exports 1 resource: `widgets`.
123
123
124
124
```yaml
125
-
apiVersion: apis.kcp.io/v1alpha1
125
+
apiVersion: apis.kcp.io/v1alpha2
126
126
kind: APIExport
127
127
metadata:
128
128
name: example.kcp.io
129
129
spec:
130
-
latestResourceSchemas:
131
-
- v220801.widgets.example.kcp.io
130
+
resources:
131
+
- group: example.kcp.io
132
+
name: widgets
133
+
schema: v220801.widgets.example.kcp.io
134
+
storage:
135
+
crd: {}
132
136
```
133
137
134
-
At a minimum, you specify the names of the `APIResourceSchema`s you want to export in the `spec.latestResourceSchemas`
135
-
field. The `APIResourceSchemas` must be in the same workspace as the `APIExport` (and therefore no workspace name or
136
-
path is required here).
138
+
At a minimum, you specify the resource group, resource name, name of the `APIResourceSchema` and storage type in `spec.resources`. `APIResourceSchemas` must be in the same workspace as the `APIExport` (and therefore no workspace name or path is required here).
137
139
138
140
You can optionally configure the following additional aspects of an `APIExport`:
139
141
@@ -182,36 +184,34 @@ requested resource by setting the appropriate [API verbs](https://kubernetes.io/
182
184
Let's take the example `APIExport` from above and add permission claims for `ConfigMaps` and `Things`:
@@ -303,9 +311,12 @@ When reconciling exported APIs, controllers usually interact with the API resour
303
311
304
312
### Endpoint Slices
305
313
306
-
An API provider that implements a controller should also create something called an `APIExportEndpointSlice` alongside their `APIExport`. This will "slice and dice" the list of available virtual workspace endpoints. For example, a [Partition](../sharding/partitions.md) can be provided to restrict provided virtual workspace URLs to a part of the sharded kcp setup.
314
+
!!! information "Changed with kcp v0.28"
315
+
Previous versions of kcp did not automatically create an `APIExportEndpointSlice`. Check their respective versioned documentation for details.
316
+
317
+
Since kcp is a sharded system, global access to the resources exposed via an `APIExport` is not trivial and can mean that a service provider has to connect to multiple shard endpoints to get the "full picture". This behaviour of kcp is reflected in `APIExportEndpointSlices`. They return a list of endpoints to connect to for a particular `APIExport`. kcp creates one global `APIExportEndpointSlice` per `APIExport` automatically. So unless a certain partition of the kcp installation should be targeted, it is not required to create one manually. If you wish to disable this behaviour, label your `APIExport` with `apiexports.apis.kcp.io/skip-endpointslice=true`.
307
318
308
-
This is what the resource looks like:
319
+
An API provider that implements a controller can optionally also create an `APIExportEndpointSlice` themselves. This will "slice and dice" the list of available virtual workspace endpoints based on [Partitions](../sharding/partitions.md). This is what it looks like:
309
320
310
321
```yaml title="APIExportEndpointSlice for a partition's virtual workspace endpoints"
311
322
kind: APIExportEndpointSlice
@@ -317,10 +328,11 @@ spec:
317
328
path: root # (1)
318
329
name: example.kcp.io
319
330
# optional
320
-
partition: cloud-region-gcp-europe-xdfgs
331
+
partition: cloud-region-gcp-europe-xdfgs # (2)
321
332
```
322
333
323
-
1. The workspace path at which the `APIExport` sits. This can be in a different workspace than the `APIExportEndpointSlice`
334
+
1. The workspace path at which the `APIExport` sits. This can be in a different workspace than the `APIExportEndpointSlice`.
335
+
2. The `Partition` object targeted by this endpoint slice.
324
336
325
337
Based on this, only virtual workspace URLs for the `cloud-region-gcp-europe-xdfgs` partition will be populated into this endpoint slice. If you wish to get a full list of virtual workspace endpoints, just omit the `spec.partition` field from the example above.
326
338
@@ -395,7 +407,7 @@ TODO
395
407
Returning to our previous example, we can use the following `APIBinding` to import the widgets api.
396
408
397
409
```yaml
398
-
apiVersion: apis.kcp.io/v1alpha1
410
+
apiVersion: apis.kcp.io/v1alpha2
399
411
kind: APIBinding
400
412
metadata:
401
413
name: example.kcp.io
@@ -406,13 +418,15 @@ spec:
406
418
path: "root:api-provider" # path of your api-provider workspace
407
419
```
408
420
421
+
#### Permission Claims
422
+
409
423
Furthermore, `APIBindings` provide the `APIExport` owner access to additional resources defined in an `APIExport`'s permission claims list. Permission claims must be accepted by the user explicitly, before this access is granted. The resources can be builtin Kubernetes resources or resources from other `APIExports`.
410
424
When an `APIExport` is changed after workspaces have bound to it, new or changed APIs are automatically propagated to all `APIBindings`. New permission claims on the other hand are NOT automatically accepted.
411
425
412
426
Returning to our example, we can grant the requested permissions in the `APIBinding`:
413
427
414
428
```yaml
415
-
apiVersion: apis.kcp.io/v1alpha1
429
+
apiVersion: apis.kcp.io/v1alpha2
416
430
kind: APIBinding
417
431
metadata:
418
432
name: example.kcp.io
@@ -423,24 +437,35 @@ spec:
423
437
path: "root:api-provider" # path of your api-provider workspace
It should be noted that `APIBindings` do not create `CRDs` or `APIResourceSchemas`in the workspace. Instead APIs are directly bound using Kubernetes' internal binding mechanism behind the scenes.
440
454
455
+
##### Verbs
456
+
441
457
Operations allowed on the resources for which permission claims are accepted is defined as the intersection of
442
458
the verbs in the APIBinding and the verbs in the appropriate APIExport.
443
459
460
+
##### Selector
461
+
462
+
`APIBindings`allow API consumers to scope an API provider's access to claimed resources via the `selector` field on a permission claim. This means that providers will only be able to see and access those objects matched by the `selector`.
463
+
464
+
!!! information
465
+
Currently, only `selector.matchAll=true` is supported, giving the provider that owns the `APIExport` full access to all objects of a claimed resource. Additional selectors are planned for upcoming releases.
466
+
467
+
---
468
+
444
469
In practice, bound APIs behave similarly to other resources in kcp or Kubernetes. This means you can query for imported APIs using `kubectl api-resources`. Additionally you can use `kubectl explain` to get a detailed view on all fields of the API.
Copy file name to clipboardExpand all lines: docs/content/concepts/sharding/cache-server.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,11 +121,11 @@ Parameters:
121
121
122
122
For example:
123
123
124
-
`/services/cache/shards/*/clusters/*/apis/apis.kcp.io/v1alpha1/apiexports`: for listing apiexports for all shards and clusters
124
+
`/services/cache/shards/*/clusters/*/apis/apis.kcp.io/v1alpha2/apiexports`: for listing apiexports for all shards and clusters
125
125
126
-
`/services/cache/shards/amber/clusters/*/apis/apis.kcp.io/v1alpha1/apiexports`: for listing apiexports for amber shard for all clusters
126
+
`/services/cache/shards/amber/clusters/*/apis/apis.kcp.io/v1alpha2/apiexports`: for listing apiexports for amber shard for all clusters
127
127
128
-
`/services/cache/shards/sapphire/clusters/system:sapphire/apis/apis.kcp.io/v1alpha1/apiexports`: for listing apiexports for sapphire shard stored in system:sapphire cluster
128
+
`/services/cache/shards/sapphire/clusters/system:sapphire/apis/apis.kcp.io/v1alpha2/apiexports`: for listing apiexports for sapphire shard stored in system:sapphire cluster
0 commit comments