Skip to content

Commit 5ca4390

Browse files
authored
Merge pull request #8 from kcp-dev/rename-platform-kcp
🌱 Reword "platform" to "kcp"
2 parents 4107481 + 618a2b0 commit 5ca4390

File tree

17 files changed

+134
-138
lines changed

17 files changed

+134
-138
lines changed

cmd/api-syncagent/main.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,45 +100,45 @@ func run(ctx context.Context, log *zap.SugaredLogger, opts *Options) error {
100100
}
101101

102102
// load the kcp kubeconfig
103-
platformRestConfig, err := loadKubeconfig(opts.PlatformKubeconfig)
103+
kcpRestConfig, err := loadKubeconfig(opts.KcpKubeconfig)
104104
if err != nil {
105-
return fmt.Errorf("failed to load platform kubeconfig: %w", err)
105+
return fmt.Errorf("failed to load kcp kubeconfig: %w", err)
106106
}
107107

108108
// sanity check
109-
if !strings.Contains(platformRestConfig.Host, "/clusters/") {
110-
return fmt.Errorf("platform kubeconfig does not point to a specific workspace")
109+
if !strings.Contains(kcpRestConfig.Host, "/clusters/") {
110+
return fmt.Errorf("kcp kubeconfig does not point to a specific workspace")
111111
}
112112

113-
// We check if the APIExport exists and extract information we need to set up our platformCluster.
114-
apiExport, lcPath, lcName, err := resolveAPIExport(ctx, platformRestConfig, opts.APIExportRef)
113+
// We check if the APIExport exists and extract information we need to set up our kcpCluster.
114+
apiExport, lcPath, lcName, err := resolveAPIExport(ctx, kcpRestConfig, opts.APIExportRef)
115115
if err != nil {
116116
return fmt.Errorf("failed to resolve APIExport: %w", err)
117117
}
118118

119119
log.Infow("Resolved APIExport", "apigroup", opts.APIExportRef, "workspace", lcPath, "logicalcluster", lcName)
120120

121-
// init the "permanent" platform cluster connection
122-
platformCluster, err := setupPlatformCluster(platformRestConfig, opts)
121+
// init the "permanent" kcp cluster connection
122+
kcpCluster, err := setupKcpCluster(kcpRestConfig, opts)
123123
if err != nil {
124-
return fmt.Errorf("failed to initialize platform cluster: %w", err)
124+
return fmt.Errorf("failed to initialize kcp cluster: %w", err)
125125
}
126126

127-
// start the platform cluster caches when the manager boots up
127+
// start the kcp cluster caches when the manager boots up
128128
// (happens regardless of leader election status)
129-
if err := mgr.Add(platformCluster); err != nil {
130-
return fmt.Errorf("failed to add platform cluster runnable: %w", err)
129+
if err := mgr.Add(kcpCluster); err != nil {
130+
return fmt.Errorf("failed to add kcp cluster runnable: %w", err)
131131
}
132132

133-
if err := apiresourceschema.Add(mgr, platformCluster, lcName, log, 4, opts.AgentName, opts.APIExportRef, opts.PublishedResourceSelector); err != nil {
133+
if err := apiresourceschema.Add(mgr, kcpCluster, lcName, log, 4, opts.AgentName, opts.APIExportRef, opts.PublishedResourceSelector); err != nil {
134134
return fmt.Errorf("failed to add apiresourceschema controller: %w", err)
135135
}
136136

137-
if err := apiexport.Add(mgr, platformCluster, lcName, log, opts.APIExportRef, opts.AgentName, opts.PublishedResourceSelector); err != nil {
137+
if err := apiexport.Add(mgr, kcpCluster, lcName, log, opts.APIExportRef, opts.AgentName, opts.PublishedResourceSelector); err != nil {
138138
return fmt.Errorf("failed to add apiexport controller: %w", err)
139139
}
140140

141-
if err := syncmanager.Add(ctx, mgr, platformCluster, platformRestConfig, log, apiExport, opts.PublishedResourceSelector); err != nil {
141+
if err := syncmanager.Add(ctx, mgr, kcpCluster, kcpRestConfig, log, apiExport, opts.PublishedResourceSelector); err != nil {
142142
return fmt.Errorf("failed to add syncmanager controller: %w", err)
143143
}
144144

@@ -231,9 +231,9 @@ func resolveAPIExport(ctx context.Context, restConfig *rest.Config, apiExportRef
231231
return apiExport, lcPath, lcName, nil
232232
}
233233

234-
// setupPlatformCluster sets up a plain, non-kcp-aware ctrl-runtime Cluster object
234+
// setupKcpCluster sets up a plain, non-kcp-aware ctrl-runtime Cluster object
235235
// that is solvely used to interact with the APIExport and APIResourceSchemas.
236-
func setupPlatformCluster(restConfig *rest.Config, opts *Options) (cluster.Cluster, error) {
236+
func setupKcpCluster(restConfig *rest.Config, opts *Options) (cluster.Cluster, error) {
237237
scheme := runtime.NewScheme()
238238

239239
if err := kcpdevv1alpha1.AddToScheme(scheme); err != nil {
@@ -246,7 +246,7 @@ func setupPlatformCluster(restConfig *rest.Config, opts *Options) (cluster.Clust
246246

247247
return cluster.New(restConfig, func(o *cluster.Options) {
248248
o.Scheme = scheme
249-
// RBAC on the platform cluster is very tight and does not allow to list/watch all objects;
249+
// RBAC in kcp might be very tight and might not allow to list/watch all objects;
250250
// restrict the cache's selectors accordingly so we can still make use of caching.
251251
o.Cache = cache.Options{
252252
Scheme: scheme,

cmd/api-syncagent/options.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ type Options struct {
3535
// work.
3636
// KubeconfigFile string
3737

38-
// PlatformKubeconfig is the kubeconfig that gives access to kcp. This
38+
// KcpKubeconfig is the kubeconfig that gives access to kcp. This
3939
// kubeconfig's cluster URL has to point to the workspace where the APIExport
4040
// referenced via APIExportRef lives.
41-
PlatformKubeconfig string
41+
KcpKubeconfig string
4242

4343
// Namespace is the namespace that the Sync Agent runs in.
4444
Namespace string
@@ -49,7 +49,7 @@ type Options struct {
4949

5050
// AgentName can be used to give this Sync Agent instance a custom name. This name is used
5151
// for the Sync Agent resource inside kcp. This value must not be changed after a Sync Agent
52-
// has registered for the first time in the platform.
52+
// has registered for the first time in kcp.
5353
// If not given, defaults to "<service ref>-syncagent".
5454
AgentName string
5555

@@ -77,7 +77,7 @@ func NewOptions() *Options {
7777
func (o *Options) AddFlags(flags *pflag.FlagSet) {
7878
o.LogOptions.AddPFlags(flags)
7979

80-
flags.StringVar(&o.PlatformKubeconfig, "platform-kubeconfig", o.PlatformKubeconfig, "kubeconfig file of kcp")
80+
flags.StringVar(&o.KcpKubeconfig, "kcp-kubeconfig", o.KcpKubeconfig, "kubeconfig file of kcp")
8181
flags.StringVar(&o.Namespace, "namespace", o.Namespace, "Kubernetes namespace the Sync Agent is running in")
8282
flags.StringVar(&o.AgentName, "agent-name", o.AgentName, "name of this Sync Agent, must not be changed after the first run, can be left blank to auto-generate a name")
8383
flags.StringVar(&o.APIExportRef, "apiexport-ref", o.APIExportRef, "name of the APIExport in kcp that this Sync Agent is powering")
@@ -108,8 +108,8 @@ func (o *Options) Validate() error {
108108
errs = append(errs, errors.New("--apiexport-ref is required"))
109109
}
110110

111-
if len(o.PlatformKubeconfig) == 0 {
112-
errs = append(errs, errors.New("--platform-kubeconfig is required"))
111+
if len(o.KcpKubeconfig) == 0 {
112+
errs = append(errs, errors.New("--kcp-kubeconfig is required"))
113113
}
114114

115115
if s := o.PublishedResourceSelectorString; len(s) > 0 {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ spec:
244244
description: ConfigMap or Secret
245245
type: string
246246
origin:
247-
description: '"service" or "platform"'
247+
description: '"service" or "kcp"'
248248
type: string
249249
reference:
250250
properties:

docs/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@ The intended usecase follows roughly these steps:
1717
inside of kcp.
1818
4. The service owner uses the Sync Agent Helm chart (or similar deployment technique) to install the
1919
Sync Agent in their cluster.
20-
5. To actually make resources available in the platform, the service owner now has to create a
21-
set of `PublishedResource` objects. The configuration happens from their point of view, meaning
22-
they define how to publish a CRD to the platform, defining renaming rules and other projection
23-
settings.
20+
5. To actually make resources available in kcp, the service owner now has to create a set of
21+
`PublishedResource` objects. The configuration happens from their point of view, meaning they
22+
define how to publish a CRD to kcp, defining renaming rules and other projection settings.
2423
6. Once a `PublishedResource` is created in the service cluster, the Sync Agent will pick it up,
2524
find the referenced CRD, convert/project this CRD into an `APIResourceSchema` (ARS) for kcp and
2625
then create the ARS in org workspace.
2726
7. Finally the Sync Agent will take all `PublishedResources` and bundle them into the pre-existing
2827
`APIExport` in the org workspace. This APIExport can then be bound in the org workspace itself
2928
(or later any workspaces (depending on permissions)) and be used there.
3029
8. kcp automatically provides a virtual workspace for the `APIExport` and this is what the Sync Agent
31-
then uses to watch all objects for the relevant resources in the platform (i.e. in all workspaces).
30+
then uses to watch all objects for the relevant resources in kcp (i.e. in all workspaces).
3231
9. The Sync Agent will now begin to synchronize objects back and forth between the service cluster
3332
and kcp.
3433

@@ -100,8 +99,8 @@ In addition to projecting (mapping) the GVK, the `PublishedResource` also contai
10099
rules, which influence how the local objects that the Sync Agent is creating are named.
101100

102101
As a single Sync Agent serves a single service, the API group used in kcp is the same for all
103-
`PublishedResources`. It's the API group configured in the `APIExport` inside the platform (created
104-
in step 1 in the overview above).
102+
`PublishedResources`. It's the API group configured in the `APIExport` inside kcp (created in step 1
103+
in the overview above).
105104

106105
To prevent chaos, `PublishedResources` are immutable: handling the case that a PR first wants to
107106
publish `kubermatic.k8c.io/v1 Cluster` and then suddenly `kubermatic.k8c.io/v1 User` resources would

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ syncAgent:
7373

7474
# Required: Name of the Kubernetes Secret that contains a "kubeconfig" key, with the kubeconfig
7575
# provided by kcp to access it.
76-
platformKubeconfig: kcp-kubeconfig
76+
kcpKubeconfig: kcp-kubeconfig
7777

7878
# Create additional RBAC on the service cluster. These rules depend somewhat on the Sync Agent
7979
# configuration, but the following two rules are very common. If you configure the Sync Agent to

docs/publish-resources.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Publishing Resources
22

33
The guide describes the process of making a resource (usually defined by a CustomResourceDefinition)
4-
of one Kubernetes cluster (the "service cluster" or "local cluster") available for use in kcp (the
5-
"platform cluster" or "workspaces"). This involves setting up an `APIExport` and then installing
6-
the Sync Agent and defining `PublishedResources` in the local cluster.
4+
of one Kubernetes cluster (the "service cluster" or "local cluster") available for use in kcp. This
5+
involves setting up an `APIExport` and then installing the Sync Agent and defining
6+
`PublishedResources` in the local cluster.
77

88
All of the documentation and API types are worded and named from the perspective of a service owner,
99
the person(s) who own a service and want to make it available to consumers in kcp.
@@ -12,7 +12,7 @@ the person(s) who own a service and want to make it available to consumers in kc
1212

1313
A "service" comprises a set of resources within a single Kubernetes API group. It doesn't need to be
1414
_all_ of the resources in that group, service owners are free and encouraged to only make a subset
15-
of resources (i.e. a subset of CRDs) available for use in the platform.
15+
of resources (i.e. a subset of CRDs) available for use in kcp.
1616

1717
For each of the CRDs on the service cluster that should be published, the service owner creates a
1818
`PublishedResource` object, which will contain both which CRD to publish, as well as numerous other
@@ -80,15 +80,15 @@ CRD.
8080
### Projection
8181
8282
For stronger separation of concerns and to enable whitelabelling of services, the type meta for
83-
can be projected, i.e. changed between the local service cluster and the platform. You could for
84-
example rename `Certificate` from cert-manager to `Sertifikat` inside the platform.
83+
can be projected, i.e. changed between the local service cluster and kcp. You could for example
84+
rename `Certificate` from cert-manager to `Sertifikat` inside kcp.
8585

8686
Note that the API group of all published resources is always changed to the one defined in the
87-
APIExport object (meaning 1 Sync Agent serves all the selected published resources under the
88-
same API group). That is why changing the API group cannot be configured in the projection.
87+
APIExport object (meaning 1 Sync Agent serves all the selected published resources under the same
88+
API group). That is why changing the API group cannot be configured in the projection.
8989

9090
Besides renaming the Kind and Version, dependent fields like Plural, ShortNames and Categories
91-
can be adjusted to fit the desired naming scheme in the platform. The Plural name is computed
91+
can be adjusted to fit the desired naming scheme in kcp. The Plural name is computed
9292
automatically, but can be overridden. ShortNames and Categories are copied unless overwritten in the
9393
`PublishedResource`.
9494

@@ -111,7 +111,7 @@ spec:
111111
# scope: Namespaced # change only when you know what you're doing
112112
```
113113

114-
Consumers (end users) in the platform would then ultimately see projected names only. Note that GVK
114+
Consumers (end users) in kcp would then ultimately see projected names only. Note that GVK
115115
projection applies only to the synced object itself and has no effect on the contents of these
116116
objects. To change the contents, use external solutions like Crossplane to transform objects.
117117
<!-- To change the contents, use *Mutations*. -->
@@ -134,8 +134,8 @@ are available:
134134
* `$remoteNameHash` – first 20 hex characters of the SHA-1 hash of `$remoteName`
135135

136136
If nothing is configured, the default ensures that no collisions will happen: Each workspace in
137-
the platform will create a namespace on the local cluster, with a combination of namespace and
138-
name hashes used for the actual resource names.
137+
kcp will create a namespace on the local cluster, with a combination of namespace and name hashes
138+
used for the actual resource names.
139139

140140
```yaml
141141
apiVersion: syncagent.kcp.io/v1alpha1
@@ -162,7 +162,7 @@ Configuration happens `spec.mutation` and there are two fields:
162162
be other top-level fields) from the remote side to the local side. Use this to apply defaulting,
163163
normalising, and enforcing rules.
164164
* `status` contains the mutation rules when syncing the `status` subresource back from the local
165-
cluster up into the platform. Use this to normalize names and values (e.g. if you rewrote
165+
cluster up into kcp. Use this to normalize names and values (e.g. if you rewrote
166166
`.spec.secretName` from `"foo"` to `"dfkbssbfh"`, make sure the status does not "leak" this name
167167
by accident).
168168

@@ -285,7 +285,7 @@ spec:
285285
# "connection-details" or "credentials".
286286
identifier: tls-secret
287287
288-
# "service" or "platform"
288+
# "service" or "kcp"
289289
origin: service
290290
291291
# for now, only "Secret" and "ConfigMap" are supported;
@@ -354,7 +354,7 @@ spec:
354354
name: "$remoteClusterName-$remoteNamespaceHash-$remoteNameHash"
355355
356356
related:
357-
- origin: service # service or platform
357+
- origin: service # service or kcp
358358
kind: Secret # for now, only "Secret" and "ConfigMap" are supported;
359359
# there is no GVK projection for related resources
360360
@@ -383,10 +383,9 @@ The following sections go into more details of the behind the scenes magic.
383383
### Synchronization
384384

385385
Even though the whole configuration is written from the standpoint of the service owner, the actual
386-
synchronization logic considers the platform side as the canonical source of truth. The Sync Agent
387-
continuously tries to make the local objects look like the ones in the platform, while pushing
388-
status updates back into the platform (if the given `PublishedResource` (i.e. CRD) has a `status`
389-
subresource enabled).
386+
synchronization logic considers the kcp side as the canonical source of truth. The Sync Agent
387+
continuously tries to make the local objects look like the ones in kcp, while pushing status updates
388+
back into kcp (if the given `PublishedResource` (i.e. CRD) has a `status` subresource enabled).
390389

391390
### Local <-> Remote Connection
392391

@@ -399,7 +398,7 @@ reconciliations, the (potentially costly, but probably not) renaming logic does
399398
applied again. This allows the Sync Agent to change defaults and also allows the service owner to make
400399
changes to the naming rules without breaking existing objects.
401400

402-
Since we do not want to store metadata on the platform side, we instead rely on label selectors on
401+
Since we do not want to store metadata on the kcp side, we instead rely on label selectors on
403402
the local objects. Each object on the service cluster has a label for the remote cluster name,
404403
namespace and object name, and when trying to find the matching local object, the Sync Agent simply
405404
does a label-based search.
@@ -432,8 +431,8 @@ service cluster is called the `destination object`.
432431

433432
#### Phase 2: Handle Deletion
434433

435-
A finalizer is used in the platform workspaces to prevent orphans in the service cluster side. This
436-
is the only real evidence in the platform side that the Sync Agent is even doing things. When a remote
434+
A finalizer is used in the kcp workspaces to prevent orphans in the service cluster side. This
435+
is the only real evidence in the kcp side that the Sync Agent is even doing things. When a remote
437436
(source) object is deleted, the corresponding local object is deleted as well. Once the local object
438437
is gone, the finalizer is removed from the source object.
439438

0 commit comments

Comments
 (0)