Skip to content

Commit 4d51108

Browse files
committed
Update "Exporting APIs" page with new v1alpha2 APIs and functionality
On-behalf-of: SAP <[email protected]> Signed-off-by: Marvin Beckers <[email protected]>
1 parent eab68b5 commit 4d51108

File tree

3 files changed

+70
-45
lines changed

3 files changed

+70
-45
lines changed

docs/content/concepts/apis/admission-webhooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ flowchart TD
3232
export --> binding1
3333
export --> binding2
3434
35-
classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px;
36-
classDef resource fill:#e1f3d8,stroke:#82c91e,stroke-width:2px;
35+
classDef state color:#F77
36+
classDef or fill:none,stroke:none
3737
class export,schema,webhook,crd,binding1,binding2 resource;
3838
```
3939

docs/content/concepts/apis/exporting-apis.md

Lines changed: 65 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ flowchart TD
4141
export --> binding1
4242
export --> binding2
4343
44-
classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px;
45-
classDef resource fill:#e1f3d8,stroke:#82c91e,stroke-width:2px;
44+
classDef state color:#F77
45+
classDef or fill:none,stroke:none
4646
class export,schema,binding1,binding2 resource;
4747
```
4848

@@ -122,18 +122,20 @@ workspaces.
122122
Here is an example `APIExport` called `example.kcp.io` that exports 1 resource: `widgets`.
123123

124124
```yaml
125-
apiVersion: apis.kcp.io/v1alpha1
125+
apiVersion: apis.kcp.io/v1alpha2
126126
kind: APIExport
127127
metadata:
128128
name: example.kcp.io
129129
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: {}
132136
```
133137

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).
137139

138140
You can optionally configure the following additional aspects of an `APIExport`:
139141

