Originally, I thought it would be easy to replace the functionality of different services (across namespace) with istio, but I actually ran into a problem.
Let me describe the problem:
The same namespace, in an already successful into sidecars pod, I want to visit the details in the form of curl http://details:8080/details/0 service. The details are not actually deployed on the namespace, but deployed in namespace istio-project and the service port is 9080. I use http://details.istio-project.svc.cluster.local:9080/details/0 is to be able to access the details. In order to let me use the curl http://details:8080/details/0 can visit I made the following:
1.Deploy the service in the namespace of the requested test(create DNS):
apiVersion: v1
kind: Service
labels:
app: details
service: details
name: details
spec:
clusterIP: 172.30.24.46
ports:
- name: http
port: 9080
protocol: TCP
targetPort: 9080
selector:
app: details
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
2.Create virtualService to forward flow
kind: VirtualService
metadata:
name: details
namespace: request-namespace
spec:
hosts:
- details.alter-470869450099302400.svc.cluster.local
http:
- name: remote-namespace-route
route:
- destination:
host: details.istio-project.svc.cluster.local
port:
number: 9080
then I do ‘curl http://details:8080/details/0’ failed:
curl: (56) Recv failure: Connection reset by peer
envoy log:
[2020-11-16T07:37:12.207Z] "- - -" 0 UF,URX "-" "-" 0 0 10001 - "-" "-" "-" "-" "172.30.24.46:8080" PassthroughCluster - 172.30.24.46:8080 10.108.144.56:33778 - -
when I use curl http://details:9080/details/0 ok