Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support kubectl apply steps #37

Merged
merged 7 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions README_GCP.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ gcloud projects add-iam-policy-binding ${GCLOUD_PROJECT} \
--role "roles/cloudtrace.agent"
gcloud iam service-accounts add-iam-policy-binding opentelemetry-demo@${GCLOUD_PROJECT}.iam.gserviceaccount.com \
--role roles/iam.workloadIdentityUser \
--member "serviceAccount:${GCLOUD_PROJECT}.svc.id.goog[default/opentelemetry-demo]"
--member "serviceAccount:${GCLOUD_PROJECT}.svc.id.goog[otel-demo/opentelemetry-demo-otelcol]"
```

Update [`gcp-config-valus.yml`](gcp-config-values.yml) to annotate the
Expand All @@ -57,9 +57,31 @@ service account and annotate it to use Workload Identity.
Follow the [OpenTelemetry docs to run the Helm chart](https://opentelemetry.io/docs/demo/kubernetes-deployment):

```console
kubectl create namespace otel-demo
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo update
helm install my-otel-demo open-telemetry/opentelemetry-demo --values gcp-config-values.yml --version 0.29.1
helm install my-otel-demo open-telemetry/opentelemetry-demo --namespace otel-demo --values gcp-config-values.yml --version 0.29.1
```

### (Alternative) Using `kubectl apply`

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.

Update
[`kubernetes/opentelemetry-demo.yaml`](kubernetes/opentelemetry-demo.yaml) to
annotate the Kubernetes service account with your project:

```console
sed -i "s/%GCLOUD_PROJECT%/${GCLOUD_PROJECT}/g" ./kubernetes/opentelemetry-demo.yaml
```

Install the manifests:

```console
kubectl apply -n otel-demo -f ./kubernetes/opentelemetry-demo.yaml
```

## Running on GCE
Expand Down
2 changes: 1 addition & 1 deletion gcp-config-values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
serviceAccount:
create: true
annotations: {"iam.gke.io/gcp-service-account":"opentelemetry-demo@%GCLOUD_PROJECT%.iam.gserviceaccount.com"}
name: "opentelemetry-demo"
name: "opentelemetry-demo-otelcol"

config:
processors:
Expand Down Expand Up @@ -76,8 +76,8 @@
exporters: [googlecloud]
traces:
processors: [memory_limiter, resourcedetection, resource, batch]
exporters: [googlecloud] #spanmetrics disabled

Check warning on line 79 in gcp-config-values.yml

View workflow job for this annotation

GitHub Actions / yamllint

79:36 [comments] too few spaces before comment

Check warning on line 79 in gcp-config-values.yml

View workflow job for this annotation

GitHub Actions / yamllint

79:37 [comments] missing starting space in comment
metrics:
receivers: [otlp] #spanmetrics disabled

Check warning on line 81 in gcp-config-values.yml

View workflow job for this annotation

GitHub Actions / yamllint

81:29 [comments] too few spaces before comment

Check warning on line 81 in gcp-config-values.yml

View workflow job for this annotation

GitHub Actions / yamllint

81:30 [comments] missing starting space in comment
processors: [filter/currency, memory_limiter, resourcedetection, transform/collision, resource, batch]
exporters: [googlemanagedprometheus]
68 changes: 55 additions & 13 deletions kubernetes/opentelemetry-demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ kind: ServiceAccount
metadata:
name: opentelemetry-demo-otelcol
namespace: otel-demo
annotations:
iam.gke.io/gcp-service-account: "opentelemetry-demo@%GCLOUD_PROJECT%.iam.gserviceaccount.com"
labels:
app.kubernetes.io/name: otelcol
app.kubernetes.io/instance: opentelemetry-demo
Expand Down Expand Up @@ -179,10 +181,21 @@ data:
endpoint: http://opentelemetry-demo-prometheus-server:9090/api/v1/otlp
tls:
insecure: true

googlecloud:
log:
default_log_name: opentelemetry.io/opentelemetry-demo

googlemanagedprometheus:

extensions:
health_check: {}
processors:
batch: {}
batch:
send_batch_max_size: 200
send_batch_size: 200
timeout: 5s

filter/ottl:
error_mode: ignore
metrics:
Expand Down Expand Up @@ -212,21 +225,48 @@ data:
- sources:
- from: connection
memory_limiter:
check_interval: 5s
limit_percentage: 80
spike_limit_percentage: 25
check_interval: 1s
limit_percentage: 65
spike_limit_percentage: 20
resource:
attributes:
- action: insert
from_attribute: k8s.pod.uid
key: service.instance.id
resourcedetection:
detectors: [gcp]
timeout: 10s

transform:
metric_statements:
- context: metric
statements:
- set(description, "") where name == "queueSize"
- set(description, "") where name == "rpc.server.duration"
- set(description, "") where name == "http.client.duration"
transform/collision:
metric_statements:
- context: datapoint
statements:
- set(attributes["exported_location"], attributes["location"])
- delete_key(attributes, "location")
- set(attributes["exported_cluster"], attributes["cluster"])
- delete_key(attributes, "cluster")
- set(attributes["exported_namespace"], attributes["namespace"])
- delete_key(attributes, "namespace")
- set(attributes["exported_job"], attributes["job"])
- delete_key(attributes, "job")
- set(attributes["exported_instance"], attributes["instance"])
- delete_key(attributes, "instance")
- set(attributes["exported_project_id"], attributes["project_id"])
- delete_key(attributes, "project_id")

# See https://github.com/open-telemetry/opentelemetry-demo/issues/1330
filter/currency:
metrics:
metric:
- 'IsMatch(name, "(.*)app_currency(.*)")'

receivers:
jaeger:
protocols:
Expand Down Expand Up @@ -262,41 +302,43 @@ data:
pipelines:
logs:
exporters:
- debug
- googlecloud
processors:
- k8sattributes
- resourcedetection
- resource
- memory_limiter
- batch
receivers:
- otlp
metrics:
exporters:
- otlphttp/prometheus
- debug
- googlemanagedprometheus
processors:
- k8sattributes
- memory_limiter
- filter/ottl
- filter/currency
- resourcedetection
- transform
- transform/collision
- resource
- batch
receivers:
- otlp
- spanmetrics
#- spanmetrics
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were the commented out lines in this file intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, spanmetrics is enabled in the upstream demo but it caused errors with GCP (I think due to rate/duplicate timeseries) so I commented them out in our docker compose config and helm chart. Left them here as a reminder to stay in sync

traces:
exporters:
- otlp
- debug
- spanmetrics
- googlecloud
#- spanmetrics
processors:
- k8sattributes
- memory_limiter
- resourcedetection
- resource
- batch
receivers:
- otlp
- jaeger
- zipkin
telemetry:
metrics:
address: ${env:MY_POD_IP}:8888
Expand Down
Loading