Skip to content

Commit 17e4c2b

Browse files
committed
/docs: rename CachedResource to ClusterCachedResource
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
1 parent d3f8e36 commit 17e4c2b

4 files changed

Lines changed: 51 additions & 48 deletions

File tree

docs/content/concepts/apis/cached-resources.md

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
# CachedResource API
1+
# Cached resource API
22

33
!!! warning
44
As of 0.29, this feature is of alpha-version quality. To use it, enable the `CachedAPIs` feature gate.
55

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

811
## Resource replication
912

1013
```yaml
1114
apiVersion: cache.kcp.io/v1alpha1
12-
kind: CachedResource
15+
kind: ClusterCachedResource
1316
metadata:
1417
name: cpuflavors-v1
1518
spec:
@@ -20,16 +23,16 @@ spec:
2023
2124
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:
2225

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.
2427
- The resource must be cluster scoped.
2528
- The resource must not be a [built-in API](./built-in.md) or kcp system API belonging to `apis.kcp.io` group.
2629
- The resource may be originating from a CRD or an APIBinding.
2730

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

3033
```yaml
3134
apiVersion: cache.kcp.io/v1alpha1
32-
kind: CachedResource
35+
kind: ClusterCachedResource
3336
metadata:
3437
name: cpuflavors-v1
3538
status:
@@ -50,10 +53,10 @@ status:
5053
local: 8 # (2)
5154
```
5255

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

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

5861
```mermaid
5962
flowchart TD
@@ -63,31 +66,31 @@ flowchart TD
6366
cpuflavorsCRD["CPUFlavors CRD"]
6467
cpuflavorCRs["CPUFlavor objects..."]
6568
66-
cpuflavorsCachedResource["CPUFlavors CachedResource"]
69+
cpuflavorsClusterCachedResource["CPUFlavors ClusterCachedResource"]
6770
6871
cpuflavorCRs -."From".-> cpuflavorsCRD
69-
cpuflavorsCachedResource -.Watches.-> cpuflavorCRs
72+
cpuflavorsClusterCachedResource -.Watches.-> cpuflavorCRs
7073
end
7174
72-
cpuflavorsCachedResource -."Replicates CPUFlavor objects into".-> cacheServer
75+
cpuflavorsClusterCachedResource -."Replicates CPUFlavor objects into".-> cacheServer
7376
```
7477

75-
You can optionally configure the following additional aspects of a CachedResource:
78+
You can optionally configure the following additional aspects of a ClusterCachedResource:
7679

7780
- its identity
7881
- resource selector
7982

8083
We'll talk about each of these next.
8184

82-
### CachedResource identity
85+
### ClusterCachedResource identity
8386

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

8689
The identity **key** is considered a private key and should not be shared.
8790

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

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

9295
```yaml
9396
apiVersion: v1
@@ -99,7 +102,7 @@ stringData:
99102
key: "<Your identity key>"
100103
---
101104
apiVersion: cache.kcp.io/v1alpha1
102-
kind: CachedResource
105+
kind: ClusterCachedResource
103106
metadata:
104107
name: cpuflavors-v1
105108
spec:
@@ -112,11 +115,11 @@ spec:
112115

113116
### Selectors
114117

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

117120
```yaml
118121
apiVersion: cache.kcp.io/v1alpha1
119-
kind: CachedResource
122+
kind: ClusterCachedResource
120123
metadata:
121124
name: cpuflavors-v1
122125
spec:
@@ -127,58 +130,58 @@ spec:
127130
cloud.example.com/visibility: Public
128131
```
129132

130-
## Exporting CachedResources
133+
## Exporting ClusterCachedResources
131134

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

134137
**Example user story:**
135138

136139
- You, the **service provider**, run a cloud _Cloud Co._, including a compute service.
137140
- You offer a service of provisioning and running VM instances: users create an `Instance` object and voilà, they have a running VM!
138141
- 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?
139142
- 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.
141144
- 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).
142145
- **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.
143146

144147
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).
145148

146-
### CachedResourceEndpointSlice
149+
### ClusterCachedResourceEndpointSlice
147150

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

150153
```mermaid
151154
flowchart TD
152155
cacheServer["Cache server"]
153156
replicationVW["Replication VW"]
154157
155158
subgraph provider["API Provider Workspace"]
156-
cpuflavorsCachedResource["CPUFlavors CachedResource"]
157-
cpuflavorsCachedResourceEndpointSlice["CPUFlavors CachedResourceEndpointSlice"]
159+
cpuflavorsClusterCachedResource["CPUFlavors ClusterCachedResource"]
160+
cpuflavorsClusterCachedResourceEndpointSlice["CPUFlavors ClusterCachedResourceEndpointSlice"]
158161
159-
cpuflavorsCachedResourceEndpointSlice --> cpuflavorsCachedResource
162+
cpuflavorsClusterCachedResourceEndpointSlice --> cpuflavorsClusterCachedResource
160163
end
161164
162165
replicationVW -."Reads from".-> cacheServer
163-
cpuflavorsCachedResourceEndpointSlice -."Has an endpoint for".-> replicationVW
166+
cpuflavorsClusterCachedResourceEndpointSlice -."Has an endpoint for".-> replicationVW
164167
```
165168

