Skip to content

Commit 271740f

Browse files
committed
KEP 1645: add labels and annotations export
Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
1 parent b646a81 commit 271740f

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 -&gt; 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

@@ -1013,6 +1029,13 @@ Session affinity affects a service as a whole for a given consumer. The derived
10131029
service's session affinity will be decided according to the conflict resolution
10141030
policy.
10151031

1032+
#### Labels and Annotations
1033+
1034+
If supported, exporting labels and annotations would affect a `Service` as a whole
1035+
for a given consumer. The derived service's labels and annotations will be decided
1036+
according to the conflict resolution if the set of name/value pairs are not identical
1037+
between the constituent clusters.
1038+
10161039
### Test Plan
10171040

10181041
E2E tests can use [kind](https://kind.sigs.k8s.io/) to create multiple clusters
@@ -1229,7 +1252,7 @@ retain the flexibility of selectors.
12291252

12301253
### Export via annotation
12311254

1232-
`ServiceExport` as described has no spec and seems like it could just be
1255+
`ServiceExport` initially had no spec and seemed like it could just be
12331256
replaced with an annotation, e.g. `multicluster.kubernetes.io/export`. When a
12341257
service is found with the annotation, it would be considered marked for export
12351258
to the clusterset. The controller would then create `EndpointSlices` and an
@@ -1258,6 +1281,31 @@ more confusing for users. Having just one simple deciding factor based on
12581281
ServiceExport oldness makes resolving conflicts straightforward, and this
12591282
alternative conflict resolution algorithm could hinder this ease of use.
12601283

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

0 commit comments

Comments
 (0)