



sudo kubectl create namespace netistiodemo sudo kubectl label namespace netistiodemo istio-injection=enabled sudo kubectl get ns netistiodemo --show-labels # 查看注入状态 sudo kubectl apply -f netapp-1nodes.yaml -n netistiodemo sudo kubectl apply -f netapp-destination.yaml -n netistiodemo
sudo kubectl apply -f nettapp-vs-v1.yaml -n netistiodemo







gateway:springbootapp-gateway为同namespace的gateway;netistiodemo/netapp-gateway为netistiodemo空间的gateway,格式【命名空间】/【gateway名】 match:uri prefix前缀匹配,将以/net/、/netcore/为前缀的请求,映射到netapp服务上;请求规则支持exact(完全匹配),prefix(前缀匹配)、regex(正则匹配)三种匹配方式 host:netapp-svc.netistiodemo.svc.cluster.local,指向namespace为netistiodemo的.netcore服务中,格式【service svc】+【命名空间】+ 【默认:svc.cluster】 + 【集群名称】







apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: springbootapp-v1 spec: hosts: - "*" gateways: - springbootapp-gateway - netistiodemo/netapp-gateway http: - fault: delay: fixedDelay: 1s percent: 100 match: - uri: prefix: /net/ - uri: prefix: /netcore/ rewrite: uri: / route: - destination: host: netapp-svc.netistiodemo.svc.cluster.local port: number: 8081 subset: v1 - match: - uri: exact: /netdefault rewrite: uri: /api/Query/getDetaultStr route: - destination: host: netapp-svc.netistiodemo.svc.cluster.local port: number: 8081 subset: v1 - match: - uri: exact: /redirect redirect: authority: springbootapp-svc uri: /hello - match: - uri: prefix: /spring rewrite: uri: / route: - destination: host: springbootapp-svc port: number: 8080 subset: v1 weight: 70 - destination: host: springbootapp-svc port: number: 8080 subset: v2 weight: 30 timeout: 5s - route: - destination: host: netapp-svc.netistiodemo.svc.cluster.local port: number: 8081 subset: v1





