|
| 1 | +--- |
| 2 | +description: > |
| 3 | + Explains how to use an external cache server in a kcp installation. |
| 4 | +--- |
| 5 | + |
| 6 | +# kcp cache-server |
| 7 | + |
| 8 | +The kcp cache-server is used to coordinate all shards within one kcp installation. It holds data used |
| 9 | +by all of them, like `APIExports`, `Workspaces` and RBAC to some degree. If no standalone cache is |
| 10 | +configured, then the kcp root shard will run an in-process cache that uses the root shard's etcd as |
| 11 | +its storage backend. However once multiple shards are involved, a standalone cache server should be |
| 12 | +provisioned. |
| 13 | + |
| 14 | +!!! warning |
| 15 | + Currently there is no support for persistence in kcp's cache-server, so whenever the Pod is |
| 16 | + restarted, it will have to be re-filled over time by the kcp shards. |
| 17 | + |
| 18 | +## Architecture |
| 19 | + |
| 20 | +The cache server is a purely passive server: It doesn't connect to any shard or proxy, but instead |
| 21 | +all the kcp shards connect to it, in order to store their data on the cache. This makes the server |
| 22 | +conceptually very simple, since it all it needs to function is a TLS serving certificate. |
| 23 | + |
| 24 | +As of kcp 0.30, there is only a single cache server supported for a whole kcp installation |
| 25 | +consisting of multiple shads). Future kcp releases might extend this to allow multiple, geographically |
| 26 | +close, cache servers. |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +To deploy a cache server, create a `CacheServer` object: |
| 31 | + |
| 32 | +```yaml |
| 33 | +apiVersion: operator.kcp.io/v1alpha1 |
| 34 | +kind: CacheServer |
| 35 | +metadata: |
| 36 | + name: my-cache-server |
| 37 | + namespace: example |
| 38 | +spec: |
| 39 | + certificates: |
| 40 | + issuerRef: |
| 41 | + group: cert-manager.io |
| 42 | + kind: ClusterIssuer |
| 43 | + name: selfsigned |
| 44 | +``` |
| 45 | +
|
| 46 | +The kcp-operator will provision a root CA and a serving certificate for the cache server. For this, |
| 47 | +similar to how `RootShard` work, you need to configure either your desired `ClusterIssuer` or provide |
| 48 | +a pre-existing CA certificate/key as a `Secret`. |
| 49 | + |
| 50 | +Once the `CacheServer` object is created and reconciled, you need to configure the `RootShard` and each |
| 51 | +`Shard` to make use of it, since by default the embedded cache would be enabled. To do so, refer to |
| 52 | +the new `CacheServer` object in your shard: |
| 53 | + |
| 54 | +```yaml |
| 55 | +apiVersion: operator.kcp.io/v1alpha1 |
| 56 | +kind: RootShard |
| 57 | +metadata: |
| 58 | + name: my-root |
| 59 | + namespace: example |
| 60 | +spec: |
| 61 | + # ... |
| 62 | +
|
| 63 | + cache: |
| 64 | + ref: |
| 65 | + name: my-cache-server |
| 66 | +
|
| 67 | + # ... |
| 68 | +``` |
| 69 | + |
| 70 | +Once applied, the kcp-operator will reconfigure the shard `Deployments` accordingly and briefly after |
| 71 | +that, the cache server will be filled with data. |
0 commit comments