Skip to content

Commit 3fb4087

Browse files
authored
Merge pull request #4922 from MrFreezeex/KEP1645-sync-labels-annotations
KEP 1645: add labels and annotations export
2 parents 178cf35 + 271740f commit 3fb4087

File tree

1 file changed

+52
-4
lines changed
  • keps/sig-multicluster/1645-multi-cluster-services-api

1 file changed

+52
-4
lines changed

keps/sig-multicluster/1645-multi-cluster-services-api/README.md

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ tags, and then generate with `hack/update-toc.sh`.
107107
- [Service Port](#service-port)
108108
- [Headlessness](#headlessness)
109109
- [Session Affinity](#session-affinity)
110+
- [Labels and Annotations](#labels-and-annotations)
110111
- [Test Plan](#test-plan)
111112
- [Graduation Criteria](#graduation-criteria)
112113
- [Alpha -> Beta Graduation](#alpha---beta-graduation)
@@ -119,6 +120,7 @@ tags, and then generate with `hack/update-toc.sh`.
119120
- [Export services via label selector](#export-services-via-label-selector)
120121
- [Export via annotation](#export-via-annotation)
121122
- [Other conflict resolution algorithms](#other-conflict-resolution-algorithms)
123+
- [Exporting labels/annotations from the Service/ServiceExport objects](#exporting-labelsannotations-from-the-serviceserviceexport-objects)
122124
- [Infrastructure Needed](#infrastructure-needed)
123125
<!-- /toc -->
124126

@@ -413,9 +415,19 @@ type ServiceExport struct {
413415
// +optional
414416
metav1.ObjectMeta `json:"metadata,omitempty"`
415417
// +optional
418+
Spec ServiceExportSpec `json:"spec,omitempty"`
419+
// +optional
416420
Status ServiceExportStatus `json:"status,omitempty"`
417421
}
418422

423+
// ServiceExportSpec describes an exported service and extra exported information
424+
type ServiceExportSpec struct {
425+
// +optional
426+
ExportedLabels map[string]string `json:"exportedLabels"`
427+
// +optional
428+
ExportedAnnotations map[string]string `json:"exportedAnnotations"`
429+
}
430+
419431
// ServiceExportStatus contains the current status of an export.
420432
type ServiceExportStatus struct {
421433
// +optional
@@ -497,9 +509,13 @@ single authority across all clusters. It is that authority’s responsibility to
497509
ensure that a name is shared by multiple services within the namespace if and
498510
only if they are instances of the same service.
499511

500-
All information about the service, including ports, backends and topology, will
501-
continue to be stored in the `Service` objects, which are each name mapped to a
502-
`ServiceExport`.
512+
Most information about the service, including ports, backends, topology and
513+
session affinity, will continue to be stored in the `Service` objects, which
514+
are each name mapped to a `ServiceExport`. This does not apply for labels and
515+
annotations which are stored in `ServiceExport` directly in `spec.exportedLabels`
516+
and `spec.exportedAnnotations`. Exporting labels and annotations is optionally
517+
supported by MCS-API implementations. If supported, annotations or labels must
518+
not be exported from the `metadata` of the `Service` or `ServiceExport` resources.
503519

504520
Deleting a `ServiceExport` will stop exporting the name-mapped `Service`.
505521

@@ -1019,6 +1035,13 @@ Session affinity affects a service as a whole for a given consumer. The derived
10191035
service's session affinity will be decided according to the conflict resolution
10201036
policy.
10211037

1038+
#### Labels and Annotations
1039+
1040+
If supported, exporting labels and annotations would affect a `Service` as a whole
1041+
for a given consumer. The derived service's labels and annotations will be decided
1042+
according to the conflict resolution if the set of name/value pairs are not identical
1043+
between the constituent clusters.
1044+
10221045
### Test Plan
10231046

10241047
E2E tests can use [kind](https://kind.sigs.k8s.io/) to create multiple clusters
@@ -1235,7 +1258,7 @@ retain the flexibility of selectors.
12351258

12361259
### Export via annotation
12371260

1238-
`ServiceExport` as described has no spec and seems like it could just be
1261+
`ServiceExport` initially had no spec and seemed like it could just be
12391262
replaced with an annotation, e.g. `multicluster.kubernetes.io/export`. When a
12401263
service is found with the annotation, it would be considered marked for export
12411264
to the clusterset. The controller would then create `EndpointSlices` and an
@@ -1264,6 +1287,31 @@ more confusing for users. Having just one simple deciding factor based on
12641287
ServiceExport oldness makes resolving conflicts straightforward, and this
12651288
alternative conflict resolution algorithm could hinder this ease of use.
12661289

1290+
### Exporting labels/annotations from the Service/ServiceExport objects
1291+
1292+
`Service` and `ServiceExport` have labels and annotations which could be used during
1293+
export and propagated to the `ServiceImport`. However various tools such as kubectl or
1294+
ArgoCD add some labels and annotations which would then need to be actively
1295+
filtered to avoid any conflict. Filtering those labels and annotations is not
1296+
something easy and we chose to avoid this problem entirely by not using the metadata
1297+
object and adding dedicated fields in the spec of the `ServiceExport` resource.
1298+
1299+
Also if we were using the labels and annotations from the metadata of either the
1300+
`ServiceExport` or `Service` resources, it may be more confusing for users as it
1301+
would be the only fields present in both resources. For instance, should an
1302+
implementation merge the labels/annotations from both objects? Should it favor one?
1303+
Should it takes only from the `Service` object? With dedicated fields for labels
1304+
and annotations in the spec of the `ServiceExport` resource, it may becomes more
1305+
straightforward that each resource have their own labels and annotations in their
1306+
metadata and that the exported labels and annotations are from the dedicated
1307+
fields in the `ServiceExport` spec.
1308+
1309+
We also favored dedicated fields on the `ServiceExport` resource to allow for better
1310+
flexibility, as it will allow to export labels and annotations fully decorrelated
1311+
from the `Service` and `ServiceExport` metadata. More flexibility could also be
1312+
achieved with CEL expression on the `ServiceExport` at the cost of greater
1313+
complexity (managing CEL expressions on potentially many `ServiceExport` across clusters).
1314+
12671315
## Infrastructure Needed
12681316
<!--
12691317
Use this section if you need things from the project/SIG. Examples include a

0 commit comments

Comments
 (0)