Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Created December 29, 2022 19:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vfarcic/4418b87dea48c7c4b1811d65f5133947 to your computer and use it in GitHub Desktop.
Save vfarcic/4418b87dea48c7c4b1811d65f5133947 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/4418b87dea48c7c4b1811d65f5133947
###################################################################
# Distributed Tracing With Jaeger And OpenTelemetry In Kubernetes #
# https://youtu.be/FK0uh-7nDSg #
###################################################################
# Additional Info:
# - Jaeger: https://jaegertracing.io
# - You MUST Instrument Your Code With OpenTelemetry!: https://youtu.be/oe5YYh9mhzw
#########
# Setup #
#########
# Create a Kubernetes cluster with Ingress set as default
git clone https://github.com/vfarcic/silly-demo
cd silly-demo
# Replace `127.0.0.1` with the Ingress Service IP
export INGRESS_HOST=127.0.0.1
# Install `yq` CLI from https://github.com/mikefarah/yq if you do not have it already
# Install `jq` CLI from https://stedolan.github.io/jq/download/
yq --inplace \
".spec.rules[0].host = \"silly-demo.$INGRESS_HOST.nip.io\"" \
kustomize/base/ingress.yaml
yq --inplace \
".spec.rules[0].host = \"pinger.$INGRESS_HOST.nip.io\"" \
kustomize/overlays/pinger-jaeger/ingress.yaml
kubectl create namespace production
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm upgrade --install cert-manager jetstack/cert-manager \
--namespace cert-manager --create-namespace \
--set installCRDs=true --wait
kubectl create namespace observability
kubectl --namespace observability apply \
--filename https://github.com/jaegertracing/jaeger-operator/releases/download/v1.39.0/jaeger-operator.yaml
#######################################
# Push OpenTelemetry Traces To Jaeger #
#######################################
kubectl kustomize --enable-helm \
kustomize/overlays/stateful-db \
| kubectl --namespace production apply --filename -
echo "
apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
name: jaeger
spec:
ingress:
enabled: true
hosts:
- jaeger.$INGRESS_HOST.nip.io
" | kubectl --namespace observability apply --filename -
kubectl --namespace observability get jaegers
echo "http://jaeger.$INGRESS_HOST.nip.io"
# Open it in a browser
cat kustomize/overlays/stateful-db-jaeger/deployment-patch.yaml
kubectl kustomize --enable-helm \
kustomize/overlays/stateful-db-jaeger \
| kubectl --namespace production apply --filename -
##########################################
# Explore OpenTelemetry Traces In Jaeger #
##########################################
cat main.go
cat video.go
curl -X POST "http://silly-demo.$INGRESS_HOST.nip.io/video?id=wNBG1-PSYmE&title=Kubernetes%20Policies%20And%20Governance%20-%20Ask%20Me%20Anything%20With%20Jim%20Bugwadia"
curl -X POST "http://silly-demo.$INGRESS_HOST.nip.io/video?id=VlBiLFaSi7Y&title=Scaleway%20-%20Everything%20We%20Expect%20From%20A%20Cloud%20Computing%20Service%3F"
curl "http://silly-demo.$INGRESS_HOST.nip.io/videos" | jq .
# Show the traces in Jaeger
# Service: `silly-demo`
# Tags: `http.method=POST`
cat fibonacci.go
curl "http://silly-demo.$INGRESS_HOST.nip.io/fibonacci?number=10"
# Show the traces in Jaeger
cat video.go
curl -X POST "http://silly-demo.$INGRESS_HOST.nip.io/video?id=VlBiLFaSi7Y&title=Scaleway%20-%20Everything%20We%20Expect%20From%20A%20Cloud%20Computing%20Service%3F"
# Show the traces in Jaeger
#####################################################
# Distributed Tracing With OpenTelemetry And Jaeger #
#####################################################
kubectl --namespace production apply \
--kustomize kustomize/overlays/pinger-jaeger
curl "http://pinger.$INGRESS_HOST.nip.io/ping?url=http://silly-demo:8080"
# Show the traces in Jaeger
###########
# Destroy #
###########
# Destroy or reset the cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment