nacos
nacos copied to clipboard
How to configure dr, vs after registering to nacos service and synchronizing to istio?
I use nacos's mcp over xds, but I don't know how to configure destination and virtual service for spring cloud. Can anyone help me?
The content of serviceEntry generated by nacos is as follows:
{
"kind": "ServiceEntry",
"apiVersion": "networking.istio.io/v1alpha3",
"metadata": {
"name": "mesh-server.test.public",
"namespace": "public",
"resourceVersion": "2022-08-05 10:02:31.167195328 +0000 UTC m=+30664.233598148",
"creationTimestamp": "2022-08-05T09:26:35Z",
"labels": {
"registryType": "nacos"
},
"annotations": {
"virtual": "1"
}
},
"spec": {
"endpoints": [
{
"address": "10.244.0.173",
"labels": {
"cluster": "DEFAULT",
"preserved.register.source": "SPRING_CLOUD"
},
"ports": {
"http": 8081
},
"weight": 1
},
{
"address": "10.244.0.174",
"labels": {
"cluster": "DEFAULT",
"preserved.register.source": "SPRING_CLOUD"
},
"ports": {
"http": 8081
},
"weight": 1
},
{
"address": "10.244.0.172",
"labels": {
"cluster": "DEFAULT",
"preserved.register.source": "SPRING_CLOUD"
},
"ports": {
"http": 8081
},
"weight": 1
}
],
"hosts": [
"mesh-server.test.public.nacos"
],
"location": "MESH_INTERNAL",
"ports": [
{
"name": "http",
"number": 8081,
"protocol": "HTTP"
}
],
"resolution": "STATIC"
}
}
My dr, VS configuration:does not take effect
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: dr
spec:
host: mesh-server.test.public.nacos
subsets:
- labels:
version: v1
name: v1
- labels:
version: v2
name: v2
- labels:
version: v3
name: v3
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: dr
spec:
hosts:
- mesh-server.test.public.nacos
http:
- route:
- destination:
host: nacos-istio-provider
subset: v2
weight: 100
my deployed service:
$ kubectl get po
NAME READY STATUS RESTARTS AGE
nacos-istio-comsumer-847b4945bf-jthm2 2/2 Running 0 2d15h
nacos-istio-provider-75689b667-clqmx 2/2 Running 0 2d15h
nacos-istio-provider-v2-6cff45878d-45dmd 2/2 Running 0 2d15h
nacos-istio-provider-v3-545b776d5b-bx29s 2/2 Running 0 2d15h
my nacos :
@SpecialYang Please help to review this issue.
@KomachiSion 3q
有开启istio的nds劫持吗?
@yichouchou istio智能路由????
mesh-server.test.public.nacos
你的se 是host:mesh-server.test.public.nacos ,假设你spring cloud未改造,是通过服务ip调用,自然不会生效的。 假设改造过了,是通过fqdn:mesh-server.test.public.nacos 调用,那么你需要开启istio的dns
@yichouchou 我在cloud服务中,是使用 mesh-server访问的,这个会有影响吗? 我并未使用全 mesh-server.test.public.nacos。我已经开启了istio的dns。 我估计可能是我没使用全域名导致的。。。
@yichouchou 我在cloud服务中,是使用 mesh-server访问的,这个会有影响吗? 我并未使用全 mesh-server.test.public.nacos。我已经开启了istio的dns。 我估计可能是我没使用全域名导致的。。。
curl一下便可以试出来,必须完全匹配host
@yichouchou 3q ok了~