Kubernetes 如何配置istio路由,使其将所有流量发送到一个pod而不是另一个pod?

Kubernetes 如何配置istio路由,使其将所有流量发送到一个pod而不是另一个pod?,kubernetes,istio,Kubernetes,Istio,我在GKE集群上运行了以下routing.yaml文件和两个服务 apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: frontend namespace: prefix spec: hosts: - frontend http: - route: - destination: host: frontend s

我在GKE集群上运行了以下routing.yaml文件和两个服务

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: frontend
  namespace: prefix
spec:
  hosts:
    - frontend
  http:
    - route:
      - destination:
          host: frontend
          subset: prod
        weight: 100
---

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: backend
  namespace: prefix
spec:
  hosts:
    - backend
  http:
    - route:
      - destination:
          host: backend
          subset: prod
        weight: 100
现在,每当我点击http请求时,我希望我的前端产品应该得到所有的请求和响应应该是相同的。但事实证明这是不同的,最糟糕的是其他服务器被随机攻击 以下是输出

http GET xx.xx.xx.xx:6756/get_prefix class==d 'Authorization: Token 95cd418693b14ddc87220430e7225ab5'
HTTP/1.1 403 Forbidden
content-length: 159
content-type: text/html
date: Thu, 24 Oct 2019 09:32:25 GMT
server: istio-envoy
x-envoy-decorator-operation: frontend.prefix.svc.cluster.local:6756/*
x-envoy-upstream-service-time: 4

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>403 Forbidden</title>
<h1>Forbidden</h1>
<p>YOUR TOKEN IS INVALID, YOU CAN'T ASK FOR PREFIX</p>
后端服务文件与端口6757类似。 如何确保流量只流向一个吊舱

kubectl get pods --namespace prefix
NAME                               READY   STATUS    RESTARTS   AGE
backend-canary-7978f77b58-7qzh6    2/2     Running   0          126m
backend-prod-5ff66456f9-zwxxn      2/2     Running   0          126m
frontend-canary-7dd5c45dfc-lcfh6   2/2     Running   0          126m
frontend-prod-7f6d9b5ddc-bkk5h     2/2     Running   0          126m

你有一个匹配的DestinationRule对象吗?没有,VirtualService没有取代RouteRule吗?我想我们在RouteRule不需要它。我对此不熟悉。
子集:
DestinationRule
对象中声明的子集匹配。Istio文档中的示例并没有真正突出显示它们,但顶部有一个注释,它取决于一组匹配的
子集:
到pod标签。@DavidMaze找到了,这太棒了helpful@DavidMaze但前端的LoadBalancer仍然以循环方式路由请求,我为他们制定了相应的命运规则。虽然我在后端完成了,但前端仍然进行循环。我想那是因为GKE的磅?
apiVersion: v1
kind: Service

metadata:
  name: frontend
  labels:
    app: frontend
  namespace: prefix

spec:
  selector:
    app: frontend
  type: LoadBalancer
  ports:
    - port: 6756
      targetPort: 6756
      name: http
kubectl get pods --namespace prefix
NAME                               READY   STATUS    RESTARTS   AGE
backend-canary-7978f77b58-7qzh6    2/2     Running   0          126m
backend-prod-5ff66456f9-zwxxn      2/2     Running   0          126m
frontend-canary-7dd5c45dfc-lcfh6   2/2     Running   0          126m
frontend-prod-7f6d9b5ddc-bkk5h     2/2     Running   0          126m