Need help in creating EnvoyFilter to support LB with consistent hash and use Hostname for consistent hashing

I am using/verifying Istio for our use case, where I need session affinity for pods.For this I am currently using the below destination rule:

apiVersion: networking.istio.io/v1alpha3

kind: DestinationRule

metadata:

    name: sticky-quote

spec:

    host: quote

    trafficPolicy:

      loadBalancer:

        consistentHash:

          httpHeaderName: X-DEVICE-ID

Now upon scaling down/up the session affinity doesn’t maintain maybe because the consistent hashing in pod depends on pod IP. Envoy already has solution to use the pod hostname for consistent hashing. To use this feature I am using an EnvoyFilter as below, But I am not sure whether using the right configuration.


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: ADD

      filterClass: UNSPECIFIED

      value:

        lb_policy: MAGLEV

        common_lb_config:

          consistent_hashing_lb_config:

            use_hostname_for_hashing: true

Can someone help me in framing the right filter config.