# istio-distributed-tracing-example **Repository Path**: keren_chen/istio-distributed-tracing-example ## Basic Information - **Project Name**: istio-distributed-tracing-example - **Description**: https://github.com/snowdrop/istio-distributed-tracing-example.git - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-09-27 - **Last Updated**: 2022-09-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README = Istio Distributed Tracing Mission == Purpose Showcase Istio's Distributed Tracing via a (minimally) instrumented set of Spring Boot applications == Prerequisites . Openshift 3.10 cluster . Istio 1.0.x installed on the aforementioned cluster using the link:https://github.com/Maistra/istio-operator[Istio Operator]. .. Follow link:https://github.com/Maistra/openshift-ansible/blob/maistra-0.1.0-ocp-3.1.0-istio-1.0.0/istio/Installation.md[these] instructions for more information about the Operator . Login to the cluster with the *admin* user == Environment preparation Create a new project/namespace on the cluster. This is where your application will be deployed. ```bash oc new-project ``` In link:https://docs.openshift.com/container-platform/3.11/servicemesh-install/servicemesh-install.html#configuring-security-constraints-for-application-service-accounts[OpenShift] each service account must be granted permissions with the anyuid and privileged Security Context Constraints (SCC) to enable the sidecars to run correctly. ```bash oc adm policy add-scc-to-user anyuid -z default -n oc adm policy add-scc-to-user privileged -z default -n ``` == Build and deploy the application === With Fabric8 Maven Plugin (FMP) Execute the following command to build the project and deploy it to OpenShift: ```bash mvn clean fabric8:deploy -Popenshift ``` Configuration for FMP may be found both in pom.xml and `src/main/fabric8` files/folders. This configuration is used to define service names and deployments that control how pods are labeled/versioned on the OpenShift cluster. Labels and versions are key concepts for creating load-balanced or multi-versioned pods in a service. === With Source to Image build (S2I) Run the following commands to apply and execute the OpenShift templates that will configure and deploy the applications: ```bash find . | grep openshiftio | grep application | xargs -n 1 oc apply -f oc new-app --template=istio-distributed-tracing-example-greeting-service -p SOURCE_REPOSITORY_URL=https://github.com/snowdrop/istio-distributed-tracing-example -p SOURCE_REPOSITORY_REF=master -p SOURCE_REPOSITORY_DIR=spring-boot-istio-distributed-tracing-greeting-service oc new-app --template=istio-distributed-tracing-example-cute-name-service -p SOURCE_REPOSITORY_URL=https://github.com/snowdrop/istio-distributed-tracing-example -p SOURCE_REPOSITORY_REF=master -p SOURCE_REPOSITORY_DIR=spring-boot-istio-distributed-tracing-cute-name-service ``` = Use Cases == Access the application via the Istio ingress-gateway . Create a RouteRule to forward traffic from istio-ingress to the demo application + ```bash oc create -f rules/greeting-gateway.yml ``` . Access the application + Run the following command to determine the appropriate URL to access our demo. Make sure you access the url with the HTTP scheme. HTTPS is NOT enabled by default: + ```bash echo http://$(oc get route istio-ingressgateway -o jsonpath='{.spec.host}{"\n"}' -n istio-system)/greeting/ ``` + The result of the above command is the istio-system istio-ingress URL, appended with the RouteRule path. Open this URL in your a web browser. . Follow the instructions in the application UI == View application traces . Access the Jaeger tracing dashboard + The traces from the invocation of the two endpoints should look like the following: + image::spring-boot-istio-distributed-tracing-greeting-service/src/main/resources/static/traces.jpg[] + Note that it could take a few seconds for all the spans to be collected and presented in a trace that matches the picture above == Undeploy the application === With Fabric8 Maven Plugin (FMP) ```bash mvn fabric8:undeploy ``` === With Source to Image build (S2I) ```bash oc delete all --all oc delete ingress --all find . | grep openshiftio | grep application | xargs -n 1 oc delete -f ``` === Remove the namespace This will delete the project from the OpenShift cluster ```bash oc delete project ``` == Integration tests To run integration tests, create a new namespace and run maven job ```bash oc new-project mvn clean verify -Popenshift,openshift-it ```