I have Kafka cluster with two nodes. node1 with ip 1.1.1.1, and node2 with ip 2.2.2.2 All traffic must go through Egres Controller. If a client from the application addresses a node with ip 1.1.1.1, then he should contact it without any balancing from Istio
Configuration:
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: kafka
spec:
hosts:
- kafka.host
addresses:
- 1.1.1.1/32
- 2.2.2.2/32
ports:
- number: 9092
name: tcp-kafka
protocol: TCP
location: MESH_EXTERNAL
resolution: STATIC
endpoints:
- address: 1.1.1.1
- address: 2.2.2.2
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: kafka
spec:
host: kafka.host
trafficPolicy:
loadBalancer:
simple: PASSTHROUGH # disabled loadBalancer
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: kafka
spec:
selector:
istio: istio-egressgateway
servers:
- port:
number: 9092
name: tcp-kafka
protocol: TCP
hosts:
- kafka.host
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: kafka
spec:
hosts:
- kafka.host
gateways:
- mesh
- kafka
tcp:
- match:
- gateways:
- mesh
destinationSubnets:
- 1.1.1.1/32
- 2.2.2.2/32
port: 9092
route:
- destination:
host: istio-egressgateway
port:
number: 9092
- match:
- gateways:
- kafka
port: 9092
route:
- destination:
host: kafka.host
port:
number: 9092
weight: 100
Traffic reaches to Egress Controller and does not go outside, while in the egress controller logs:
[Envoy (Epoch 0)] [2020-07-31 13:52:21.351][58][warning][upstream] [external/envoy/source/common/upstream/original_dst_cluster.cc:76] original_dst_load_balancer: No downstream connection or no original_dst.
[2020-07-31T13:52:11.385Z] "- - -" 0 UH "-" "-" 0 0 0 - "-" "-" "-" "-" "-" - - 10.128.19.132:9092 10.128.13.52:47984 - -
P.S. If you set loadBalancer: ROUND_ROBIN or another in the DestinationRule, then everything works and traffic goes to external nodes. But there is no guarantee that when accessing ip 1.1.1.1 from the application, the traffic will go to the external server with ip 1.1.1.1
Istio v1.1