@@ -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
@@ -1013,6 +1029,13 @@ Session affinity affects a service as a whole for a given consumer. The derived
1013
1029
service's session affinity will be decided according to the conflict resolution
1014
1030
policy.
1015
1031
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
+
1016
1039
# ## Test Plan
1017
1040
1018
1041
E2E tests can use [kind](https://kind.sigs.k8s.io/) to create multiple clusters
@@ -1229,7 +1252,7 @@ retain the flexibility of selectors.
1229
1252
1230
1253
# ## Export via annotation
1231
1254
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
1233
1256
replaced with an annotation, e.g. `multicluster.kubernetes.io/export`. When a
1234
1257
service is found with the annotation, it would be considered marked for export
1235
1258
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
1258
1281
ServiceExport oldness makes resolving conflicts straightforward, and this
1259
1282
alternative conflict resolution algorithm could hinder this ease of use.
1260
1283
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
+
1261
1309
# # Infrastructure Needed
1262
1310
<!--
1263
1311
Use this section if you need things from the project/SIG. Examples include a
0 commit comments