创建deployments和对应的service,然后用ingressgateway暴露服务:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: myapp
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 15033 # gateway的端口
      name: myapp
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: myapp-vs
spec:
  hosts:
  - "*"
  gateways:
  - myapp
  http:
  - match:
    - port: 15033 # 匹配gateway的端口
    route:
    - destination:
        host: myapp-svc
        port:
          number: 8080
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: myapp
spec:
  host: myapp-svc
  trafficPolicy:
    tls:
      mode: DISABLE

修改istio-ingressgateway:

kubectl edit svc -n istio-system istio-ingressgateway

添加要暴露的端口信息:

  - name: myapp
    nodePort: 32759 # 要暴露的端口
    port: 15033
    protocol: TCP
    targetPort: 15033