From 284f1cd9e4c2b1bdaa110f783e990e95d1f94b42 Mon Sep 17 00:00:00 2001 From: Dhia Ayachi Date: Mon, 6 May 2024 13:38:44 -0400 Subject: [PATCH 1/3] activate tproxy mode even when a cluster IP is not assigned to pod. --- .../controllers/endpoints/endpoints_controller.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/control-plane/connect-inject/controllers/endpoints/endpoints_controller.go b/control-plane/connect-inject/controllers/endpoints/endpoints_controller.go index fe6c5aed0b..96ce133454 100644 --- a/control-plane/connect-inject/controllers/endpoints/endpoints_controller.go +++ b/control-plane/connect-inject/controllers/endpoints/endpoints_controller.go @@ -582,7 +582,7 @@ func (r *Controller) createServiceRegistrations(pod corev1.Pod, serviceEndpoints if tproxyEnabled { var k8sService corev1.Service - + proxyService.Proxy.Mode = api.ProxyModeTransparent err = r.Client.Get(r.Context, types.NamespacedName{Name: serviceEndpoints.Name, Namespace: serviceEndpoints.Namespace}, &k8sService) if err != nil { return nil, nil, err @@ -625,7 +625,6 @@ func (r *Controller) createServiceRegistrations(pod corev1.Pod, serviceEndpoints service.TaggedAddresses = taggedAddresses proxyService.TaggedAddresses = taggedAddresses - proxyService.Proxy.Mode = api.ProxyModeTransparent } else { r.Log.Info("skipping syncing service cluster IP to Consul", "name", k8sService.Name, "ns", k8sService.Namespace, "ip", k8sService.Spec.ClusterIP) } From ba0a8963a389b09d96e6dc65bb747ced30ee2856 Mon Sep 17 00:00:00 2001 From: Dhia Ayachi Date: Tue, 7 May 2024 11:18:07 -0400 Subject: [PATCH 2/3] add changelog --- .changelog/3974.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3974.txt diff --git a/.changelog/3974.txt b/.changelog/3974.txt new file mode 100644 index 0000000000..c5f3d7093b --- /dev/null +++ b/.changelog/3974.txt @@ -0,0 +1,3 @@ +```release-note:bug +Create Consul service with mode transparent-proxy even when a cluster IP is not assigned to the service.. +``` From f26637135fe4c87632aac9a900df06eef544aacd Mon Sep 17 00:00:00 2001 From: Dhia Ayachi Date: Tue, 7 May 2024 15:55:38 -0400 Subject: [PATCH 3/3] fix failing tests --- .../controllers/endpoints/endpoints_controller_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/control-plane/connect-inject/controllers/endpoints/endpoints_controller_test.go b/control-plane/connect-inject/controllers/endpoints/endpoints_controller_test.go index d22dfe0dac..4597b804f7 100644 --- a/control-plane/connect-inject/controllers/endpoints/endpoints_controller_test.go +++ b/control-plane/connect-inject/controllers/endpoints/endpoints_controller_test.go @@ -5547,7 +5547,7 @@ func TestCreateServiceRegistrations_withTransparentProxy(t *testing.T) { }, }, }, - expProxyMode: api.ProxyModeDefault, + expProxyMode: api.ProxyModeTransparent, expTaggedAddresses: nil, expErr: "", }, @@ -5567,7 +5567,7 @@ func TestCreateServiceRegistrations_withTransparentProxy(t *testing.T) { }, }, }, - expProxyMode: api.ProxyModeDefault, + expProxyMode: api.ProxyModeTransparent, expTaggedAddresses: nil, expErr: "", }, @@ -5588,7 +5588,7 @@ func TestCreateServiceRegistrations_withTransparentProxy(t *testing.T) { }, }, expTaggedAddresses: nil, - expProxyMode: api.ProxyModeDefault, + expProxyMode: api.ProxyModeTransparent, expErr: "", }, "service with an IPv6 clusterIP": {