The demo can send logs, traces, and metrics to Google Cloud. The easiest way to
do this is with the gcp/helmfile.yaml
(when
deploying via Helmfile on GKE) or
src/otelcollector/otelcol-config-extras.yml
when running with docker-compose
on GCE.
The recommended way to run the demo on GKE is with the official Helm chart. If running on a GKE Autopilot cluster (or any cluster with Workload Identity), you must follow the prerequisite steps to set up a Workload Identity-enabled service account below. Otherwise, you can skip to the next section.
Grant permission using Workload Identity to write logs, traces, and metrics:
export GCLOUD_PROJECT=<your project id>
export PROJECT_NUMBER=$(gcloud projects describe ${GCLOUD_PROJECT} --format='get(projectNumber)')
gcloud projects add-iam-policy-binding ${GCLOUD_PROJECT} \
--member "principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${PROJECT_ID}.svc.id.goog/subject/ns/otel-demo/sa/opentelemetry-demo-otelcol" \
--role "roles/logging.logWriter"
gcloud projects add-iam-policy-binding ${GCLOUD_PROJECT} \
--member "principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${PROJECT_ID}.svc.id.goog/subject/ns/otel-demo/sa/opentelemetry-demo-otelcol" \
--role "roles/monitoring.metricWriter"
gcloud projects add-iam-policy-binding ${GCLOUD_PROJECT} \
--member "principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${PROJECT_ID}.svc.id.goog/subject/ns/otel-demo/sa/opentelemetry-demo-otelcol" \
--role "roles/cloudtrace.agent"
gcloud iam service-accounts add-iam-policy-binding opentelemetry-demo@${GCLOUD_PROJECT}.iam.gserviceaccount.com \
--member "principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${PROJECT_ID}.svc.id.goog/subject/ns/otel-demo/sa/opentelemetry-demo-otelcol" \
--role roles/iam.workloadIdentityUser \
Make sure you have the following installed:
Ensure you have either configured or disabled Workload Identity in your cluster.
helmfile --interactive apply -f gcp/helmfile.yaml
To clean up, run:
helmfile --interactive destroy -f gcp/helmfile.yaml
Installing with the Helm chart is recommended, but you can also use kubectl apply
to install the manifests directly.
First, make sure you have followed the Workload Identity setup steps above.
Install the manifests:
kubectl apply -n otel-demo -f ./kubernetes/opentelemetry-demo.yaml
Follow the OpenTelemetry docs to run with Docker:
make start
With the demo running, you should see telemetry automatically created by the demo's load generator. You can see metrics under "Prometheus Target" in Cloud Monitoring:
Traces in the Trace explorer:
And logs in the Logs explorer organized by service: