---
# System prepended metadata

title: Opentelemetry-demo
tags: [cloud-native]

---

### Opentelemetry-demo
---
According to https://github.com/open-telemetry/opentelemetry-demo
### - OS:
GCP VM:+1: 
:+1: 

#### Prerequesties :+1: :
- k8s cluster (e.g. https://github.com/rich7420/kubernetes-shell)

We use helm to deploy opentelemetry-demo

#### to install hlem 
```bash
curl -fsSL https://raw.githubusercontent.com/rich7420/kubernetes-shell/refs/heads/main/kubernete_gcp/install_helm.sh | bash
```

#### Add OpenTelemetry Helm repository:
```bash
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
```

#### To install the chart with the release name my-otel-demo, run the following command:
```bash
helm install my-otel-demo open-telemetry/opentelemetry-demo
```

##### to build with loadbalancer for external ip(if you use GKE or YOU NEED TO USE STATIC ADDRESS in gcp vm)
```bash
helm upgrade my-otel-demo open-telemetry/opentelemetry-demo \
    --set components.frontend-proxy.service.type=LoadBalancer \
    --set components.frontend-proxy.service.port=8080
```

##### Test and use 
```bash
kubectl port-forward svc/frontend-proxy 8080:8080 -n default --address 0.0.0.0
```
- After port-forwarding, you can use ```http://<external ip>:8080``` to view telemetry-demo web.

##### delete useless pod
```bash
kubectl get pod -o wide | awk '($2 != "1/1" || ($3 != "Running" && $3 != "Pending")) && NR>1 {print $1}' | xargs kubectl delete pod
```



