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
Copy file name to clipboardExpand all lines: docs/content/concepts/apis/cached-resources.md
+43-40Lines changed: 43 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,18 @@
1
-
# CachedResource API
1
+
# Cached resource API
2
2
3
3
!!! warning
4
4
As of 0.29, this feature is of alpha-version quality. To use it, enable the `CachedAPIs` feature gate.
5
5
6
-
A CachedResource object triggers replication of a user-defined resource from its workspace into kcp's [cache server](../sharding/cache-server.md), extending its [built-in resource set](../sharding/cache-server.md#built-in-resources) with custom types. This makes those resources available across shards, enabling implementors to build globally-aware kcp-native components. API providers can additionally expose replicated resources as read-only to consumer workspaces — see [Exporting CachedResources](#exporting-cachedresources).
6
+
!!! note
7
+
Only a cluster scoped ClusterCachedResource is supported for the time being.
8
+
9
+
A ClusterCachedResource object triggers replication of a user-defined resource from its workspace into kcp's [cache server](../sharding/cache-server.md), extending its [built-in resource set](../sharding/cache-server.md#built-in-resources) with custom types. This makes those resources available across shards, enabling implementors to build globally-aware kcp-native components. API providers can additionally expose replicated resources as read-only to consumer workspaces — see [Exporting ClusterCachedResources](#exporting-clustercachedresources).
7
10
8
11
## Resource replication
9
12
10
13
```yaml
11
14
apiVersion: cache.kcp.io/v1alpha1
12
-
kind: CachedResource
15
+
kind: ClusterCachedResource
13
16
metadata:
14
17
name: cpuflavors-v1
15
18
spec:
@@ -20,16 +23,16 @@ spec:
20
23
21
24
The snippet above shows an example where all `cpuflavors.v1.cloud.example.com` objects in the workspace are replicated to the cache. There are some constraints on what resources may be replicated:
22
25
23
-
- There may be only one CachedResource for a particular group-version-resource triplet in the workspace.
26
+
- There may be only one ClusterCachedResource for a particular group-version-resource triplet in the workspace.
24
27
- The resource must be cluster scoped.
25
28
- The resource must not be a [built-in API](./built-in.md) or kcp system API belonging to `apis.kcp.io` group.
26
29
- The resource may be originating from a CRD or an APIBinding.
27
30
28
-
Once created, resource replication progress may be checked in CachedResource's status:
31
+
Once created, resource replication progress may be checked in ClusterCachedResource's status:
29
32
30
33
```yaml
31
34
apiVersion: cache.kcp.io/v1alpha1
32
-
kind: CachedResource
35
+
kind: ClusterCachedResource
33
36
metadata:
34
37
name: cpuflavors-v1
35
38
status:
@@ -50,10 +53,10 @@ status:
50
53
local: 8 # (2)
51
54
```
52
55
53
-
1. `cache` resource count refers to the count of objects currently in cache for this CachedResource.
54
-
2. `local` resource count refers to the count of objects the CachedResource currently sees in its workspace.
56
+
1. `cache` resource count refers to the count of objects currently in cache for this ClusterCachedResource.
57
+
2. `local` resource count refers to the count of objects the ClusterCachedResource currently sees in its workspace.
55
58
56
-
The objects a CachedResource is watching are always replicated in the direction **from** CachedResource's workspace **into** cache. Note that this means the only way to modify the in-cache copies is to modify the original objects. In-cache objects can be then projected into a workspace as a read-only API. This is done by creating a respective APIExport with [CachedResource virtual resource](#exporting-cachedresources), and binding to it.
59
+
The objects a ClusterCachedResource is watching are always replicated in the direction **from** ClusterCachedResource's workspace **into** cache. Note that this means the only way to modify the in-cache copies is to modify the original objects. In-cache objects can be then projected into a workspace as a read-only API. This is done by creating a respective APIExport with [ClusterCachedResource virtual resource](#exporting-clustercachedresources), and binding to it.
You can optionally configure the following additional aspects of a CachedResource:
78
+
You can optionally configure the following additional aspects of a ClusterCachedResource:
76
79
77
80
- its identity
78
81
- resource selector
79
82
80
83
We'll talk about each of these next.
81
84
82
-
### CachedResource identity
85
+
### ClusterCachedResource identity
83
86
84
-
Similar to the [APIExport identity](./exporting-apis.md#apiexport-identity) concept, there may be many CachedResources with the same group-version-resource triplet across the kcp installation. To differentiate between them and identify owners, a CachedResource object uses a unique identity key stored in a secret.
87
+
Similar to the [APIExport identity](./exporting-apis.md#apiexport-identity) concept, there may be many ClusterCachedResources with the same group-version-resource triplet across the kcp installation. To differentiate between them and identify owners, a ClusterCachedResource object uses a unique identity key stored in a secret.
85
88
86
89
The identity **key** is considered a private key and should not be shared.
87
90
88
-
**Hash** calculated from that key, found at `.status.identityHash`, is considered a public key. APIExport's virtual resource definition expects this identity hash to be supplied when exporting a CachedResource.
91
+
**Hash** calculated from that key, found at `.status.identityHash`, is considered a public key. APIExport's virtual resource definition expects this identity hash to be supplied when exporting a ClusterCachedResource.
89
92
90
-
By default, creating a CachedResource object triggers creation of an identity secret with a randomly generated key in its `key` data item. You can provide your own key by referencing your secret in the object's spec:
93
+
By default, creating a ClusterCachedResource object triggers creation of an identity secret with a randomly generated key in its `key` data item. You can provide your own key by referencing your secret in the object's spec:
91
94
92
95
```yaml
93
96
apiVersion: v1
@@ -99,7 +102,7 @@ stringData:
99
102
key: "<Your identity key>"
100
103
---
101
104
apiVersion: cache.kcp.io/v1alpha1
102
-
kind: CachedResource
105
+
kind: ClusterCachedResource
103
106
metadata:
104
107
name: cpuflavors-v1
105
108
spec:
@@ -112,11 +115,11 @@ spec:
112
115
113
116
### Selectors
114
117
115
-
CachedResource spec has an optional [`labelSelector`](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors) field which can be used to shape the set of objects it picks up.
118
+
ClusterCachedResource spec has an optional [`labelSelector`](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors) field which can be used to shape the set of objects it picks up.
116
119
117
120
```yaml
118
121
apiVersion: cache.kcp.io/v1alpha1
119
-
kind: CachedResource
122
+
kind: ClusterCachedResource
120
123
metadata:
121
124
name: cpuflavors-v1
122
125
spec:
@@ -127,58 +130,58 @@ spec:
127
130
cloud.example.com/visibility: Public
128
131
```
129
132
130
-
## Exporting CachedResources
133
+
## Exporting ClusterCachedResources
131
134
132
-
You can project the replicated read-only objects of a CachedResource into a workspace using the standard APIExport-APIBinding relationship. Create an APIExport and define [virtual resource](./exporting-apis.md#virtual-resources) for the associated [CachedResourceEndpointSlice](#cachedresourceendpointslice). Consumers can then bind to it.
135
+
You can project the replicated read-only objects of a ClusterCachedResource into a workspace using the standard APIExport-APIBinding relationship. Create an APIExport and define [virtual resource](./exporting-apis.md#virtual-resources) for the associated [ClusterCachedResourceEndpointSlice](#clustercachedresourceendpointslice). Consumers can then bind to it.
133
136
134
137
**Example user story:**
135
138
136
139
- You, the **service provider**, run a cloud _Cloud Co._, including a compute service.
137
140
- You offer a service of provisioning and running VM instances: users create an `Instance` object and voilà, they have a running VM!
138
141
- But how do you design the API for configuring such a resource? How do you make your consumers know what configuration options are available, given the limited resources available in the cloud?
139
142
- You've decided to offer different packages for CPUs, memory, storage, GPUs; these are represented as CRDs, e.g. `cpuflavors.cloud.example.com`, `memflavors.cloud.example.com`, with `cpu-small`, `cpu-medium`, `cpu-large`, `mem-medium`, `mem-large`, `mem-xlarge` respectively.
140
-
- You've created a CachedResource for each flavor type.
143
+
- You've created a ClusterCachedResource for each flavor type.
141
144
- You offer the service through an APIExport containing the main `instances.cloud.example.com` resource, as well as all flavors. These are exported as [virtual resources](./exporting-apis.md#virtual-resources).
142
145
- **Consumers** binding to your APIExport can list and get the available flavors from within their workspace (e.g. with `kubectl get cpuflavors`), and refer to them in their `Instance` spec. They cannot create, delete or otherwise modify the flavor objects in any way.
143
146
144
147
See an example usage at [github.com/kcp-dev/kcp/tree/main/config/examples/virtualresources](https://github.com/kcp-dev/kcp/tree/main/config/examples/virtualresources).
145
148
146
-
### CachedResourceEndpointSlice
149
+
### ClusterCachedResourceEndpointSlice
147
150
148
-
The CachedResourceEndpointSlice tracks the consumers of the associated APIExport, and needs to be created when you want to export a CachedResource.
151
+
The ClusterCachedResourceEndpointSlice tracks the consumers of the associated APIExport, and needs to be created when you want to export a ClusterCachedResource.
cpuflavorsCachedResourceEndpointSlice -."Has an endpoint for".-> replicationVW
166
+
cpuflavorsClusterCachedResourceEndpointSlice -."Has an endpoint for".-> replicationVW
164
167
```
165
168
166
169
```yaml
167
170
apiVersion: cache.kcp.io/v1alpha1
168
-
kind: CachedResourceEndpointSlice
171
+
kind: ClusterCachedResourceEndpointSlice
169
172
metadata:
170
173
name: cpuflavors-v1
171
174
spec:
172
-
cachedResource:
175
+
clusterCachedResource:
173
176
name: cpuflavors-v1 # (1)
174
177
export:
175
178
name: vm-provider # (2)
176
179
```
177
180
178
-
1. Name (and optionally the cluster path) of the CachedResource this endpoint slice is referencing.
181
+
1. Name (and optionally the cluster path) of the ClusterCachedResource this endpoint slice is referencing.
179
182
2. Name (and optionally the cluster path) of the APIExport this endpoint slice is referenced by.
180
183
181
-
Both the `cachedResource` and `export` references are immutable once set.
184
+
Both the `clusterCachedResource` and `export` references are immutable once set.
182
185
183
186
```yaml
184
187
apiVersion: apis.kcp.io/v1alpha2
@@ -194,27 +197,27 @@ spec:
194
197
virtual:
195
198
reference: # (2)
196
199
apiGroup: cache.kcp.io
197
-
kind: CachedResourceEndpointSlice
200
+
kind: ClusterCachedResourceEndpointSlice
198
201
name: cpuflavors-v1
199
202
identityHash: cd2eb0837... # (3)
200
203
```
201
204
202
-
1. Resource schema must match the schema used by the resource in the associated CachedResource.
203
-
2. Reference to the CachedResourceEndpointSlice endpoint slice `cpuflavors-v1`.
204
-
3. Identity hash of the `cpuflavors-v1` CachedResource object.
205
+
1. Resource schema must match the schema used by the resource in the associated ClusterCachedResource.
206
+
2. Reference to the ClusterCachedResourceEndpointSlice endpoint slice `cpuflavors-v1`.
207
+
3. Identity hash of the `cpuflavors-v1` ClusterCachedResource object.
205
208
206
-
A `virtual` storage definition needs (1) a reference to an [endpoint slice](./exporting-apis.md#endpoint-slices) object, and (2) a virtual resource identity. In the case of CachedResources, the endpoint slice is provided by CachedResourceEndpointSlice. The identity hash must match the one set in CachedResource's `.status.identityHash`.
209
+
A `virtual` storage definition needs (1) a reference to an [endpoint slice](./exporting-apis.md#endpoint-slices) object, and (2) a virtual resource identity. In the case of ClusterCachedResources, the endpoint slice is provided by ClusterCachedResourceEndpointSlice. The identity hash must match the one set in ClusterCachedResource's `.status.identityHash`.
Copy file name to clipboardExpand all lines: docs/content/concepts/apis/exporting-apis.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -578,7 +578,7 @@ spec:
578
578
virtual:
579
579
reference: # (1)
580
580
apiGroup: cache.kcp.io
581
-
kind: CachedResourceEndpointSlice
581
+
kind: ClusterCachedResourceEndpointSlice
582
582
name: cpuflavors-v1
583
583
identityHash: cd2eb0837... # (2)
584
584
@@ -587,6 +587,6 @@ spec:
587
587
1. The `reference` block defines a reference to an [endpoint slice](#endpoint-slices) object.
588
588
2. The `identityHash` refers to the identity hash owned by the virtual resource. This is different from the APIExport identity hash.
589
589
590
-
kcp currently supports one such virtual resource: see [CachedResource API](./cached-resources.md) for more information.
590
+
kcp currently supports one such virtual resource: see [ClusterCachedResource API](./cached-resources.md) for more information.
591
591
592
592
Virtual resources are generic, and as long as the source virtual workspace implements the endpoint slice machinery, it can be used in APIExport's `virtual` storage definition.
-**`Partition` / `PartitionSet`.** These are configuration objects consumed
152
152
in the workspace where they live and referenced by `APIExportEndpointSlice`.
153
-
-**Identity secrets.** A `CachedResource`'s identity secret is created
153
+
-**Identity secrets.** A `ClusterCachedResource`'s identity secret is created
154
154
locally per shard, not replicated.
155
155
156
156
### Adding New Resources
157
157
158
-
User-defined resources can be added to the cache server using the [CachedResource API](../apis/cached-resources.md). A CachedResource object triggers replication of a cluster-scoped resource from a workspace into the cache, making it available across shards alongside the built-in resource set.
158
+
User-defined resources can be added to the cache server using the [Cached resource API](../apis/cached-resources.md). A ClusterCachedResource object triggers replication of a cluster-scoped resource from a workspace into the cache, making it available across shards alongside the built-in resource set.
Copy file name to clipboardExpand all lines: docs/content/setup/production/overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ The main API endpoint for clients to access kcp. This is the main entry point fo
19
19
20
20
1.**Workspace scheduling**: When a new workspace is scheduled, the shard contacts the front-proxy to randomly pick a shard for the new workspace
21
21
22
-
2.**Endpoint updates**: When an `APIExportEndpointSlice` or `CachedResourceEndpointSlice` URL is updated, the update happens via the front-proxy
22
+
2.**Endpoint updates**: When an `APIExportEndpointSlice` or `ClusterCachedResourceEndpointSlice` URL is updated, the update happens via the front-proxy
23
23
24
24
**Configuration:**
25
25
- Set `--externalHostname` or `spec.external.hostname` in front-proxy or shard configurations
0 commit comments