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
+40-40Lines changed: 40 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
-
# CachedResource API
1
+
# ClusterCachedResource 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
+
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
7
8
8
## Resource replication
9
9
10
10
```yaml
11
11
apiVersion: cache.kcp.io/v1alpha1
12
-
kind: CachedResource
12
+
kind: ClusterCachedResource
13
13
metadata:
14
14
name: cpuflavors-v1
15
15
spec:
@@ -20,16 +20,16 @@ spec:
20
20
21
21
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
22
23
-
- There may be only one CachedResource for a particular group-version-resource triplet in the workspace.
23
+
- There may be only one ClusterCachedResource for a particular group-version-resource triplet in the workspace.
24
24
- The resource must be cluster scoped.
25
25
- The resource must not be a [built-in API](./built-in.md) or kcp system API belonging to `apis.kcp.io` group.
26
26
- The resource may be originating from a CRD or an APIBinding.
27
27
28
-
Once created, resource replication progress may be checked in CachedResource's status:
28
+
Once created, resource replication progress may be checked in ClusterCachedResource's status:
29
29
30
30
```yaml
31
31
apiVersion: cache.kcp.io/v1alpha1
32
-
kind: CachedResource
32
+
kind: ClusterCachedResource
33
33
metadata:
34
34
name: cpuflavors-v1
35
35
status:
@@ -50,10 +50,10 @@ status:
50
50
local: 8 # (2)
51
51
```
52
52
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.
53
+
1. `cache` resource count refers to the count of objects currently in cache for this ClusterCachedResource.
54
+
2. `local` resource count refers to the count of objects the ClusterCachedResource currently sees in its workspace.
55
55
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.
56
+
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:
75
+
You can optionally configure the following additional aspects of a ClusterCachedResource:
76
76
77
77
- its identity
78
78
- resource selector
79
79
80
80
We'll talk about each of these next.
81
81
82
-
### CachedResource identity
82
+
### ClusterCachedResource identity
83
83
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.
84
+
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
85
86
86
The identity **key** is considered a private key and should not be shared.
87
87
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.
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 ClusterCachedResource.
89
89
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:
90
+
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
91
92
92
```yaml
93
93
apiVersion: v1
@@ -99,7 +99,7 @@ stringData:
99
99
key: "<Your identity key>"
100
100
---
101
101
apiVersion: cache.kcp.io/v1alpha1
102
-
kind: CachedResource
102
+
kind: ClusterCachedResource
103
103
metadata:
104
104
name: cpuflavors-v1
105
105
spec:
@@ -112,11 +112,11 @@ spec:
112
112
113
113
### Selectors
114
114
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.
115
+
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
116
117
117
```yaml
118
118
apiVersion: cache.kcp.io/v1alpha1
119
-
kind: CachedResource
119
+
kind: ClusterCachedResource
120
120
metadata:
121
121
name: cpuflavors-v1
122
122
spec:
@@ -127,58 +127,58 @@ spec:
127
127
cloud.example.com/visibility: Public
128
128
```
129
129
130
-
## Exporting CachedResources
130
+
## Exporting ClusterCachedResources
131
131
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.
132
+
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
133
134
134
**Example user story:**
135
135
136
136
- You, the **service provider**, run a cloud _Cloud Co._, including a compute service.
137
137
- You offer a service of provisioning and running VM instances: users create an `Instance` object and voilà, they have a running VM!
138
138
- 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
139
- 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.
140
+
- You've created a ClusterCachedResource for each flavor type.
141
141
- 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
142
- **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
143
144
144
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
145
146
-
### CachedResourceEndpointSlice
146
+
### ClusterCachedResourceEndpointSlice
147
147
148
-
The CachedResourceEndpointSlice tracks the consumers of the associated APIExport, and needs to be created when you want to export a CachedResource.
148
+
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
163
+
cpuflavorsClusterCachedResourceEndpointSlice -."Has an endpoint for".-> replicationVW
164
164
```
165
165
166
166
```yaml
167
167
apiVersion: cache.kcp.io/v1alpha1
168
-
kind: CachedResourceEndpointSlice
168
+
kind: ClusterCachedResourceEndpointSlice
169
169
metadata:
170
170
name: cpuflavors-v1
171
171
spec:
172
-
cachedResource:
172
+
clusterCachedResource:
173
173
name: cpuflavors-v1 # (1)
174
174
export:
175
175
name: vm-provider # (2)
176
176
```
177
177
178
-
1. Name (and optionally the cluster path) of the CachedResource this endpoint slice is referencing.
178
+
1. Name (and optionally the cluster path) of the ClusterCachedResource this endpoint slice is referencing.
179
179
2. Name (and optionally the cluster path) of the APIExport this endpoint slice is referenced by.
180
180
181
-
Both the `cachedResource` and `export` references are immutable once set.
181
+
Both the `clusterCachedResource` and `export` references are immutable once set.
182
182
183
183
```yaml
184
184
apiVersion: apis.kcp.io/v1alpha2
@@ -194,27 +194,27 @@ spec:
194
194
virtual:
195
195
reference: # (2)
196
196
apiGroup: cache.kcp.io
197
-
kind: CachedResourceEndpointSlice
197
+
kind: ClusterCachedResourceEndpointSlice
198
198
name: cpuflavors-v1
199
199
identityHash: cd2eb0837... # (3)
200
200
```
201
201
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.
202
+
1. Resource schema must match the schema used by the resource in the associated ClusterCachedResource.
203
+
2. Reference to the ClusterCachedResourceEndpointSlice endpoint slice `cpuflavors-v1`.
204
+
3. Identity hash of the `cpuflavors-v1` ClusterCachedResource object.
205
205
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`.
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 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 [ClusterCachedResource 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