首页 > 解决方案 > 如何在 istio 中为子页面配置入口路由?

问题描述

我有一个 Web 应用程序的负载均衡器服务。

如果我们打开 http://LB ,该页面应该以 http:///productpage 启动,它将只显示空白页面,因为主要产品在 productpage url 中。

那么,如何在 istio 网关 VirtualService 中进行配置呢?请建议。

我试过的样品。

部署:

apiVersion: v1
kind: Service
metadata:
  name: mart-service
  labels:
    app: mart
    service: mart
spec:
  selector:
    app: mart
  ports:
    - name: http 
      port: 80
      targetPort: 18170

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: mart-details
  labels:
    account: mart
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mart-deployment
  labels:
    app: mart
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mart
      version: v1
  template:
    metadata:
      labels:
        app: mart
        version: v1
    spec:
      serviceAccountName: mart-details
      containers:
        - name: mart
          image: martserver.azurecr.io/mart:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 18170
              name: mart-port
          #securityContext:
              #runAsUser: 1000
          volumeMounts:
            - mountPath: /home/spring/AppData/Local/erwin/Mart Server/
              name: mart-volume
      volumes:
      - name: mart-volume
        persistentVolumeClaim:
          claimName: martpv


---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
 name: martpv
 labels:
   app: mart
   version: v1
spec:
 accessModes:
 - ReadWriteMany
 storageClassName: azurefile
 resources:
   requests:
     storage: 5Gi

网关:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: martserver-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"

虚拟服务:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: martserver
spec:
  hosts:
  - "*"
  gateways:
  - martserver-gateway
  http:
  - match:
    - uri:
        exact: /MartServer
    - uri:
        exact: /
    route:
    - destination:
        host: mart-service
        port:
          number: 80

请立即忽略该图像,因为它是私人仓库。当我尝试使用 LoadBalancer 类型的服务和连接时,产品工作正常。

页面打不开:http://IG/MartServer

并且,kiali 输出。

在此处输入图像描述

标签: istio

解决方案


推荐阅读