@@ -107,6 +107,7 @@ tags, and then generate with `hack/update-toc.sh`.
107
107
- [ Service Port] ( #service-port )
108
108
- [ Headlessness] ( #headlessness )
109
109
- [ Session Affinity] ( #session-affinity )
110
+ - [ Labels and Annotations] ( #labels-and-annotations )
110
111
- [ Test Plan] ( #test-plan )
111
112
- [ Graduation Criteria] ( #graduation-criteria )
112
113
- [ Alpha -> ; Beta Graduation] ( #alpha---beta-graduation )
@@ -119,6 +120,7 @@ tags, and then generate with `hack/update-toc.sh`.
119
120
- [ Export services via label selector] ( #export-services-via-label-selector )
120
121
- [ Export via annotation] ( #export-via-annotation )
121
122
- [ Other conflict resolution algorithms] ( #other-conflict-resolution-algorithms )
123
+ - [ Exporting labels/annotations from the Service/ServiceExport objects] ( #exporting-labelsannotations-from-the-serviceserviceexport-objects )
122
124
- [ Infrastructure Needed] ( #infrastructure-needed )
123
125
<!-- /toc -->
124
126
@@ -413,9 +415,19 @@ type ServiceExport struct {
413
415
// +optional
414
416
metav1.ObjectMeta ` json:"metadata,omitempty"`
415
417
// +optional
418
+ Spec ServiceExportSpec ` json:"spec,omitempty"`
419
+ // +optional
416
420
Status ServiceExportStatus ` json:"status,omitempty"`
417
421
}
418
422
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
+
419
431
// ServiceExportStatus contains the current status of an export.
420
432
type ServiceExportStatus struct {
421
433
// +optional
@@ -497,9 +509,13 @@ single authority across all clusters. It is that authority’s responsibility to
497
509
ensure that a name is shared by multiple services within the namespace if and
498
510
only if they are instances of the same service.
499
511
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.
503
519
504
520
Deleting a `ServiceExport` will stop exporting the name-mapped `Service`.
505
521
@@ -1019,6 +1035,13 @@ Session affinity affects a service as a whole for a given consumer. The derived
1019
1035
service's session affinity will be decided according to the conflict resolution
1020
1036
policy.
1021
1037
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
+
1022
1045
# ## Test Plan
1023
1046
1024
1047
E2E tests can use [kind](https://kind.sigs.k8s.io/) to create multiple clusters
@@ -1235,7 +1258,7 @@ retain the flexibility of selectors.
1235
1258
1236
1259
# ## Export via annotation
1237
1260
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
1239
1262
replaced with an annotation, e.g. `multicluster.kubernetes.io/export`. When a
1240
1263
service is found with the annotation, it would be considered marked for export
1241
1264
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
1264
1287
ServiceExport oldness makes resolving conflicts straightforward, and this
1265
1288
alternative conflict resolution algorithm could hinder this ease of use.
1266
1289
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
+
1267
1315
# # Infrastructure Needed
1268
1316
<!--
1269
1317
Use this section if you need things from the project/SIG. Examples include a
0 commit comments