Skip to content

Commit

Permalink
[NET-5217] Apply K8s node locality to services and sidecars (#2748)
Browse files Browse the repository at this point in the history
Apply K8s node locality to services and sidecars

Locality-aware routing is based on proxy locality rather than the
proxied service. Ensure we propagate locality to both when registering
services.
  • Loading branch information
zalimeni authored Aug 10, 2023
1 parent a287fce commit a86533b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/2748.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
control-plane: Set locality on sidecar proxies in addition to services when registering with connect-inject.
```
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ func (r *Controller) createServiceRegistrations(pod corev1.Pod, serviceEndpoints
Namespace: consulNS,
Proxy: proxyConfig,
Tags: tags,
// Sidecar locality (not proxied service locality) is used for locality-aware routing.
Locality: locality,
}

// A user can enable/disable tproxy for an entire namespace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,10 @@ func TestReconcileCreateEndpoint(t *testing.T) {
"envoy_telemetry_collector_bind_socket_dir": "/consul/connect-inject",
},
},
ServiceLocality: &api.Locality{
Region: "us-west-1",
Zone: "us-west-1a",
},
ServiceMeta: map[string]string{
"name": "abc",
"version": "2",
Expand Down Expand Up @@ -2225,6 +2229,7 @@ func TestReconcileCreateEndpoint(t *testing.T) {
require.Equal(t, tt.expectedProxySvcInstances[i].ServicePort, instance.ServicePort)
require.Equal(t, tt.expectedProxySvcInstances[i].ServiceMeta, instance.ServiceMeta)
require.Equal(t, tt.expectedProxySvcInstances[i].ServiceTags, instance.ServiceTags)
require.Equal(t, tt.expectedProxySvcInstances[i].ServiceLocality, instance.ServiceLocality)
if tt.nodeMeta != nil {
require.Equal(t, tt.expectedProxySvcInstances[i].NodeMeta, instance.NodeMeta)
}
Expand Down

0 comments on commit a86533b

Please sign in to comment.