166169
```yaml
167170
apiVersion: cache.kcp.io/v1alpha1
168-
kind: CachedResourceEndpointSlice
171+
kind: ClusterCachedResourceEndpointSlice
169172
metadata:
170173
name: cpuflavors-v1
171174
spec:
172-
cachedResource:
175+
clusterCachedResource:
173176
name: cpuflavors-v1 # (1)
174177
export:
175178
name: vm-provider # (2)
176179
```
177180

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.
179182
2. Name (and optionally the cluster path) of the APIExport this endpoint slice is referenced by.
180183

181-
Both the `cachedResource` and `export` references are immutable once set.
184+
Both the `clusterCachedResource` and `export` references are immutable once set.
182185

183186
```yaml
184187
apiVersion: apis.kcp.io/v1alpha2
@@ -194,27 +197,27 @@ spec:
194197
virtual:
195198
reference: # (2)
196199
apiGroup: cache.kcp.io
197-
kind: CachedResourceEndpointSlice
200+
kind: ClusterCachedResourceEndpointSlice
198201
name: cpuflavors-v1
199202
identityHash: cd2eb0837... # (3)
200203
```
201204

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

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

208211
```mermaid
209212
flowchart TD
210213
subgraph provider["API Provider Workspace"]
211214
export["CPUFlavors APIExport"]
212215
schema["CPUFlavors APIResourceSchema"]
213216
crd["CPUFlavors CRD"]
214-
cpuflavorsCachedResourceEndpointSlice["CPUFlavors CachedResourceEndpointSlice"]
217+
cpuflavorsClusterCachedResourceEndpointSlice["CPUFlavors ClusterCachedResourceEndpointSlice"]
215218
216219
export --> schema
217-
export --> cpuflavorsCachedResourceEndpointSlice
220+
export --> cpuflavorsClusterCachedResourceEndpointSlice
218221
schema -."Is equivalent to".-> crd
219222
end
220223

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ spec:
578578
virtual:
579579
reference: # (1)
580580
apiGroup: cache.kcp.io
581-
kind: CachedResourceEndpointSlice
581+
kind: ClusterCachedResourceEndpointSlice
582582
name: cpuflavors-v1
583583
identityHash: cd2eb0837... # (2)
584584
@@ -587,6 +587,6 @@ spec:
587587
1. The `reference` block defines a reference to an [endpoint slice](#endpoint-slices) object.
588588
2. The `identityHash` refers to the identity hash owned by the virtual resource. This is different from the APIExport identity hash.
589589

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

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

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ The set of object types replicated to the cache server is wired up by the
9393
| `apiexportendpointslices` | `apis.kcp.io/v1alpha1` | always |
9494
| `apiresourceschemas` | `apis.kcp.io/v1alpha1` | always |
9595
| `apiconversions` | `apis.kcp.io/v1alpha1` | always |
96-
| `cachedresources` | `cache.kcp.io/v1alpha1` | always |
97-
| `cachedresourceendpointslices` | `cache.kcp.io/v1alpha1` | always |
96+
| `clustercachedresources` | `cache.kcp.io/v1alpha1` | always |
97+
| `clustercachedresourceendpointslices` | `cache.kcp.io/v1alpha1` | always |
9898
| `shards` | `core.kcp.io/v1alpha1` | always |
9999
| `workspacetypes` | `tenancy.kcp.io/v1alpha1` | always |
100100
| `mutatingwebhookconfigurations` | `admissionregistration.k8s.io/v1` | always |
@@ -106,7 +106,7 @@ The set of object types replicated to the cache server is wired up by the
106106
| `clusterrolebindings` | `rbac.authorization.k8s.io/v1` | annotated `core.kcp.io/replicate` |
107107

108108
User-defined types are added on top of this set via the
109-
[CachedResource API](../apis/cached-resources.md).
109+
[Cached resource API](../apis/cached-resources.md).
110110

111111
Objects in clusters whose name starts with `system:` are excluded from
112112
replication.
@@ -150,12 +150,12 @@ unrelated tenant RBAC stays local.
150150
but does not push the binding back.
151151
- **`Partition` / `PartitionSet`.** These are configuration objects consumed
152152
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
154154
locally per shard, not replicated.
155155

156156
### Adding New Resources
157157

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

160160
### Deletion of Data
161161

docs/content/setup/production/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The main API endpoint for clients to access kcp. This is the main entry point fo
1919

2020
1. **Workspace scheduling**: When a new workspace is scheduled, the shard contacts the front-proxy to randomly pick a shard for the new workspace
2121

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
2323

2424
**Configuration:**
2525
- Set `--externalHostname` or `spec.external.hostname` in front-proxy or shard configurations

0 commit comments

Comments
 (0)