-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2725 from p0lyn0mial/document-replicating-new-type
馃摉 document replicating a new resource
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
docs/content/en/main/concepts/developers/replicate-new-resource.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: "Adding a new resource to the cache server and replication controller" | ||
linkTitle: "Replicating a new resource" | ||
weight: 1 | ||
description: > | ||
How to add a new resource for replication. | ||
--- | ||
|
||
As of today adding a new resource for replication is a manual process that consists of the following steps: | ||
|
||
1. You need to register a new CRD in the cache server. | ||
Registration is required otherwise the cache server won鈥檛 be able to serve the new resource. | ||
It boils down to adding a new entry into [an array](https://github.com/kcp-dev/kcp/blob/53fdaf580d46686686871f77e4a629bc3c234051/pkg/cache/server/bootstrap/bootstrap.go#L46). | ||
If you don鈥檛 have a CRD definition file for your type, you can use [the crdpuller](https://github.com/kcp-dev/kcp/tree/53fdaf580d46686686871f77e4a629bc3c234051/cmd/crd-puller) against any kube-apiserver to create the required manifest. | ||
|
||
2. Next, you need to register the new type in the replication controller. | ||
For that you need to add a new entry into the following [array](https://github.com/kcp-dev/kcp/blob/53fdaf580d46686686871f77e4a629bc3c234051/pkg/reconciler/cache/replication/replication_controller.go#L73) | ||
|
||
In general there are two types of resources. | ||
The ones that are replicated automatically (i.e. APIExports) | ||
and the ones that are subject to additional filtering, for example require some additional annotation (i.e. ClusterRoles). | ||
|
||
For optional resources we usually create [a separate controller](https://github.com/kcp-dev/kcp/blob/53fdaf580d46686686871f77e4a629bc3c234051/pkg/reconciler/tenancy/replicateclusterrole/replicateclusterrole_controller.go) which simply annotates objects that need to be replicated. | ||
Then during registration we provide a filtering function that checks for existence of the annotation (i.e. [filtering function for CR](https://github.com/kcp-dev/kcp/blob/53fdaf580d46686686871f77e4a629bc3c234051/pkg/reconciler/cache/replication/replication_controller.go#L130)) |