Skip to content

Commit

Permalink
activate tproxy mode even when a cluster IP is not assigned to pod (#…
Browse files Browse the repository at this point in the history
…3974)

* activate tproxy mode even when a cluster IP is not assigned to pod.

* add changelog

* fix failing tests
  • Loading branch information
dhiaayachi authored May 8, 2024
1 parent 58f715a commit c11c201
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .changelog/3974.txt
Original file line number Diff line number Diff line change
@@ -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..
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5547,7 +5547,7 @@ func TestCreateServiceRegistrations_withTransparentProxy(t *testing.T) {
},
},
},
expProxyMode: api.ProxyModeDefault,
expProxyMode: api.ProxyModeTransparent,
expTaggedAddresses: nil,
expErr: "",
},
Expand All @@ -5567,7 +5567,7 @@ func TestCreateServiceRegistrations_withTransparentProxy(t *testing.T) {
},
},
},
expProxyMode: api.ProxyModeDefault,
expProxyMode: api.ProxyModeTransparent,
expTaggedAddresses: nil,
expErr: "",
},
Expand All @@ -5588,7 +5588,7 @@ func TestCreateServiceRegistrations_withTransparentProxy(t *testing.T) {
},
},
expTaggedAddresses: nil,
expProxyMode: api.ProxyModeDefault,
expProxyMode: api.ProxyModeTransparent,
expErr: "",
},
"service with an IPv6 clusterIP": {
Expand Down

0 comments on commit c11c201

Please sign in to comment.