How to route the traffic from a pod to its Node IP address from istio sidecar

70 views Asked by At

I am running proxysql pod as a daemonset. So from any of my application pod when I try to connect using localhost 6033, I need to redirect that call to Node IP address. I have the below envoyfilter configuration which works fine if I provide Node IP address in $HOST_IP placeholder. But I want the Node IP to be taken dynamically.

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: sql-filter
  namespace: stage-namespace
spec:
  configPatches:
  - applyTo: LISTENER
    match:
      context: SIDECAR_OUTBOUND
      listener:
        portNumber: 6033
    patch:
      operation: ADD
      value:
        name: tcp_proxy1
        address:
          socket_address:
            protocol: TCP
            address: 0.0.0.0
            port_value: 6033
        filter_chains:
        - filters:
          - name: "envoy.tcp_proxy"
            typed_config:
              '@type': type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
              idle_timeout: 210s
              stat_prefix: mysql
              cluster: mysql
              max_connect_attempts: 5
  - applyTo: CLUSTER
    match:
      context: SIDECAR_OUTBOUND
    patch:
      operation: ADD
      value:
        name: "mysql"
        connect_timeout: 1s
        type: STRICT_DNS
        lb_policy: LEAST_REQUEST
        dns_lookup_family: V4_ONLY
        load_assignment:
          cluster_name: mysql
          endpoints:
          - lb_endpoints:
            - endpoint:
                address:
                  socket_address:
                    address: "$HOST_IP"
                    port_value: 6033

I have tried with hard coding the IP address in above yaml in place of $HOST_IP which works fine without any issues.

0

There are 0 answers