Skip to content

Commit a0e3f1b

Browse files
fra98adamjensenbot
authored andcommitted
Option to disable reflection of specific labels and annotations
1 parent b7e707e commit a0e3f1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+400
-139
lines changed

cmd/liqo-controller-manager/main.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ func main() {
106106
var kubeletRAMRequests, kubeletRAMLimits argsutils.Quantity
107107
var kubeletMetricsAddress string
108108
var kubeletMetricsEnabled bool
109+
var labelsNotReflected argsutils.StringList
110+
var annotationsNotReflected argsutils.StringList
109111

110112
webhookPort := flag.Uint("webhook-port", 9443, "The port the webhook server binds to")
111113
metricsAddr := flag.String("metrics-address", ":8080", "The address the metric endpoint binds to")
@@ -166,6 +168,8 @@ func main() {
166168
flag.BoolVar(&kubeletMetricsEnabled, "kubelet-metrics-enabled", false, "Enable the kubelet metrics endpoint")
167169
flag.Var(&nodeExtraAnnotations, "node-extra-annotations", "Extra annotations to add to the Virtual Node")
168170
flag.Var(&nodeExtraLabels, "node-extra-labels", "Extra labels to add to the Virtual Node")
171+
flag.Var(&labelsNotReflected, "labels-not-reflected", "List of labels (key) that must not be reflected")
172+
flag.Var(&annotationsNotReflected, "annotations-not-reflected", "List of annotations (key) that must not be reflected")
169173
kubeletIpamServer := flag.String("kubelet-ipam-server", "",
170174
"The address of the IPAM server to use for the virtual kubelet (set to empty string to disable IPAM)")
171175

@@ -187,19 +191,21 @@ func main() {
187191

188192
// Options for the virtual kubelet.
189193
virtualKubeletOpts := &forge.VirtualKubeletOpts{
190-
ContainerImage: *kubeletImage,
191-
ExtraAnnotations: kubeletExtraAnnotations.StringMap,
192-
ExtraLabels: kubeletExtraLabels.StringMap,
193-
ExtraArgs: kubeletExtraArgs.StringList,
194-
NodeExtraAnnotations: nodeExtraAnnotations,
195-
NodeExtraLabels: nodeExtraLabels,
196-
RequestsCPU: kubeletCPURequests.Quantity,
197-
RequestsRAM: kubeletRAMRequests.Quantity,
198-
LimitsCPU: kubeletCPULimits.Quantity,
199-
LimitsRAM: kubeletRAMLimits.Quantity,
200-
IpamEndpoint: *kubeletIpamServer,
201-
MetricsAddress: kubeletMetricsAddress,
202-
MetricsEnabled: kubeletMetricsEnabled,
194+
ContainerImage: *kubeletImage,
195+
ExtraAnnotations: kubeletExtraAnnotations.StringMap,
196+
ExtraLabels: kubeletExtraLabels.StringMap,
197+
ExtraArgs: kubeletExtraArgs.StringList,
198+
NodeExtraAnnotations: nodeExtraAnnotations,
199+
NodeExtraLabels: nodeExtraLabels,
200+
RequestsCPU: kubeletCPURequests.Quantity,
201+
RequestsRAM: kubeletRAMRequests.Quantity,
202+
LimitsCPU: kubeletCPULimits.Quantity,
203+
LimitsRAM: kubeletRAMLimits.Quantity,
204+
IpamEndpoint: *kubeletIpamServer,
205+
MetricsAddress: kubeletMetricsAddress,
206+
MetricsEnabled: kubeletMetricsEnabled,
207+
LabelsNotReflected: labelsNotReflected.StringList,
208+
AnnotationsNotReflected: annotationsNotReflected.StringList,
203209
}
204210

205211
clusterIdentity := clusterIdentityFlags.ReadOrDie()

cmd/virtual-kubelet/root/flag.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ func InstallFlags(flags *pflag.FlagSet, o *Opts) {
7171
flags.Var(&o.NodeExtraAnnotations, "node-extra-annotations", "Extra annotations to add to the Virtual Node")
7272
flags.Var(&o.NodeExtraLabels, "node-extra-labels", "Extra labels to add to the Virtual Node")
7373

74+
flags.Var(&o.LabelsNotReflected, "labels-not-reflected", "List of labels (key) that must not be reflected")
75+
flags.Var(&o.AnnotationsNotReflected, "annotations-not-reflected", "List of annotations (key) that must not be reflected")
76+
7477
flags.BoolVar(&o.EnableAPIServerSupport, "enable-apiserver-support", false,
7578
"Enable offloaded pods to interact back with the local Kubernetes API server")
7679
flags.BoolVar(&o.EnableStorage, "enable-storage", false, "Enable the Liqo storage reflection")

cmd/virtual-kubelet/root/opts.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ type Opts struct {
8989
PersistentVolumeClaimWorkers uint
9090
EventWorkers uint
9191

92+
LabelsNotReflected argsutils.StringList
93+
AnnotationsNotReflected argsutils.StringList
94+
9295
NodeLeaseDuration time.Duration
9396
NodePingInterval time.Duration
9497
NodePingTimeout time.Duration
@@ -140,6 +143,9 @@ func NewOpts() *Opts {
140143
PersistentVolumeClaimWorkers: DefaultPersistenVolumeClaimWorkers,
141144
EventWorkers: DefaultEventWorkers,
142145

146+
LabelsNotReflected: argsutils.StringList{},
147+
AnnotationsNotReflected: argsutils.StringList{},
148+
143149
NodeLeaseDuration: node.DefaultLeaseDuration * time.Second,
144150
NodePingInterval: node.DefaultPingInterval,
145151
NodePingTimeout: DefaultNodePingTimeout,

cmd/virtual-kubelet/root/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ func runRootCommand(ctx context.Context, c *Opts) error {
128128

129129
HomeAPIServerHost: c.HomeAPIServerHost,
130130
HomeAPIServerPort: c.HomeAPIServerPort,
131+
132+
LabelsNotReflected: c.LabelsNotReflected.StringList,
133+
AnnotationsNotReflected: c.AnnotationsNotReflected.StringList,
131134
}
132135

133136
eb := record.NewBroadcaster()

deployments/liqo/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115
| proxy.service.annotations | object | `{}` | |
116116
| proxy.service.type | string | `"ClusterIP"` | |
117117
| pullPolicy | string | `"IfNotPresent"` | The pullPolicy for liqo pods. |
118+
| reflection.skip.annotations | list | `["metallb.universe.tf/ip-allocated-from-pool","metallb.universe.tf/loadBalancerIPs","metallb.universe.tf/address-pool"]` | List of annotations that must not be reflected on remote clusters. |
119+
| reflection.skip.labels | list | `[]` | List of labels that must not be reflected on remote clusters. |
118120
| route.imageName | string | `"ghcr.io/liqotech/liqonet"` | Image repository for the route pod. |
119121
| route.pod.annotations | object | `{}` | Annotations for the route pod. |
120122
| route.pod.extraArgs | list | `[]` | Extra arguments for the route pod. |

deployments/liqo/templates/liqo-controller-manager-deployment.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ spec:
7777
- --liqo-namespace=$(POD_NAMESPACE)
7878
- --enable-incoming-peering={{ .Values.discovery.config.incomingPeeringEnabled }}
7979
- --resource-sharing-percentage={{ .Values.controllerManager.config.resourceSharingPercentage }}
80+
{{- if .Values.reflection.skip.labels }}
81+
{{- $d := dict "commandName" "--labels-not-reflected" "list" .Values.reflection.skip.labels }}
82+
{{- include "liqo.concatenateList" $d | nindent 10 }}
83+
{{- end }}
84+
{{- if .Values.reflection.skip.annotations }}
85+
{{- $d := dict "commandName" "--annotations-not-reflected" "list" .Values.reflection.skip.annotations }}
86+
{{- include "liqo.concatenateList" $d | nindent 10 }}
87+
{{- end }}
8088
- --kubelet-image={{ .Values.virtualKubelet.imageName }}{{ include "liqo.suffix" $ctrlManagerConfig }}:{{ include "liqo.version" $ctrlManagerConfig }}
8189
{{- if .Values.virtualKubelet.metrics.enabled }}
8290
- --kubelet-metrics-address=:{{ .Values.virtualKubelet.metrics.port }}

deployments/liqo/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ networking:
1818
# -- Reflect pod IPs and EnpointSlices to the remote clusters.
1919
reflectIPs: true
2020

21+
reflection:
22+
skip:
23+
# -- List of labels that must not be reflected on remote clusters.
24+
labels: []
25+
# -- List of annotations that must not be reflected on remote clusters.
26+
annotations: [
27+
metallb.universe.tf/ip-allocated-from-pool,
28+
metallb.universe.tf/loadBalancerIPs,
29+
metallb.universe.tf/address-pool,
30+
]
31+
2132
controllerManager:
2233
# -- The number of controller-manager instances to run, which can be increased for active/passive high availability.
2334
replicas: 1

pkg/liqo-controller-manager/storageprovisioner/remoteprovisioner.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ func ProvisionRemotePVC(ctx context.Context,
3636
options controller.ProvisionOptions,
3737
remoteNamespace, remoteRealStorageClass string,
3838
remotePvcLister corev1listers.PersistentVolumeClaimNamespaceLister,
39-
remotePvcClient corev1clients.PersistentVolumeClaimInterface) (*corev1.PersistentVolume, controller.ProvisioningState, error) {
39+
remotePvcClient corev1clients.PersistentVolumeClaimInterface,
40+
forgingOpts *forge.ForgingOpts) (*corev1.PersistentVolume, controller.ProvisioningState, error) {
4041
virtualPvc := options.PVC
4142

4243
labels := options.SelectedNode.GetLabels()
@@ -62,7 +63,7 @@ func ProvisionRemotePVC(ctx context.Context,
6263
default:
6364
}
6465

65-
mutation := remotePersistentVolumeClaim(virtualPvc, remoteStorageClass, remoteNamespace)
66+
mutation := remotePersistentVolumeClaim(virtualPvc, remoteStorageClass, remoteNamespace, forgingOpts)
6667
_, err = remotePvcClient.Apply(ctx, mutation, forge.ApplyOptions())
6768
if err != nil {
6869
return nil, controller.ProvisioningInBackground, err
@@ -110,11 +111,11 @@ func ProvisionRemotePVC(ctx context.Context,
110111

111112
// remotePersistentVolumeClaim forges the apply patch for the reflected PersistentVolumeClaim, given the local one.
112113
func remotePersistentVolumeClaim(virtualPvc *corev1.PersistentVolumeClaim,
113-
storageClass, namespace string) *v1apply.PersistentVolumeClaimApplyConfiguration {
114+
storageClass, namespace string, forgingOpts *forge.ForgingOpts) *v1apply.PersistentVolumeClaimApplyConfiguration {
114115
return v1apply.PersistentVolumeClaim(virtualPvc.Name, namespace).
115-
WithLabels(virtualPvc.GetLabels()).
116+
WithLabels(forge.FilterNotReflected(virtualPvc.GetLabels(), forgingOpts.LabelsNotReflected)).
116117
WithLabels(forge.ReflectionLabels()).
117-
WithAnnotations(filterAnnotations(virtualPvc.GetAnnotations())).
118+
WithAnnotations(forge.FilterNotReflected(filterAnnotations(virtualPvc.GetAnnotations()), forgingOpts.AnnotationsNotReflected)).
118119
WithSpec(remotePersistentVolumeClaimSpec(virtualPvc, storageClass))
119120
}
120121

pkg/liqo-controller-manager/storageprovisioner/storageprovisioner_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import (
3838
"sigs.k8s.io/sig-storage-lib-external-provisioner/v7/controller"
3939

4040
liqoconst "github.com/liqotech/liqo/pkg/consts"
41+
"github.com/liqotech/liqo/pkg/utils/testutil"
42+
"github.com/liqotech/liqo/pkg/virtualKubelet/forge"
4143
)
4244

4345
const (
@@ -269,6 +271,7 @@ var _ = Describe("Test Storage Provisioner", func() {
269271
var (
270272
remotePersistentVolumeClaims corev1listers.PersistentVolumeClaimNamespaceLister
271273
remotePersistentVolumesClaimsClient corev1clients.PersistentVolumeClaimInterface
274+
forgingOpts *forge.ForgingOpts
272275
)
273276

274277
BeforeEach(func() {
@@ -281,6 +284,8 @@ var _ = Describe("Test Storage Provisioner", func() {
281284
Expect(err).ToNot(HaveOccurred())
282285
}
283286

287+
forgingOpts = testutil.FakeForgingOpts()
288+
284289
factory := informers.NewSharedInformerFactory(testEnvClient, 10*time.Hour)
285290
remote := factory.Core().V1().PersistentVolumeClaims()
286291

@@ -330,7 +335,7 @@ var _ = Describe("Test Storage Provisioner", func() {
330335
return &policy
331336
}(),
332337
},
333-
}, RemoteNamespace, storageClass, remotePersistentVolumeClaims, remotePersistentVolumesClaimsClient)
338+
}, RemoteNamespace, storageClass, remotePersistentVolumeClaims, remotePersistentVolumesClaimsClient, forgingOpts)
334339

335340
if err != nil {
336341
return err
@@ -364,6 +369,8 @@ var _ = Describe("Test Storage Provisioner", func() {
364369
realPvc, err := testEnvClient.CoreV1().PersistentVolumeClaims(RemoteNamespace).Get(ctx, pvcName, metav1.GetOptions{})
365370
Expect(err).ToNot(HaveOccurred())
366371
Expect(realPvc.Spec.StorageClassName).To(PointTo(Equal(realStorageClassName)))
372+
Expect(realPvc.Labels).ToNot(HaveKey(testutil.FakeNotReflectedLabelKey))
373+
Expect(realPvc.Annotations).ToNot(HaveKey(testutil.FakeNotReflectedAnnotKey))
367374
})
368375

369376
})

pkg/utils/testutil/consts.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ const (
3535
VPNGatewayPort = 32406
3636
// AuthenticationPort is the port of the liqo-auth service used for testing.
3737
AuthenticationPort = 32407
38+
// FakeNotReflectedLabelKey is the key of the fake not reflected label used for testing.
39+
FakeNotReflectedLabelKey = "not-reflected-label"
40+
// FakeNotReflectedAnnotKey is the key of the fake not reflected annotation used for testing.
41+
FakeNotReflectedAnnotKey = "not-reflected-annot"
3842
)
3943

4044
var (

pkg/utils/testutil/liqo.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
netv1alpha1 "github.com/liqotech/liqo/apis/net/v1alpha1"
2828
sharingv1alpha1 "github.com/liqotech/liqo/apis/sharing/v1alpha1"
2929
liqoconsts "github.com/liqotech/liqo/pkg/consts"
30+
"github.com/liqotech/liqo/pkg/virtualKubelet/forge"
3031
)
3132

3233
// FakeLiqoAuthService returns a fake liqo-auth service.
@@ -248,3 +249,11 @@ func FakeNetworkConfig(local bool, clusterName, tenantNamespace,
248249
},
249250
}
250251
}
252+
253+
// FakeForgingOpts returns a fake ForgingOpts.
254+
func FakeForgingOpts() *forge.ForgingOpts {
255+
return &forge.ForgingOpts{
256+
LabelsNotReflected: []string{FakeNotReflectedLabelKey},
257+
AnnotationsNotReflected: []string{FakeNotReflectedAnnotKey},
258+
}
259+
}

pkg/virtualKubelet/forge/configmaps.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
const RootCAConfigMapName = "kube-root-ca.crt"
2424

2525
// RemoteConfigMap forges the apply patch for the reflected configmap, given the local one.
26-
func RemoteConfigMap(local *corev1.ConfigMap, targetNamespace string) *corev1apply.ConfigMapApplyConfiguration {
26+
func RemoteConfigMap(local *corev1.ConfigMap, targetNamespace string, forgingOpts *ForgingOpts) *corev1apply.ConfigMapApplyConfiguration {
2727
applyConfig := corev1apply.ConfigMap(RemoteConfigMapName(local.GetName()), targetNamespace).
28-
WithLabels(local.GetLabels()).WithLabels(ReflectionLabels()).
29-
WithAnnotations(local.GetAnnotations()).
28+
WithLabels(FilterNotReflected(local.GetLabels(), forgingOpts.LabelsNotReflected)).WithLabels(ReflectionLabels()).
29+
WithAnnotations(FilterNotReflected(local.GetAnnotations(), forgingOpts.AnnotationsNotReflected)).
3030
WithBinaryData(local.BinaryData).
3131
WithData(local.Data)
3232

pkg/virtualKubelet/forge/configmaps_test.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,34 @@ import (
2323
corev1apply "k8s.io/client-go/applyconfigurations/core/v1"
2424
"k8s.io/utils/pointer"
2525

26+
"github.com/liqotech/liqo/pkg/utils/testutil"
2627
"github.com/liqotech/liqo/pkg/virtualKubelet/forge"
2728
)
2829

2930
var _ = Describe("ConfigMaps Forging", func() {
3031
Describe("the RemoteConfigMap function", func() {
3132
var (
32-
input *corev1.ConfigMap
33-
output *corev1apply.ConfigMapApplyConfiguration
33+
input *corev1.ConfigMap
34+
output *corev1apply.ConfigMapApplyConfiguration
35+
forgingOpts *forge.ForgingOpts
3436
)
3537

3638
BeforeEach(func() {
3739
input = &corev1.ConfigMap{
3840
ObjectMeta: metav1.ObjectMeta{
3941
Name: "name", Namespace: "original",
40-
Labels: map[string]string{"foo": "bar"},
41-
Annotations: map[string]string{"bar": "baz"},
42+
Labels: map[string]string{"foo": "bar", testutil.FakeNotReflectedLabelKey: "true"},
43+
Annotations: map[string]string{"bar": "baz", testutil.FakeNotReflectedAnnotKey: "true"},
4244
},
4345
Data: map[string]string{"data-key": "data value"},
4446
BinaryData: map[string][]byte{"binary-data-key": []byte("ABC")},
4547
Immutable: pointer.Bool(true),
4648
}
49+
50+
forgingOpts = testutil.FakeForgingOpts()
4751
})
4852

49-
JustBeforeEach(func() { output = forge.RemoteConfigMap(input, "reflected") })
53+
JustBeforeEach(func() { output = forge.RemoteConfigMap(input, "reflected", forgingOpts) })
5054

5155
It("should correctly set the name and namespace", func() {
5256
Expect(output.Name).To(PointTo(Equal("name")))
@@ -57,10 +61,12 @@ var _ = Describe("ConfigMaps Forging", func() {
5761
Expect(output.Labels).To(HaveKeyWithValue("foo", "bar"))
5862
Expect(output.Labels).To(HaveKeyWithValue(forge.LiqoOriginClusterIDKey, LocalClusterID))
5963
Expect(output.Labels).To(HaveKeyWithValue(forge.LiqoDestinationClusterIDKey, RemoteClusterID))
64+
Expect(output.Labels).ToNot(HaveKey(testutil.FakeNotReflectedLabelKey))
6065
})
6166

6267
It("should correctly set the annotations", func() {
6368
Expect(output.Annotations).To(HaveKeyWithValue("bar", "baz"))
69+
Expect(output.Annotations).ToNot(HaveKey(testutil.FakeNotReflectedAnnotKey))
6470
})
6571

6672
It("should correctly set the data", func() {

pkg/virtualKubelet/forge/endpointslices.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ func EndpointToBeReflected(endpoint *discoveryv1.Endpoint, localNodeClient corev
7474

7575
// RemoteShadowEndpointSlice forges the remote shadowendpointslice, given the local endpointslice.
7676
func RemoteShadowEndpointSlice(local *discoveryv1.EndpointSlice, remote *vkv1alpha1.ShadowEndpointSlice,
77-
localNodeClient corev1listers.NodeLister, targetNamespace string,
78-
translator EndpointTranslator) *vkv1alpha1.ShadowEndpointSlice {
77+
localNodeClient corev1listers.NodeLister, targetNamespace string, translator EndpointTranslator,
78+
forgingOpts *ForgingOpts) *vkv1alpha1.ShadowEndpointSlice {
7979
if remote == nil {
8080
// The remote is nil if not already created.
8181
remote = &vkv1alpha1.ShadowEndpointSlice{ObjectMeta: metav1.ObjectMeta{Name: local.GetName(), Namespace: targetNamespace}}
8282
}
8383

8484
return &vkv1alpha1.ShadowEndpointSlice{
85-
ObjectMeta: RemoteEndpointSliceObjectMeta(&local.ObjectMeta, &remote.ObjectMeta),
85+
ObjectMeta: RemoteEndpointSliceObjectMeta(&local.ObjectMeta, &remote.ObjectMeta, forgingOpts),
8686
Spec: vkv1alpha1.ShadowEndpointSliceSpec{
8787
Template: vkv1alpha1.EndpointSliceTemplate{
8888
AddressType: local.AddressType,
@@ -94,9 +94,11 @@ func RemoteShadowEndpointSlice(local *discoveryv1.EndpointSlice, remote *vkv1alp
9494
}
9595

9696
// RemoteEndpointSliceObjectMeta forges the objectMeta of the reflected endpointslice, given the local one.
97-
func RemoteEndpointSliceObjectMeta(local, remote *metav1.ObjectMeta) metav1.ObjectMeta {
97+
func RemoteEndpointSliceObjectMeta(local, remote *metav1.ObjectMeta, forgingOpts *ForgingOpts) metav1.ObjectMeta {
9898
objectMeta := RemoteObjectMeta(local, remote)
9999
objectMeta.SetLabels(labels.Merge(objectMeta.Labels, EndpointSliceLabels()))
100+
objectMeta.SetLabels(FilterNotReflected(objectMeta.Labels, forgingOpts.LabelsNotReflected))
101+
objectMeta.SetAnnotations(FilterNotReflected(objectMeta.Annotations, forgingOpts.AnnotationsNotReflected))
100102

101103
return objectMeta
102104
}

pkg/virtualKubelet/forge/endpointslices_test.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
vkv1alpha1 "github.com/liqotech/liqo/apis/virtualkubelet/v1alpha1"
2929
"github.com/liqotech/liqo/pkg/consts"
30+
"github.com/liqotech/liqo/pkg/utils/testutil"
3031
"github.com/liqotech/liqo/pkg/virtualKubelet/forge"
3132
)
3233

@@ -63,24 +64,27 @@ var _ = Describe("EndpointSlices Forging", func() {
6364

6465
Describe("the RemoteEndpointSlice function", func() {
6566
var (
66-
input *discoveryv1.EndpointSlice
67-
output *vkv1alpha1.ShadowEndpointSlice
67+
input *discoveryv1.EndpointSlice
68+
output *vkv1alpha1.ShadowEndpointSlice
69+
forgingOpts *forge.ForgingOpts
6870
)
6971

7072
BeforeEach(func() {
7173
input = &discoveryv1.EndpointSlice{
7274
ObjectMeta: metav1.ObjectMeta{
7375
Name: "name", Namespace: "original",
74-
Labels: map[string]string{"foo": "bar"},
75-
Annotations: map[string]string{"bar": "baz"},
76+
Labels: map[string]string{"foo": "bar", testutil.FakeNotReflectedLabelKey: "true"},
77+
Annotations: map[string]string{"bar": "baz", testutil.FakeNotReflectedAnnotKey: "true"},
7678
},
7779
AddressType: discoveryv1.AddressTypeFQDN,
7880
Endpoints: []discoveryv1.Endpoint{{Hostname: pointer.String("Test")}},
7981
Ports: []discoveryv1.EndpointPort{{Name: pointer.String("HTTPS")}},
8082
}
8183

84+
forgingOpts = testutil.FakeForgingOpts()
85+
8286
JustBeforeEach(func() {
83-
output = forge.RemoteShadowEndpointSlice(input, output, &FakeNodeLister{}, "reflected", Translator)
87+
output = forge.RemoteShadowEndpointSlice(input, output, &FakeNodeLister{}, "reflected", Translator, forgingOpts)
8488
})
8589

8690
It("should correctly set the name and namespace", func() {
@@ -93,9 +97,11 @@ var _ = Describe("EndpointSlices Forging", func() {
9397
Expect(output.Labels).To(HaveKeyWithValue(forge.LiqoOriginClusterIDKey, LocalClusterID))
9498
Expect(output.Labels).To(HaveKeyWithValue(forge.LiqoDestinationClusterIDKey, RemoteClusterID))
9599
Expect(output.Labels).To(HaveKeyWithValue(discoveryv1.LabelManagedBy, forge.EndpointSliceManagedBy))
100+
Expect(output.Labels).ToNot(HaveKey(testutil.FakeNotReflectedLabelKey))
96101
})
97102
It("should correctly set the annotations", func() {
98103
Expect(output.Annotations).To(HaveKeyWithValue("bar", "baz"))
104+
Expect(output.Annotations).ToNot(HaveKey(testutil.FakeNotReflectedAnnotKey))
99105
})
100106
It("should correctly set the address type", func() {
101107
Expect(output.Spec.Template.AddressType).To(PointTo(Equal(discoveryv1.AddressTypeFQDN)))

0 commit comments

Comments
 (0)