新页面
部署 Gateway
ingress_gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: bookinfo-gateway
spec:
selector:
istio: ingress
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
kubectl -n bookinfo apply -f ingress_gateway.yaml
部署 VirtualService
productpage_vs.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo
spec:
hosts:
- "*"
gateways:
- bookinfo-gateway
http:
- match:
- uri:
exact: /productpage
- uri:
prefix: /static
- uri:
exact: /login
- uri:
exact: /logout
- uri:
prefix: /api/v1/products
route:
- destination:
host: productpage
port:
number: 9080
kubectl -n bookinfo apply -f productpage_vs.yaml
通过istio访问 带上/productpage
#查看istio-ingress的NodePort端口
kubectl get svc -n istio-system
可手动修改访问端口,port端口号和ingress_gateway.yaml文件中number对上即可
kubectl edit svc istio-ingressgateway -n istio-system
- name: http-test
nodePort: 32666
port: 666
protocol: TCP
targetPort: 666