Open this demo app in Google Cloud Shell. This includes necessary tools.
If you are using Cloud Shell, skip to the next section.
- Install gcloud https://cloud.google.com/sdk/install
- Install kubectl https://kubernetes.io/docs/tasks/tools/install-kubectl/
- Install docker https://docs.docker.com/install/
-
Enable Google Cloud and set up region and zone.
gcloud init
-
Enable the GKE API:
gcloud services enable container.googleapis.com
-
Setup GCP project to
YOUR_PROJECT_ID
. ReplaceYOUR_PROJECT_ID
with your GCP project id.gcloud config set project YOUR_PROJECT_ID
-
Setup the location of GKE cluster and create a new cluster named
cloud-trace-demo
. The example below sets the cluster's location to the "us-central1-c" zone. You can replace the zone with one which you like. See zones for the full list.ZONE=us-central1-c gcloud container clusters create cloud-trace-demo \ --zone $ZONE
-
Update GKE cluster credentials and verify the access to the cluster:
gcloud container clusters get-credentials cloud-trace-demo --zone $ZONE kubectl get nodes
The output is similar to the following:
NAME STATUS ROLES AGE VERSION gke-cloud-trace-demo-default-pool-43f3fe97-dnk1 Ready <none> 5m v1.23.8-gke.1900 gke-cloud-trace-demo-default-pool-43f3fe97-j2b8 Ready <none> 5m v1.23.8-gke.1900 gke-cloud-trace-demo-default-pool-43f3fe97-znvv Ready <none> 5m v1.23.8-gke.1900
-
Download the demo application:
git clone https://github.com/GoogleCloudPlatform/python-docs-samples cd python-docs-samples/trace/cloud-trace-demo-app-opentelemetry/
-
Setup the application:
./setup.sh
The setup deployes 3 services of the demo application using a pre-built image. If you like, you can build your own container image using
app/Dockerfile
. -
Track the status of the deployment:
kubectl get deployments
The output is similar to the following:
NAME READY UP-TO-DATE AVAILABLE AGE cloud-trace-demo-a 1/1 1 1 3m cloud-trace-demo-b 1/1 1 1 3m cloud-trace-demo-c 1/1 1 1 3m
-
Send a curl request to the cloud-trace-demo-a:
curl $(kubectl get svc -o=jsonpath='{.items[?(@.metadata.name=="cloud-trace-demo-a")].status.loadBalancer.ingress[0].ip}')
The output is similar to the following:
Hello, I am service A And I am service B Hello, I am service C
-
Visit Trace List to check traces generated. Click on any trace in the graph to see the Waterfall View.
-
To clean up the provisioned resources:
gcloud container clusters delete cloud-trace-demo --zone $ZONE