By entering request Gateway Istio, and issued frontend-v1 and frontend-v2 micro service by requesting VirtualService different header respectively.
Https://istio.io/docs/reference/config/networking/gateway/ about Gateway can view
this article to be completed "OpenShift Service 4 of Mesh tutorial (4) - traffic management" after the operation. Need to run before the official start of the operation the following command to run my-istio-app project applications to empty the contents.
$ scripts/teardown.sh
- Execute commands, create frontend-v1 and frontend-v2 micro services and related resources.
$ oc apply -f ocp/frontend-v1-deployment.yml
$ oc apply -f ocp/frontend-v2-deployment.yml
$ oc apply -f ocp/frontend-service.yml
$ oc apply -f ocp/frontend-route.yml
$ oc apply -f ocp/backend-v1-deployment.yml
$ oc apply -f ocp/backend-service.yml
- Run command, and then micro-service call path Kiali the console to view the request.
$ scripts/run-50.sh
3. Run created Gateway.
$ oc apply -f istio-files/frontend-gateway.yml
Note: In the runs of this Gateway istio-system, and corresponds to a route through istio = ingressgateway the label.
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: frontend-gateway
spec:
selector:
istio: ingressgateway # use istio default controller, in this example, default controller is istio-system
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- '*'
- Execute command creates Virtual Service and Destination Rule.
$ oc apply -f istio-files/destination-rule-frontend-v1-v2.yml
$ oc apply -f istio-files/virtual-service-frontend-header-foo-bar-to-v1.yml
Wherein the virtual-service-frontend-header-foo-bar-to-v1.yml conditions based routing header comprising of:
...
- match:
- headers:
foo:
exact: bar
route:
- destination:
host: frontend
subset: v1
...
5. Obtain access gateway address, and then specify a default access gateway header, acknowledgment different flows Frontend.
$ export GATEWAY_URL=$(oc get route istio-ingressgateway -n istio-system -o jsonpath='{.spec.host}')
$ curl $GATEWAY_URL
Frontend version: v2 => [Backend: http://backend:8080, Response: 200, Body: Backend version:v1,Response:200,Host:backend-v1-6ddf9c7dcf-ppk77, Message: Hello World!!]
$ curl -H foo:bar $GATEWAY_URL
Frontend version: v1 => [Backend: http://backend:8080, Response: 200, Body: Backend version:v1,Response:200,Host:backend-v1-6ddf9c7dcf-ppk77, Message: Hello World!!]
- To view micro-service call path Kiali console.