Configure envoy cluster configs using envoy filter

Hello,

I am trying to configure envoy cluster config using envoy filter and it seems like my filter is incorrect.
I am hoping someone can help me, and if we can enhance documentation for this in the ‘Envoy Filter’ page.

Context: one of my services uses consistent hash for load-balancing.

---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: teletubby
spec:
  host: teletubby
  trafficPolicy:
    loadBalancer:
      consistentHash:
        httpHeaderName: r-p

For long running connections, when a pod dies, it will connect to a different pod, but when the original pod comes back online, the long running connections are connected to a different hashed pod.
To solve this, I was thinking to use close_connections_on_host_set_change which is a loadbalancer cluster config in envoy.
https://www.envoyproxy.io/docs/envoy/v1.17.0/api-v3/config/cluster/v3/cluster.proto.html?highlight=close_connections_on_host_set_change#config-cluster-v3-cluster-commonlbconfig

With this, i was expecting the istio gateway to close existing connections when hosts are added/removed from that service.

I tried to set this up by adding it as Envoy Filter.
But it seems like my understanding of configuring this filter is not correct and perhaps some missing gaps.
I assumed i am applying this to the gateway connections, and that we are patching cluster config as by default the close_connections_on_host_set_change setting is false.

My config:

---
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: ingress-connections-reset-on-host-changes
  namespace: istio-system
spec:
  workloadSelector:
    labels:
      app: istio-ingressgateway
  configPatches:
  - applyTo: CLUSTER
    match:
      context: GATEWAY
      cluster: {}
    patch:
      operation: REPLACE
      filterClass: UNSPECIFIED
      value:
        common_lb_config:
          close_connections_on_host_set_change: true

I am happy to add this or similar sample in docs for ppl wanting to update cluster configs. Would soneone be able to point me in right direction?
thanks,

Hi Rashmi,
Are you able to get it working with the EnvoyFilter?

Hi,
I can get the consistent hash to work but couldn’t reset connection on host list change for which i was using the envoy filter for! :frowning: