Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tests
  • Loading branch information
mluk-sap committed Nov 19, 2025
commit a8d6b3309aa336cea81f8f4add970896da0a513c
66 changes: 66 additions & 0 deletions internal/clusterconfig/clusterconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,72 @@ var _ = Describe("EvaluateClusterSize", func() {
Expect(err).To(Not(HaveOccurred()))
Expect(size).To(Equal(clusterconfig.Production))
})

It("should detect dual stack Ingress if an ip-address-type annotation is set to dual stack", func() {
//given
ingressSvc := corev1.Service{
ObjectMeta: v1.ObjectMeta{
Name: "istio-ingressgateway",
Namespace: "istio-system",
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-ip-address-type": "dualstack",
},
},
Spec: corev1.ServiceSpec{},
}

client := createFakeClient(&ingressSvc)

//when
ds, err := clusterconfig.IsDualStack(context.Background(), client)

//then
Expect(err).To(Not(HaveOccurred()))
Expect(ds).To(Equal(true))
})

It("should detect single stack Ingress if an ip-address-type annotation is not set dual stack", func() {
//given
ingressSvc := corev1.Service{
ObjectMeta: v1.ObjectMeta{
Name: "istio-ingressgateway",
Namespace: "istio-system",
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-ip-address-type": "ipv4",
},
},
Spec: corev1.ServiceSpec{},
}

client := createFakeClient(&ingressSvc)

//when
ds, err := clusterconfig.IsDualStack(context.Background(), client)

//then
Expect(err).To(Not(HaveOccurred()))
Expect(ds).To(Equal(false))
})

It("should detect single stack Ingress if an ip-address-type annotation is not set", func() {
//given
ingressSvc := corev1.Service{
ObjectMeta: v1.ObjectMeta{
Name: "istio-ingressgateway",
Namespace: "istio-system",
},
Spec: corev1.ServiceSpec{},
}

client := createFakeClient(&ingressSvc)

//when
ds, err := clusterconfig.IsDualStack(context.Background(), client)

//then
Expect(err).To(Not(HaveOccurred()))
Expect(ds).To(Equal(false))
})
})

func createFakeClient(objects ...client.Object) client.Client {
Expand Down
83 changes: 83 additions & 0 deletions internal/reconciliations/istioresources/reconciliation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,89 @@ var _ = Describe("Reconciliation", func() {
Expect(client.Get(context.Background(), ctrlclient.ObjectKey{Name: "proxy-protocol", Namespace: "istio-system"}, &e)).Should(Not(Succeed()))
})

It("should be created when hyperscaler is AWS, and the dual stack is enabled", func() {
//given
n := corev1.Node{Spec: corev1.NodeSpec{ProviderID: "aws://asdasdads"}}
//given
ingressSvc := corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "istio-ingressgateway",
Namespace: "istio-system",
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-ip-address-type": "dualstack",
},
},
Spec: corev1.ServiceSpec{},
}

client := createFakeClient(&n, &ingressSvc)
reconciler := NewReconciler(client)

//when
err := reconciler.Reconcile(context.Background(), istioCR)

//then
Expect(err).To(Not(HaveOccurred()))
Expect(client.Get(context.Background(), ctrlclient.ObjectKey{Name: "proxy-protocol", Namespace: "istio-system"}, &networkingv1alpha3.EnvoyFilter{})).Should(Succeed())
})

It("should not be created when hyperscaler is AWS, but the dual stack is disabled", func() {
//given
n := corev1.Node{Spec: corev1.NodeSpec{ProviderID: "aws://asdasdads"}}
//given
ingressSvc := corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "istio-ingressgateway",
Namespace: "istio-system",
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-ip-address-type": "ipv4",
},
},
Spec: corev1.ServiceSpec{},
}

client := createFakeClient(&n, &ingressSvc)
reconciler := NewReconciler(client)

//when
err := reconciler.Reconcile(context.Background(), istioCR)

//then
Expect(err).To(Not(HaveOccurred()))

var e networkingv1alpha3.EnvoyFilter
Expect(client.Get(context.Background(), ctrlclient.ObjectKey{Name: "proxy-protocol", Namespace: "istio-system"}, &e)).Should(Not(Succeed()))
})

It("should not be created when hyperscaler is AWS, even if proxy-protocol is set but the dual stack is not enabled", func() {
//given
n := corev1.Node{Spec: corev1.NodeSpec{ProviderID: "aws://asdasdads"}}
//given
ingressSvc := corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "istio-ingressgateway",
Namespace: "istio-system",
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-ip-address-type": "ipv4",
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol": "*",
},
},
Spec: corev1.ServiceSpec{},
}

client := createFakeClient(&n, &ingressSvc)
reconciler := NewReconciler(client)

//when
err := reconciler.Reconcile(context.Background(), istioCR)

//then
Expect(err).To(Not(HaveOccurred()))

var e networkingv1alpha3.EnvoyFilter
Expect(client.Get(context.Background(), ctrlclient.ObjectKey{Name: "proxy-protocol", Namespace: "istio-system"}, &e)).Should(Not(Succeed()))
})

It("should be created when hyperscaler is OpenStack", func() {
//given
n := corev1.Node{Spec: corev1.NodeSpec{ProviderID: "openstack://example"}}
Expand Down
Loading