Skip to content

Commit

Permalink
[dash0] scripts for deploying the otel demo to k8s locally
Browse files Browse the repository at this point in the history
Either deploy to one namespace or to two different namespaces (just to
make the deployment topology a bit more "interesting").
  • Loading branch information
basti1302 committed Feb 5, 2024
1 parent e445ba6 commit fdaa0e6
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .licenserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"src/featureflagservice/priv/",
"src/productcatalogservice/genproto/",
"internal/tools/",
".github/actions/deploy-demo/action.yaml",
".github/actions/update-env-file/action.yaml"
".github/actions/",
"kubernetes/local/"
]
}
}
3 changes: 3 additions & 0 deletions kubernetes/local/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dash0-values.yaml
ns1-values.yaml
ns2-values.yaml
4 changes: 4 additions & 0 deletions kubernetes/local/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Helper Scripts to Deploy the Dash0 fork of the OpenTelemetry Demo to Kubernetes Locally
=======================================================================================

See <https://docs.google.com/document/d/1ASCn8AUR0ehqSynsUkTqvH2biTYsFAxz1rXi1Lkh3DE/edit#heading=h.sku3rt6c70ac>.
57 changes: 57 additions & 0 deletions kubernetes/local/cross-namespace-service-names.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: v1
kind: Service
metadata:
name: opentelemetry-demo-in-ns2-emailservice
namespace: otel-demo-ns1
spec:
type: ExternalName
externalName: opentelemetry-demo-ns2-emailservice.otel-demo-ns2.svc.cluster.local
ports:
- port: 8080
---
apiVersion: v1
kind: Service
metadata:
name: opentelemetry-demo-in-ns2-paymentservice
namespace: otel-demo-ns1
spec:
type: ExternalName
externalName: opentelemetry-demo-ns2-paymentservice.otel-demo-ns2.svc.cluster.local
ports:
- port: 8080
---
apiVersion: v1
kind: Service
metadata:
name: opentelemetry-demo-in-ns2-shippingservice
namespace: otel-demo-ns1
spec:
type: ExternalName
externalName: opentelemetry-demo-ns2-shippingservice.otel-demo-ns2.svc.cluster.local
ports:
- port: 8080
---
apiVersion: v1
kind: Service
metadata:
name: opentelemetry-demo-in-ns1-featureflagservice
namespace: otel-demo-ns2
spec:
type: ExternalName
externalName: opentelemetry-demo-ns1-featureflagservice.otel-demo-ns1.svc.cluster.local
ports:
- name: grpc
port: 50053
- name: http
port: 8081
---
apiVersion: v1
kind: Service
metadata:
name: opentelemetry-demo-in-ns1-quoteservice
namespace: otel-demo-ns2
spec:
type: ExternalName
externalName: opentelemetry-demo-ns1-quoteservice.otel-demo-ns1.svc.cluster.local
ports:
- port: 8080
2 changes: 2 additions & 0 deletions kubernetes/local/dash0-one-ns.yq
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.otelDemo.helm |
.default.image.pullSecrets=[{"name": "regcred"}]
26 changes: 26 additions & 0 deletions kubernetes/local/deploy-two-namespaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -euo pipefail

cd -P -- "$(dirname -- "$0")"

./teardown.sh

sleep 5

yq --from-file ns1.yq ../../../dash0-configuration/demo/environments/aws/demo-eu-west-1-demo.yaml > ns1-values.yaml
yq --from-file ns2.yq ../../../dash0-configuration/demo/environments/aws/demo-eu-west-1-demo.yaml > ns2-values.yaml

helm install --namespace otel-demo-ns1 --create-namespace opentelemetry-demo-postgresql oci://registry-1.docker.io/bitnamicharts/postgresql --values postgres-values.yaml
helm install --namespace otel-demo-ns1 --create-namespace opentelemetry-demo-ns1 open-telemetry/opentelemetry-demo --values ns1-values.yaml
helm install --namespace otel-demo-ns2 --create-namespace opentelemetry-demo-ns2 open-telemetry/opentelemetry-demo --values ns2-values.yaml
kubectl apply -f cross-namespace-service-names.yaml
kubectl apply --namespace otel-demo-ns1 -f postgres-service-two-namespaces.yaml

