nacos icon indicating copy to clipboard operation
nacos copied to clipboard

How to configure dr, vs after registering to nacos service and synchronizing to istio?

Open mark8s opened this issue 1 year ago • 2 comments

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

mark8s avatar Aug 08 '22 01:08 mark8s

@SpecialYang Please help to review this issue.

KomachiSion avatar Aug 08 '22 11:08 KomachiSion

@KomachiSion 3q

mark8s avatar Aug 09 '22 01:08 mark8s

有开启istio的nds劫持吗?

yichouchou avatar Aug 22 '22 08:08 yichouchou

@yichouchou istio智能路由????

mark8s avatar Aug 22 '22 11:08 mark8s

mesh-server.test.public.nacos

你的se 是host:mesh-server.test.public.nacos ,假设你spring cloud未改造,是通过服务ip调用,自然不会生效的。 假设改造过了,是通过fqdn:mesh-server.test.public.nacos 调用,那么你需要开启istio的dns

yichouchou avatar Aug 22 '22 12:08 yichouchou

@yichouchou 我在cloud服务中,是使用 mesh-server访问的,这个会有影响吗? 我并未使用全 mesh-server.test.public.nacos。我已经开启了istio的dns。 我估计可能是我没使用全域名导致的。。。

mark8s avatar Aug 22 '22 12:08 mark8s

@yichouchou 我在cloud服务中,是使用 mesh-server访问的,这个会有影响吗? 我并未使用全 mesh-server.test.public.nacos。我已经开启了istio的dns。 我估计可能是我没使用全域名导致的。。。

curl一下便可以试出来,必须完全匹配host

yichouchou avatar Aug 22 '22 12:08 yichouchou

@yichouchou 3q ok了~

mark8s avatar Aug 23 '22 01:08 mark8s