Skip to content

Commit 6192589

Browse files
authored
Merge pull request #119 from kcp-dev/more-related-resources
Support arbitrary related resources
2 parents 0227d23 + 34d7ca4 commit 6192589

35 files changed

+2323
-500
lines changed

deploy/crd/kcp.io/syncagent.kcp.io_publishedresources.yaml

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,17 +349,44 @@ spec:
349349
type: object
350350
type: object
351351
related:
352+
description: |-
353+
Related configures additional resources that semantically belong to the synced
354+
resource, like a Secret containing generated credentials. Related objects are
355+
synced along the main resource.
352356
items:
357+
description: |-
358+
RelatedResourceSpec describes a single related resource, which might point to
359+
any number of actual Kubernetes objects.
360+
361+
(in the following rule, group is optional becaue core/v1 is represented by group="")
362+
group is included here because when an identityHash is used, core/v1 cannot possible be targetted
353363
properties:
364+
group:
365+
description: |-
366+
Group is the API group of the related resource. This should be left blank for resources
367+
in the core API group.
368+
type: string
354369
identifier:
355370
description: |-
356371
Identifier is a unique name for this related resource. The name must be unique within one
357372
PublishedResource and is the key by which consumers (end users) can identify and consume the
358373
related resource. Common names are "connection-details" or "credentials".
359374
The identifier must be an alphanumeric string.
360375
type: string
376+
identityHash:
377+
description: |-
378+
IdentityHash is the identity hash of a kcp APIExport, in case the given Kind is
379+
provided by an APIExport and not Kube-native.
380+
type: string
361381
kind:
362-
description: ConfigMap or Secret
382+
description: |-
383+
Kind is the object kind of the related resource (for example "Secret").
384+
385+
Deprecated: Use "Resource" instead. This field is limited to "ConfigMap" and "Secret" and will
386+
be removed in the future. Kind and Resource cannot be specified at the same time.
387+
enum:
388+
- ConfigMap
389+
- Secret
363390
type: string
364391
mutation:
365392
description: |-
@@ -686,12 +713,45 @@ spec:
686713
- service
687714
- kcp
688715
type: string
716+
projection:
717+
description: |-
718+
Projection is used to change the GVK of a related resource on the opposite side of
719+
its origin.
720+
All fields in the projection are optional. If a field is set, it will overwrite
721+
that field in the GVK.
722+
properties:
723+
group:
724+
description: The API group, for example "myservice.example.com". Leave empty to not modify the API group.
725+
type: string
726+
resource:
727+
description: The resource name, for example "databases". Leave empty to not modify the resource.
728+
type: string
729+
version:
730+
description: The API version, for example "v1beta1". Leave empty to not modify the version.
731+
type: string
732+
type: object
733+
resource:
734+
description: Resource is the name of the related resource (for example "secrets").
735+
type: string
736+
version:
737+
description: |-
738+
Version is the API version of the related resource. This can be left blank to automatically
739+
use the preferred version.
740+
type: string
689741
required:
690742
- identifier
691-
- kind
692743
- object
693744
- origin
694745
type: object
746+
x-kubernetes-validations:
747+
- message: must specify either kind (deprecated) or group, version, resource
748+
rule: has(self.kind) != (has(self.version) || has(self.resource))
749+
- message: resource and version must be configured together or not at all
750+
rule: has(self.resource) == has(self.version)
751+
- message: configuring a group also requires a version and resource
752+
rule: '!has(self.group) || (has(self.resource) && has(self.version))'
753+
- message: identity hashes can only be used with GVRs
754+
rule: '!has(self.identityHash) || (has(self.group) && has(self.version) && has(self.resource))'
695755
type: array
696756
resource:
697757
description: |-
@@ -723,6 +783,22 @@ spec:
723783
- apiGroup
724784
- kind
725785
type: object
786+
synchronization:
787+
description: Synchronization allows to configure how the syncagent processes this resource.
788+
properties:
789+
enabled:
790+
description: |-
791+
Enabled can be used to toggle the synchronization as a whole. When set to
792+
false, the syncagent will only copy the CRD and include it in the APIExport,
793+
but not will attempt to synchronize objects of this resource from the kcp
794+
workspaces to the provider.
795+
Synchronization must be disabled for resources that are used as related
796+
resources for other PublishedResources. Otherwise the syncagent would
797+
potentially loop and never finish processing an object.
798+
type: boolean
799+
required:
800+
- enabled
801+
type: object
726802
required:
727803
- resource
728804
type: object

docs/content/faq.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,17 @@ schema from the `APIExport`.
3232

3333
## Does the Sync Agent handle permission claims?
3434

35-
Only those required for its own operation. If you configure a namespaced resource to sync, it will
36-
automatically add a claim for `namespaces` in kcp, plus it will add either `configmaps` or `secrets`
37-
if related resources are configured in a `PublishedResource`. But you cannot specify additional
38-
permissions claims.
35+
Only those required for its own operation. The syncagent will add the following permission claims
36+
to the APIExport it manages:
37+
38+
* `events` (always)
39+
* `namespaces` (always)
40+
* `core.kcp.io/logicalclusters` (if `enableWorkspacePaths` is set in a `PublishedResource`)
41+
* any resource used as related resources (most often this means `configmaps` or `secrets`, but could
42+
be any resource)
43+
44+
The syncagent will always overwrite the entire list of permission claims, i.e. you cannot have custom
45+
claims in an APIExport managed by the api-syncagent.
3946

4047
## I am seeing errors in the agent logs, what's going on?
4148

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
nav:
22
- index.md
3+
- related-resources.md
34
- templating.md
45
- api-lifecycle.md
56
- technical-details.md

0 commit comments

Comments
 (0)