kubectl cp ../../src/ffspostgres/init-scripts/10-ffs_schema.sql --namespace otel-demo-ns1 opentelemetry-demo-postgresql-0:/tmp/
kubectl cp ../../src/ffspostgres/init-scripts/20-ffs_data.sql --namespace otel-demo-ns1 opentelemetry-demo-postgresql-0:/tmp/
kubectl exec --namespace otel-demo-ns1 opentelemetry-demo-postgresql-0 -- psql postgresql://ffs:ffs@localhost/ffs -a -f /tmp/10-ffs_schema.sql
kubectl exec --namespace otel-demo-ns1 opentelemetry-demo-postgresql-0 -- psql postgresql://ffs:ffs@localhost/ffs -a -f /tmp/20-ffs_data.sql

kubectl port-forward --namespace otel-demo-ns1 service/opentelemetry-demo-ns1-frontendproxy 8080:8080

28 changes: 28 additions & 0 deletions kubernetes/local/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -euo pipefail

cd -P -- "$(dirname -- "$0")"

./teardown.sh

sleep 5

yq --from-file dash0-one-ns.yq ../../../dash0-configuration/demo/environments/aws/demo-eu-west-1-demo.yaml > dash0-values.yaml

helm install --namespace otel-demo-ns --create-namespace opentelemetry-demo-postgresql oci://registry-1.docker.io/bitnamicharts/postgresql --values postgres-values.yaml
helm install \
--namespace otel-demo-ns \
--create-namespace \
opentelemetry-demo \
open-telemetry/opentelemetry-demo \
--values dash0-values.yaml
kubectl apply --namespace otel-demo-ns -f postgres-service.yaml

kubectl cp ../../src/ffspostgres/init-scripts/10-ffs_schema.sql --namespace otel-demo-ns opentelemetry-demo-postgresql-0:/tmp/
kubectl cp ../../src/ffspostgres/init-scripts/20-ffs_data.sql --namespace otel-demo-ns opentelemetry-demo-postgresql-0:/tmp/
kubectl exec --namespace otel-demo-ns opentelemetry-demo-postgresql-0 -- psql postgresql://ffs:ffs@localhost/ffs -a -f /tmp/10-ffs_schema.sql
kubectl exec --namespace otel-demo-ns opentelemetry-demo-postgresql-0 -- psql postgresql://ffs:ffs@localhost/ffs -a -f /tmp/20-ffs_data.sql

kubectl port-forward --namespace otel-demo-ns service/opentelemetry-demo-frontendproxy 8080:8080

