Demo of Istio 1.5.x integration
1. Background
The RPC capability supported by layotto is implemented by mosn, it means that the RPC feature can reuse the capabilities in mosn.
Mosn is officially recognized by istio as a data plane implementation. Here is how to combine layotto (build on mosn) with istio and dynamically adjust service routing through XDS protocol.
2. Preparation
before starting the demo,you must install some components as follows:
-
Download from the official website and install it.
-
same as above, just follow the doc in official website.
-
You need to download the
1.5.xversion ofistio. After decompressing, configure it as follows to facilitate subsequent operations.export PATH=$PATH:${your istio directory}/bin
3. Start the demo
-
Run Docker Desktop
-
Run the following command to start
minikubeminikube start -
Run the following command to start the services in the demo (all the dependent images have been uploaded to the docker hub)
kubectl apply -f layotto-injected.yamlThe contents of
layotto-injected.yamlis here ,just copy it。 -
Run the command
kubectl get podto check the status (it needs to download the dependent images during the first startup,so please wait patiently)NAME READY STATUS RESTARTS AGE
client-665c5cc4f-tfxrk 2/2 Running 0 49m
server-v1-685966b499-8hnqp 2/2 Running 0 49m
server-v2-6cfff5dbb5-4hlgb 2/2 Running 0 49mWhen you see something similar to the above, it indicates that the startup is successful. We have deployed a client and a server. The server side is divided into V1 and V2 versions.
-
If you want to access the services in the
istiocluster from the outside, you must configure theistio ingress gatewayservice, which will increase the cost of getting started. Therefore, the proxy method is used here to simplify this demo.Run the following command
kubectl port-forward svc/client 9080:9080Then you can directly access the following links, or you can directly access them in the browser.
curl localhost:9080/grpcWhen you see the following response, the example starts successfully.
GET /hello
hello, i am layotto v1
4. Using istio to dynamically change routing policy
A. route according to version
-
Run the following command to create destination rules
kubectl apply -f destination-rule-all.yamlThe contents of
destination-rule-all.yamlis here -
Run the following command to specify that only the V1 service is accessed
kubectl apply -f layotto-virtual-service-all-v1.yamlThe contents of
layotto-virtual-service-all-v1.yamlis here -
After the above command is executed, subsequent requests will only get the return result of v1, as follows:
GET /hello
hello, i am layotto v1
B. route according to a specific header
-
Run the following command to modify the routing rules to access the v1 service when the request header contains
name:layotto, and other access to the v2 servicekubectl apply -f layotto-header-route.yaml -
Send the request to see the result
curl -H 'name: layotto' localhost:9080/grpc
5. Note
-
Since the example uses
istio 1.5.2, which is an older version, the demo will not be merged into the main branch, but exists as a separate branchistio-1.5.x. Currently the main branch code has been integrated withistio 1.10.x. -
For the source code of client and server used in the example, please refer to here.
-
In order to get started simple, the
layotto-injected.yamlfile used above has been injected through istio already. This injection process is as follows:- Run the following command to specify
istioto useLayottoas the data plane
istioctl manifest apply --set .values.global.proxy.image="mosnio/proxyv2:layotto" --set meshConfig.defaultConfig.binaryPath="/usr/local/bin/mosn"- Sidecar injection is achieved through
kube-inject
istioctl kube-inject -f layotto.yaml > layotto-injected.yamlThe contents of
layotto.yamlis here- Run the following command to replace all
/usr/local/bin/envoyinlayotto-injected.yamlwith/usr/local/bin/mosn
sed -i "s/\/usr\/local\/bin\/envoy/\/usr\/local\/bin\/mosn/g" ./layotto-injected.yaml - Run the following command to specify