@@ -182,36 +184,34 @@ requested resource by setting the appropriate [API verbs](https://kubernetes.io/
182184
Let's take the example `APIExport` from above and add permission claims for `ConfigMaps` and `Things`:
183185

184186
```yaml
185-
apiVersion: apis.kcp.io/v1alpha1
187+
apiVersion: apis.kcp.io/v1alpha2
186188
kind: APIExport
187189
metadata:
188190
name: example.kcp.io
189191
spec:
190-
latestResourceSchemas:
191-
- v220801.widgets.example.kcp.io
192+
resources:
193+
- group: example.kcp.io
194+
name: widgets
195+
schema: v220801.widgets.example.kcp.io
196+
storage:
197+
crd: {}
192198
permissionClaims:
193199
- group: "" # (1)
194200
resource: configmaps
195-
resourceSelector: # (2)
196-
- namespace: example-system
197-
name: my-setup
198-
verbs: ["get", "list", "create"] # (4)
201+
verbs: ["get", "list", "create"] # (3)
199202
- group: somegroup.kcp.io
200203
resource: things
201-
identityHash: 5fdf7c7aaf407fd1594566869803f565bb84d22156cef5c445d2ee13ac2cfca6 # (3)
202-
all: true # (5)
203-
verbs: ["*"] # (6)
204+
identityHash: 5fdf7c7aaf407fd1594566869803f565bb84d22156cef5c445d2ee13ac2cfca6 # (2)
205+
verbs: ["*"] # (4)
204206
```
205207

206208
1. This is how you specify the core API group
207-
2. You can claim access to one or more resource instances by namespace and/or name
208-
3. To claim another exported API, you must include its `identityHash`
209-
4. Verbs is a list of the [API verbs](https://kubernetes.io/docs/reference/using-api/api-concepts/#api-verbs)
210-
5. If you aren't claiming access to individual instances, you must specify `all` instead
211-
6. `"*"` is a special "verb" that matches any possible verb
212-
213-
This is essentially a request from the APIProvider, asking each consumer to grant permission for the claimed
214-
resources. If the consumer does not accept a permission claim, the API Provider is not allowed to access the claimed
209+
2. To claim another exported API, you must include its `identityHash`
210+
3. Verbs is a list of the [API verbs](https://kubernetes.io/docs/reference/using-api/api-concepts/#api-verbs)
211+
4. `"*"` is a special "verb" that matches any possible verb
212+
213+
This is essentially a request from the API provider, asking each consumer to grant permission for the claimed
214+
resources. If the consumer does not accept a permission claim, the API provider is not allowed to access the claimed
215215
resources. Consumer acceptance of permission claims is part of the `APIBinding` spec. The operations allowed on the
216216
resource are the intersection of the verbs defined in the `APIExport` and the verbs accepted in the appropriate
217217
`APIBinding`. For more details, see the section on [APIBindings](#apibinding).
@@ -230,14 +230,22 @@ For example: we have an `APIExport` in the `root` workspace called `tenancy.kcp.
230230
for `workspaces` and `workspacetypes`:
231231

232232
```yaml
233-
apiVersion: apis.kcp.io/v1alpha1
233+
apiVersion: apis.kcp.io/v1alpha2
234234
kind: APIExport
235235
metadata:
236236
name: tenancy.kcp.io
237237
spec:
238-
latestResourceSchemas:
239-
- v230110-89146c99.workspacetypes.tenancy.kcp.io
240-
- v230116-832a4a55d.workspaces.tenancy.kcp.io
238+
resources:
239+
- group: tenancy.kcp.io
240+
name: workspaces
241+
schema: v250421-25d98218b.workspaces.tenancy.kcp.io
242+
storage:
243+
crd: {}
244+
- group: tenancy.kcp.io
245+
name: workspacetypes
246+
schema: v250603-d4d365c8e.workspacetypes.tenancy.kcp.io
247+
storage:
248+
crd: {}
241249
maximalPermissionPolicy:
242250
local: {} # (1)
243251
```
@@ -303,9 +311,12 @@ When reconciling exported APIs, controllers usually interact with the API resour
303311

304312
### Endpoint Slices
305313

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`.
307318

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:
309320

310321
```yaml title="APIExportEndpointSlice for a partition's virtual workspace endpoints"
311322
kind: APIExportEndpointSlice
@@ -317,10 +328,11 @@ spec:
317328
path: root # (1)
318329
name: example.kcp.io
319330
# optional
320-
partition: cloud-region-gcp-europe-xdfgs
331+
partition: cloud-region-gcp-europe-xdfgs # (2)
321332
```
322333

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.
324336

325337
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.
326338

@@ -395,7 +407,7 @@ TODO
395407
Returning to our previous example, we can use the following `APIBinding` to import the widgets api.
396408

397409
```yaml
398-
apiVersion: apis.kcp.io/v1alpha1
410+
apiVersion: apis.kcp.io/v1alpha2
399411
kind: APIBinding
400412
metadata:
401413
name: example.kcp.io
@@ -406,13 +418,15 @@ spec:
406418
path: "root:api-provider" # path of your api-provider workspace
407419
```
408420

421+
#### Permission Claims
422+
409423
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`.
410424
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.
411425

412426
Returning to our example, we can grant the requested permissions in the `APIBinding`:
413427

414428
```yaml
415-
apiVersion: apis.kcp.io/v1alpha1
429+
apiVersion: apis.kcp.io/v1alpha2
416430
kind: APIBinding
417431
metadata:
418432
name: example.kcp.io
@@ -423,24 +437,35 @@ spec:
423437
path: "root:api-provider" # path of your api-provider workspace
424438
permissionClaims:
425439
- resource: configmaps
426-
resourceSelector:
427-
- name: my-setup
428-
namespace: example-system
429440
verbs: ["get", "list", "create"]
430441
state: Accepted
442+
selector:
443+
matchAll: true
431444
- resource: things
432445
group: somegroup.kcp.io
433-
all: true
434446
identityHash: 5fdf7c7aaf407fd1594566869803f565bb84d22156cef5c445d2ee13ac2cfca6
435447
verbs: ["*"]
436448
state: Accepted
449+
selector:
450+
matchAll: true
437451
```
438452

439453
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.
440454

455+
##### Verbs
456+
441457
Operations allowed on the resources for which permission claims are accepted is defined as the intersection of
442458
the verbs in the APIBinding and the verbs in the appropriate APIExport.
443459

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+
444469
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.
445470

446471
```sh

docs/content/concepts/sharding/cache-server.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ Parameters:
121121

122122
For example:
123123

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
125125

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
127127

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
129129

130130
#### On the Storage Layer
131131

0 commit comments

Comments
 (0)