29 changes: 29 additions & 0 deletions kubernetes/local/ns1.yq
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.otelDemo.helm |
.default.image.pullSecrets=[{"name": "regcred"}] |
del(.default.envOverrides) |
.components.ffsPostgres.enabled=false |
.components.accountingService.enabled=true |
.components.adService.enabled=true |
.components.cartService.enabled=true |
.components.checkoutService.enabled=true |
.components.currencyService.enabled=true |
.components.emailService.enabled=true |
.components.cartService.enabled=true |
.components.checkoutService.enabled=true |
.components.checkoutService.envOverrides=[
{ "name": "FEATURE_FLAG_GRPC_SERVICE_ADDR", "value": "opentelemetry-demo-featureflagservice:50053" }, { "name": "EMAIL_SERVICE_ADDR", "value": "http://opentelemetry-demo-in-ns2-emailservice:8080" }, { "name": "PAYMENT_SERVICE_ADDR", "value": "opentelemetry-demo-in-ns2-paymentservice:8080" }, {"name": "SHIPPING_SERVICE_ADDR", "value": "opentelemetry-demo-in-ns2-shippingservice:8080" } ] |
.components.currencyService.enabled=true |
.components.emailService.enabled=false |
.components.featureflagService.enabled=true |
.components.frauddetectionService.enabled=true |
.components.frontend.enabled=true |
.components.frontend.envOverrides=[{ "name": "SHIPPING_SERVICE_ADDR", "value": "opentelemetry-demo-in-ns2-shippingservice:8080" } ] |
.components.frontendProxy.enabled=true |
.components.kafka.enabled=true |
.components.loadgenerator.enabled=true |
.components.paymentService.enabled=false |
.components.productCatalogService.enabled=true |
.components.quoteService.enabled=true |
.components.recommendationService.enabled=true |
.components.redis.enabled=true |
.components.shippingService.enabled=false
34 changes: 34 additions & 0 deletions kubernetes/local/ns2.yq
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.otelDemo.helm |
del(.prometheus) |
.default.image.pullSecrets=[{"name": "regcred"}] |
del(.default.envOverrides) |
.components.ffsPostgres.enabled=false |
.components.accountingService.enabled=false |
.components.adService.enabled=false |
.components.cartService.enabled=false |
.components.checkoutService.enabled=false |
.components.currencyService.enabled=false |
.components.emailService.enabled=false |
.components.cartService.enabled=false |
.components.checkoutService.enabled=false |
.components.currencyService.enabled=false |
.components.emailService.enabled=true |
.components.featureflagService.enabled=false |
.components.frauddetectionService.enabled=false |
.components.frontend.enabled=false |
.components.frontendProxy.enabled=false |
.components.kafka.enabled=false |
.components.loadgenerator.enabled=false |
.components.paymentService.enabled=true |
.components.paymentService.envOverrides=[{ "name": "FEATURE_FLAG_GRPC_SERVICE_ADDR", "value": "opentelemetry-demo-in-ns1-featureflagservice:50053" } ] |
.components.productCatalogService.enabled=false |
.components.quoteService.enabled=false |
.components.recommendationService.enabled=false |
.components.redis.enabled=false |
.components.shippingService.enabled=true |
.components.shippingService.envOverrides=[{ "name": "FEATURE_FLAG_GRPC_SERVICE_ADDR", "value": "opentelemetry-demo-in-ns1-featureflagservice:50053" }, { "name": "QUOTE_SERVICE_ADDR", "value": "http://opentelemetry-demo-in-ns1-quoteservice:8080" }] |
del(.grafana) |
.jaeger.enabled=false |
.prometheus.enabled=false |
.grafana.enabled=false

15 changes: 15 additions & 0 deletions kubernetes/local/postgres-service-two-namespaces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: opentelemetry-demo-ns1-ffspostgres
spec:
ports:
- name: tcp-postgresql
port: 5432
protocol: TCP
targetPort: tcp-postgresql
selector:
app.kubernetes.io/component: primary
app.kubernetes.io/instance: opentelemetry-demo-postgresql
app.kubernetes.io/name: postgresql
type: ClusterIP
15 changes: 15 additions & 0 deletions kubernetes/local/postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: opentelemetry-demo-ffspostgres
spec:
ports:
- name: tcp-postgresql
port: 5432
protocol: TCP
targetPort: tcp-postgresql
selector:
app.kubernetes.io/component: primary
app.kubernetes.io/instance: opentelemetry-demo-postgresql
app.kubernetes.io/name: postgresql
type: ClusterIP
6 changes: 6 additions & 0 deletions kubernetes/local/postgres-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
global:
postgresql:
auth:
username: "ffs"
password: "ffs"
database: "ffs"
21 changes: 21 additions & 0 deletions kubernetes/local/teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -euo pipefail

cd -P -- "$(dirname -- "$0")"

pwd

# tear down things installed by deploy.sh
helm uninstall --namespace otel-demo-ns --ignore-not-found opentelemetry-demo-postgresql
helm uninstall --namespace otel-demo-ns --ignore-not-found opentelemetry-demo
kubectl delete --namespace otel-demo-ns --ignore-not-found -f postgres-service.yaml
kubectl delete --namespace otel-demo-ns --ignore-not-found -f postgres-service-two-namespaces.yaml

# tear down things installed by deploy-two-namespaces.sh
helm uninstall --namespace otel-demo-ns1 --ignore-not-found opentelemetry-demo-ns1
helm uninstall --namespace otel-demo-ns2 --ignore-not-found opentelemetry-demo-ns2
helm uninstall --namespace otel-demo-ns1 --ignore-not-found opentelemetry-demo-postgresql
kubectl delete --namespace otel-demo-ns1 --ignore-not-found -f postgres-service.yaml
kubectl delete --ignore-not-found -f cross-namespace-service-names.yaml

0 comments on commit fdaa0e6

Please sign in to comment.