From 8a0069128b1ec012927ea1dfc75e2b5fc0475e89 Mon Sep 17 00:00:00 2001 From: Marcin Skalski Date: Fri, 17 Jan 2025 17:53:36 +0100 Subject: [PATCH] fix(kuma-cp): fix issue with pod labels overriding existing dataplane labels (#12589) Fixes: #12142 ## Motivation We should not override already present dataplane labels with pod labels --------- Signed-off-by: Marcin Skalski --- .../k8s/controllers/pod_controller_test.go | 2 + .../runtime/k8s/controllers/pod_converter.go | 20 ++++++-- .../k8s/controllers/pod_converter_test.go | 49 +++++++++++++++++-- .../testdata/egress/01.dataplane.yaml | 4 ++ .../testdata/egress/02.dataplane.yaml | 4 ++ .../testdata/egress/03.dataplane.yaml | 4 ++ .../testdata/egress/04.dataplane.yaml | 4 ++ .../testdata/egress/05.dataplane.yaml | 4 ++ .../egress-exists-labels.dataplane.yaml | 12 +++++ ...ress-exists-labels.existing-dataplane.yaml | 12 +++++ .../egress/egress-exists-labels.node.yaml | 8 +++ .../egress/egress-exists-labels.pod.yaml | 14 ++++++ ...egress-exists-labels.services-for-pod.yaml | 12 +++++ .../testdata/ingress/01.dataplane.yaml | 4 ++ .../testdata/ingress/02.dataplane.yaml | 4 ++ .../testdata/ingress/03.dataplane.yaml | 4 ++ .../testdata/ingress/04.dataplane.yaml | 4 ++ .../testdata/ingress/05.dataplane.yaml | 4 ++ .../testdata/ingress/06.dataplane.yaml | 4 ++ .../ingress-exists-labels.dataplane.yaml | 19 +++++++ ...ress-exists-labels.existing-dataplane.yaml | 16 ++++++ .../ingress/ingress-exists-labels.pod.yaml | 14 ++++++ ...ngress-exists-labels.services-for-pod.yaml | 15 ++++++ .../ingress/ingress-exists.dataplane.yaml | 4 ++ .../testdata/update-dataplane.dataplane.yaml | 30 ++++++++++++ .../update-dataplane.existing-dataplane.yaml | 24 +++++++++ .../update-dataplane.other-services.yaml | 23 +++++++++ .../testdata/update-dataplane.pod.yaml | 20 ++++++++ .../update-dataplane.services-for-pod.yaml | 9 ++++ test/e2e/federation/federation_suite_test.go | 5 +- 30 files changed, 342 insertions(+), 10 deletions(-) create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.dataplane.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.existing-dataplane.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.node.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.pod.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.services-for-pod.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.dataplane.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.existing-dataplane.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.pod.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.services-for-pod.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.dataplane.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.existing-dataplane.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.other-services.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.pod.yaml create mode 100644 pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.services-for-pod.yaml diff --git a/pkg/plugins/runtime/k8s/controllers/pod_controller_test.go b/pkg/plugins/runtime/k8s/controllers/pod_controller_test.go index 56b69068b0c9..38a3f9ae5b37 100644 --- a/pkg/plugins/runtime/k8s/controllers/pod_controller_test.go +++ b/pkg/plugins/runtime/k8s/controllers/pod_controller_test.go @@ -811,6 +811,7 @@ var _ = Describe("PodReconciler", func() { mesh_proto.MeshTag: "poc", mesh_proto.ResourceOriginLabel: "zone", mesh_proto.EnvTag: mesh_proto.KubernetesEnvironment, + mesh_proto.ProxyTypeLabel: "sidecar", }, OwnerReferences: []kube_meta.OwnerReference{ { @@ -893,6 +894,7 @@ var _ = Describe("PodReconciler", func() { labels: app: sample k8s.kuma.io/namespace: demo + kuma.io/display-name: pod-with-custom-admin-port kuma.io/env: kubernetes kuma.io/mesh: poc kuma.io/origin: zone diff --git a/pkg/plugins/runtime/k8s/controllers/pod_converter.go b/pkg/plugins/runtime/k8s/controllers/pod_converter.go index 2a37ea726080..0d99e730f0dd 100644 --- a/pkg/plugins/runtime/k8s/controllers/pod_converter.go +++ b/pkg/plugins/runtime/k8s/controllers/pod_converter.go @@ -3,6 +3,7 @@ package controllers import ( "context" "fmt" + "maps" "reflect" "regexp" @@ -63,7 +64,7 @@ func (p *PodConverter) PodToDataplane( labels, err := model.ComputeLabels( core_mesh.DataplaneResourceTypeDescriptor, currentSpec, - pod.Labels, + mergeLabels(dataplane.GetLabels(), pod.Labels), model.NewNamespace(pod.Namespace, pod.Namespace == p.SystemNamespace), dataplane.Mesh, p.Mode, @@ -103,7 +104,7 @@ func (p *PodConverter) PodToIngress(ctx context.Context, zoneIngress *mesh_k8s.Z labels, err := model.ComputeLabels( core_mesh.ZoneIngressResourceTypeDescriptor, currentSpec, - pod.Labels, + mergeLabels(zoneIngress.GetLabels(), pod.Labels), model.NewNamespace(pod.Namespace, pod.Namespace == p.SystemNamespace), model.NoMesh, p.Mode, @@ -119,6 +120,7 @@ func (p *PodConverter) PodToIngress(ctx context.Context, zoneIngress *mesh_k8s.Z return nil } zoneIngress.SetSpec(zoneIngressRes.Spec) + zoneIngress.SetLabels(labels) return nil } @@ -142,7 +144,7 @@ func (p *PodConverter) PodToEgress(ctx context.Context, zoneEgress *mesh_k8s.Zon labels, err := model.ComputeLabels( core_mesh.ZoneEgressResourceTypeDescriptor, currentSpec, - pod.Labels, + mergeLabels(zoneEgress.GetLabels(), pod.Labels), model.NewNamespace(pod.Namespace, pod.Namespace == p.SystemNamespace), model.NoMesh, p.Mode, @@ -158,6 +160,7 @@ func (p *PodConverter) PodToEgress(ctx context.Context, zoneEgress *mesh_k8s.Zon } zoneEgress.SetSpec(zoneEgressRes.Spec) + zoneEgress.SetLabels(labels) return nil } @@ -411,6 +414,17 @@ func MetricsAggregateFor(pod *kube_core.Pod) ([]*mesh_proto.PrometheusAggregateM return aggregateConfig, nil } +func mergeLabels(existingLabels map[string]string, podLabels map[string]string) map[string]string { + mergedLabels := map[string]string{} + if existingLabels != nil { + mergedLabels = maps.Clone(existingLabels) + } + for k, v := range podLabels { + mergedLabels[k] = v + } + return mergedLabels +} + type ReachableBackendRefs struct { Refs []*ReachableBackendRef `json:"refs,omitempty"` } diff --git a/pkg/plugins/runtime/k8s/controllers/pod_converter_test.go b/pkg/plugins/runtime/k8s/controllers/pod_converter_test.go index 17cf28281590..4af991eb294c 100644 --- a/pkg/plugins/runtime/k8s/controllers/pod_converter_test.go +++ b/pkg/plugins/runtime/k8s/controllers/pod_converter_test.go @@ -120,6 +120,15 @@ var _ = Describe("PodToDataplane(..)", func() { Expect(err).ToNot(HaveOccurred()) } + // existing dataplane + existingDataplane := &mesh_k8s.Dataplane{} + if given.existingDataplane != "" { + bytes, err := os.ReadFile(filepath.Join("testdata", given.existingDataplane)) + Expect(err).ToNot(HaveOccurred()) + err = yaml.Unmarshal(bytes, existingDataplane) + Expect(err).ToNot(HaveOccurred()) + } + converter := PodConverter{ ServiceGetter: serviceGetter, InboundConverter: InboundConverter{ @@ -135,13 +144,12 @@ var _ = Describe("PodToDataplane(..)", func() { } // when - dataplane := &mesh_k8s.Dataplane{} - err = converter.PodToDataplane(context.Background(), dataplane, pod, &namespace, services, otherDataplanes) + err = converter.PodToDataplane(context.Background(), existingDataplane, pod, &namespace, services, otherDataplanes) // then Expect(err).ToNot(HaveOccurred()) - actual, err := yaml.Marshal(dataplane) + actual, err := yaml.Marshal(existingDataplane) Expect(err).ToNot(HaveOccurred()) Expect(actual).To(MatchGoldenYAML("testdata", given.dataplane)) }, @@ -312,6 +320,13 @@ var _ = Describe("PodToDataplane(..)", func() { servicesForPod: "30.services-for-pod.yaml", dataplane: "30.dataplane.yaml", }), + Entry("Update existing dataplane with pod labels", testCase{ + pod: "update-dataplane.pod.yaml", + servicesForPod: "update-dataplane.services-for-pod.yaml", + existingDataplane: "update-dataplane.existing-dataplane.yaml", + otherServices: "update-dataplane.other-services.yaml", + dataplane: "update-dataplane.dataplane.yaml", + }), ) DescribeTable("should convert Ingress Pod into an Ingress Dataplane YAML version", @@ -404,6 +419,18 @@ var _ = Describe("PodToDataplane(..)", func() { existingDataplane: "ingress-exists.existing-dataplane.yaml", dataplane: "ingress-exists.dataplane.yaml", }), + Entry("Existing ZoneIngress with load balancer and ip should not be updated when no change", testCase{ + pod: "ingress-exists.pod.yaml", + servicesForPod: "ingress-exists.services-for-pod.yaml", + existingDataplane: "ingress-exists.existing-dataplane.yaml", + dataplane: "ingress-exists.dataplane.yaml", + }), + Entry("Existing ZoneIngress should be updated when pod labels changes", testCase{ + pod: "ingress-exists-labels.pod.yaml", + servicesForPod: "ingress-exists-labels.services-for-pod.yaml", + existingDataplane: "ingress-exists-labels.existing-dataplane.yaml", + dataplane: "ingress-exists-labels.dataplane.yaml", + }), ) DescribeTable("should convert Egress Pod into an Egress Dataplane YAML version", @@ -442,8 +469,15 @@ var _ = Describe("PodToDataplane(..)", func() { }, } - // when egress := &mesh_k8s.ZoneEgress{} + if given.existingDataplane != "" { + bytes, err = os.ReadFile(filepath.Join("testdata", "egress", given.existingDataplane)) + Expect(err).ToNot(HaveOccurred()) + err = yaml.Unmarshal(bytes, egress) + Expect(err).ToNot(HaveOccurred()) + } + + // when err = converter.PodToEgress(ctx, egress, pod, services) // then @@ -480,6 +514,13 @@ var _ = Describe("PodToDataplane(..)", func() { dataplane: "05.dataplane.yaml", node: "05.node.yaml", }), + Entry("Existing ZoneEgress should be updated when pod labels changes", testCase{ // KIND / Minikube use case + pod: "egress-exists-labels.pod.yaml", + servicesForPod: "egress-exists-labels.services-for-pod.yaml", + dataplane: "egress-exists-labels.dataplane.yaml", + node: "egress-exists-labels.node.yaml", + existingDataplane: "egress-exists-labels.existing-dataplane.yaml", + }), ) }) diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/01.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/01.dataplane.yaml index e8151f62f939..4e0da3ebc8c3 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/egress/01.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/01.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-egress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneegress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/02.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/02.dataplane.yaml index e3e12beb5484..8cd37b140552 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/egress/02.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/02.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-egress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneegress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/03.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/03.dataplane.yaml index e3e12beb5484..8cd37b140552 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/egress/03.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/03.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-egress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneegress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/04.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/04.dataplane.yaml index e3e12beb5484..8cd37b140552 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/egress/04.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/04.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-egress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneegress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/05.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/05.dataplane.yaml index e3e12beb5484..8cd37b140552 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/egress/05.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/05.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-egress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneegress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.dataplane.yaml new file mode 100644 index 000000000000..995d52465f33 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.dataplane.yaml @@ -0,0 +1,12 @@ +metadata: + creationTimestamp: null + labels: + app: kuma-egress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneegress + test: new +spec: + networking: + address: 192.168.0.1 + port: 10002 + zone: zone-1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.existing-dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.existing-dataplane.yaml new file mode 100644 index 000000000000..062d9e3ad2b1 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.existing-dataplane.yaml @@ -0,0 +1,12 @@ +metadata: + creationTimestamp: null + labels: + app: kuma-egress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneegress + test: old +spec: + networking: + address: 192.168.0.1 + port: 10002 + zone: zone-1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.node.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.node.yaml new file mode 100644 index 000000000000..bdb9e22d8f17 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.node.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Node +metadata: + name: sample-node +status: + addresses: + - address: 10.128.15.193 + type: InternalIP diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.pod.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.pod.yaml new file mode 100644 index 000000000000..ddd901b41ebd --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.pod.yaml @@ -0,0 +1,14 @@ +metadata: + namespace: kuma-system + name: kuma-egress + labels: + app: kuma-egress + test: new + annotations: + kuma.io/egress: enabled +spec: + containers: + - ports: + - containerPort: 10002 +status: + podIP: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.services-for-pod.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.services-for-pod.yaml new file mode 100644 index 000000000000..9256544986c7 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/egress/egress-exists-labels.services-for-pod.yaml @@ -0,0 +1,12 @@ +--- +metadata: + namespace: kuma-system + name: kuma-egress +spec: + type: NodePort + ports: + - port: 10002 + targetPort: 10002 + nodePort: 12345 + selector: + app: kuma-egress diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/01.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/01.dataplane.yaml index d858a920d036..9832ae974f72 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/01.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/01.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-ingress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneingress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/02.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/02.dataplane.yaml index 86fa5fc44aa8..2fc4b7fa1665 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/02.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/02.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-ingress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneingress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/03.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/03.dataplane.yaml index 1b076fd466c8..04d158a537f7 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/03.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/03.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-ingress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneingress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/04.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/04.dataplane.yaml index 87e89877c91e..963c3c504ce3 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/04.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/04.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-ingress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneingress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/05.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/05.dataplane.yaml index 75c533fe8446..9645ab6875ee 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/05.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/05.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-ingress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneingress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/06.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/06.dataplane.yaml index 429d8c83ce6a..e1f9cab4d957 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/06.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/06.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-ingress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneingress spec: networking: address: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.dataplane.yaml new file mode 100644 index 000000000000..412f76db6e7d --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.dataplane.yaml @@ -0,0 +1,19 @@ +metadata: + creationTimestamp: null + labels: + app: kuma-ingress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneingress + test: new +spec: + availableServices: + - instances: 3 + mesh: mesh-1 + tags: + kuma.io/protocol: http + kuma.io/service: service-1-zone-2 + networking: + address: 192.168.0.1 + advertisedAddress: 192.168.100.1 + advertisedPort: 10001 + port: 10001 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.existing-dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.existing-dataplane.yaml new file mode 100644 index 000000000000..699a83c8a813 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.existing-dataplane.yaml @@ -0,0 +1,16 @@ +metadata: + creationTimestamp: null + labels: + test: old +spec: + availableServices: + - instances: 3 + mesh: mesh-1 + tags: + kuma.io/protocol: http + kuma.io/service: service-1-zone-2 + networking: + address: 192.168.0.1 + advertisedAddress: 192.168.100.1 + advertisedPort: 10001 + port: 10001 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.pod.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.pod.yaml new file mode 100644 index 000000000000..4a28d6b053c7 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.pod.yaml @@ -0,0 +1,14 @@ +metadata: + namespace: kuma-system + name: kuma-ingress + labels: + app: kuma-ingress + test: new + annotations: + kuma.io/ingress: enabled +spec: + containers: + - ports: + - containerPort: 10001 +status: + podIP: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.services-for-pod.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.services-for-pod.yaml new file mode 100644 index 000000000000..5094495da5c3 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists-labels.services-for-pod.yaml @@ -0,0 +1,15 @@ +--- +metadata: + namespace: kuma-system + name: kuma-ingress +spec: + type: LoadBalancer + ports: + - port: 10001 + targetPort: 10001 + selector: + app: kuma-ingress +status: + loadBalancer: + ingress: + - ip: 192.168.100.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists.dataplane.yaml index 74ebdeff6120..4a9f209652f4 100644 --- a/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists.dataplane.yaml +++ b/pkg/plugins/runtime/k8s/controllers/testdata/ingress/ingress-exists.dataplane.yaml @@ -1,5 +1,9 @@ metadata: creationTimestamp: null + labels: + app: kuma-ingress + k8s.kuma.io/namespace: kuma-system + kuma.io/proxy-type: zoneingress spec: availableServices: - instances: 3 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.dataplane.yaml new file mode 100644 index 000000000000..56a8f38c6aed --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.dataplane.yaml @@ -0,0 +1,30 @@ +apiVersion: kuma.io/v1alpha1 +kind: Dataplane +mesh: default +metadata: + creationTimestamp: null + labels: + app: example + k8s.kuma.io/namespace: demo + kuma.io/mesh: default + kuma.io/proxy-type: sidecar + kuma.io/zone: default + version: "0.1" + name: test-app-8646b8bbc8-5qbl2 + namespace: playground +spec: + networking: + address: 192.168.0.1 + inbound: + - health: + ready: true + port: 8080 + tags: + app: example + k8s.kuma.io/namespace: demo + k8s.kuma.io/service-name: example + k8s.kuma.io/service-port: "80" + kuma.io/protocol: tcp + kuma.io/service: example_demo_svc_80 + kuma.io/zone: zone-1 + version: "0.1" diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.existing-dataplane.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.existing-dataplane.yaml new file mode 100644 index 000000000000..19d8205d3c33 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.existing-dataplane.yaml @@ -0,0 +1,24 @@ +apiVersion: kuma.io/v1alpha1 +kind: Dataplane +mesh: default +metadata: + name: test-app-8646b8bbc8-5qbl2 + namespace: playground + labels: + kuma.io/zone: default +spec: + networking: + address: 10.244.0.25 + inbound: + - port: 80 + tags: + app: test-app + pod-template-hash: 8646b8bbc8 + kuma.io/service: test-app_playground_svc_80 + - port: 443 + tags: + app: test-app + pod-template-hash: 8646b8bbc8 + kuma.io/service: test-app_playground_svc_443 + transparentProxying: + redirectPort: 15001 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.other-services.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.other-services.yaml new file mode 100644 index 000000000000..1c9db361cbc2 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.other-services.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: test-app + namespace: playground +spec: + clusterIP: 10.108.144.24 + ports: + - name: http + port: 80 + protocol: TCP + targetPort: 80 + - name: https + port: 443 + protocol: TCP + targetPort: 80 + selector: + app: test-app + sessionAffinity: None + type: ClusterIP +status: + loadBalancer: {} diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.pod.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.pod.yaml new file mode 100644 index 000000000000..c36d7cbb8eb7 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.pod.yaml @@ -0,0 +1,20 @@ +metadata: + namespace: demo + name: example + labels: + app: example + version: "0.1" +spec: + containers: + - ports: [] + # when a 'targetPort' in a ServicePort is a number, + # it should not be mandatory to list container ports explicitly + # + # containerPort: 8080 + # containerPort: 8443 + - ports: + - containerPort: 7070 + - containerPort: 6060 + name: metrics +status: + podIP: 192.168.0.1 diff --git a/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.services-for-pod.yaml b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.services-for-pod.yaml new file mode 100644 index 000000000000..133ed99768d9 --- /dev/null +++ b/pkg/plugins/runtime/k8s/controllers/testdata/update-dataplane.services-for-pod.yaml @@ -0,0 +1,9 @@ +metadata: + namespace: demo + name: example +spec: + clusterIP: 192.168.0.1 + ports: + - # protocol defaults to TCP + port: 80 + targetPort: 8080 diff --git a/test/e2e/federation/federation_suite_test.go b/test/e2e/federation/federation_suite_test.go index 8c8c1d551f47..4f42babfd837 100644 --- a/test/e2e/federation/federation_suite_test.go +++ b/test/e2e/federation/federation_suite_test.go @@ -14,7 +14,6 @@ func TestE2E(t *testing.T) { } var ( - // TODO(bartsmykla): disabled while investingating flake (https://github.com/kumahq/kuma/issues/12142) - _ = XDescribe("Federation with Kube Global", Label("job-3"), federation.FederateKubeZoneCPToKubeGlobal, Ordered) - _ = XDescribe("Federation with Universal Global", Label("job-3"), federation.FederateKubeZoneCPToUniversalGlobal, Ordered) + _ = Describe("Federation with Kube Global", Label("job-3"), federation.FederateKubeZoneCPToKubeGlobal, Ordered) + _ = Describe("Federation with Universal Global", Label("job-3"), federation.FederateKubeZoneCPToUniversalGlobal, Ordered) )