Skip to content

Commit

Permalink
[dash0] chore: improve local k8s deployment
Browse files Browse the repository at this point in the history
* remove deployment to two namespaces, we can resurrect that if we pick
  up
  https://linear.app/dash0/issue/ENG-951/make-the-deployment-topology-more-interesting
  again
* rename namespace from otel-demo-ns to otel-demo
* extract processing of values file into separate script
* add support for sending data to a configurable ingress URL via
  OTEL_EXPORTER_OTLP_ENDPOINT
* add support for using a custom values.yaml file via VALUES_YAML
  • Loading branch information
basti1302 committed Mar 14, 2024
1 parent cc29ca5 commit 838789a
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 224 deletions.
4 changes: 1 addition & 3 deletions kubernetes/local/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
dash0-values.yaml
ns1-values.yaml
ns2-values.yaml
dash0-otel-demo-local-k8s-values.yaml
34 changes: 34 additions & 0 deletions kubernetes/local/create-values-yaml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -euo pipefail

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

source utils

if [[ -n ${VALUES_YAML:-} ]]; then
echo "Using custom values yaml file: $VALUES_YAML"
cp $VALUES_YAML dash0-otel-demo-local-k8s-values.yaml
else
echo "Creating dash0-otel-demo-local-k8s-values.yaml based on:"
echo "- $dash0_configuration_dir/demo/environments/aws/demo-eu-west-1-demo.yaml and"
echo "- $dash0_configuration_dir/demo/values.yaml"
echo "Set VALUES_YAML to use a custom values file."
echo
yq \
". *= load(\"$dash0_configuration_dir/demo/environments/aws/demo-eu-west-1-demo.yaml\")" \
$dash0_configuration_dir/demo/values.yaml | \
yq --from-file dash0-otel-demo-local-k8s.yq > \
dash0-otel-demo-local-k8s-values.yaml

if [[ -n ${OTEL_EXPORTER_OTLP_ENDPOINT:-} ]]; then
echo "Using non-default reporting endpoint from environment variable"
echo "OTEL_EXPORTER_OTLP_ENDPOINT: $OTEL_EXPORTER_OTLP_ENDPOINT"
echo
yq -i ".opentelemetry-collector.config.exporters.otlp/dash0-dev.endpoint=\"$OTEL_EXPORTER_OTLP_ENDPOINT\" | del(.opentelemetry-collector.config.exporters.otlp/dash0-dev.auth) " dash0-otel-demo-local-k8s-values.yaml
else
echo "Reporting to $(yq '.opentelemetry-collector.config.exporters["otlp/dash0-dev"]'.endpoint dash0-otel-demo-local-k8s-values.yaml), set OTEL_EXPORTER_OTLP_ENDPOINT to report somewhere else."
echo
fi
fi

57 changes: 0 additions & 57 deletions kubernetes/local/cross-namespace-service-names.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.otelDemo.helm |
.default.image.pullSecrets=[{"name": "regcred"}] |
del(.opentelemetry-collector.config.exporters.otlp/dash0-prod) |
del(.opentelemetry-collector.config.exporters.otlp/dash0-prod-pen-testing) |
del(.opentelemetry-collector.config.service.pipelines.*.exporters.[] | select(. == "otlp/dash0-prod*") ) |
.opentelemetry-collector.config.processors.resource.attributes[] |= select(.key == "cloud.account.id").value |= "012345678901"
47 changes: 0 additions & 47 deletions kubernetes/local/deploy-two-namespaces.sh

This file was deleted.

28 changes: 12 additions & 16 deletions kubernetes/local/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,31 @@ git_pull_dash0_configuration
trap switch_back_to_original_context EXIT
switch_to_local_context

refresh_image_pull_secret otel-demo-ns
refresh_image_pull_secret otel-demo

./teardown.sh no-context-switch

sleep 5

yq \
". *= load(\"$dash0_configuration_dir/demo/environments/aws/demo-eu-west-1-demo.yaml\")" \
$dash0_configuration_dir/demo/values.yaml | \
yq --from-file dash0-one-ns.yq > \
dash0-values.yaml
./create-values-yaml.sh $dash0_configuration_dir

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 --create-namespace opentelemetry-demo-postgresql oci://registry-1.docker.io/bitnamicharts/postgresql --values postgres-values.yaml
helm install \
--namespace otel-demo-ns \
--namespace otel-demo \
--create-namespace \
opentelemetry-demo \
open-telemetry/opentelemetry-demo \
--values dash0-values.yaml
kubectl apply --namespace otel-demo-ns -f postgres-service.yaml
--values dash0-otel-demo-local-k8s-values.yaml
kubectl apply --namespace otel-demo -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 cp ../../src/ffspostgres/init-scripts/10-ffs_schema.sql --namespace otel-demo opentelemetry-demo-postgresql-0:/tmp/
kubectl cp ../../src/ffspostgres/init-scripts/20-ffs_data.sql --namespace otel-demo opentelemetry-demo-postgresql-0:/tmp/
kubectl exec --namespace otel-demo opentelemetry-demo-postgresql-0 -- psql postgresql://ffs:ffs@localhost/ffs -a -f /tmp/10-ffs_schema.sql
kubectl exec --namespace otel-demo opentelemetry-demo-postgresql-0 -- psql postgresql://ffs:ffs@localhost/ffs -a -f /tmp/20-ffs_data.sql

echo waiting for the frontend and frontendproxy pod to become ready
sleep 5
kubectl wait --namespace otel-demo-ns --for=condition=ready pod -l app.kubernetes.io/component=frontendproxy --timeout 10s
kubectl wait --namespace otel-demo-ns --for=condition=ready pod -l app.kubernetes.io/component=frontend --timeout 20s
kubectl wait --namespace otel-demo --for=condition=ready pod -l app.kubernetes.io/component=frontendproxy --timeout 10s
kubectl wait --namespace otel-demo --for=condition=ready pod -l app.kubernetes.io/component=frontend --timeout 20s
./port-forward.sh

32 changes: 0 additions & 32 deletions kubernetes/local/ns1.yq

This file was deleted.

36 changes: 0 additions & 36 deletions kubernetes/local/ns2.yq

This file was deleted.

6 changes: 0 additions & 6 deletions kubernetes/local/port-forward-two-ns.sh

This file was deleted.

2 changes: 1 addition & 1 deletion kubernetes/local/port-forward.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -euo pipefail

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

15 changes: 0 additions & 15 deletions kubernetes/local/postgres-service-two-namespaces.yaml

This file was deleted.

14 changes: 3 additions & 11 deletions kubernetes/local/teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ if [[ ${1:-} != "no-context-switch" ]]; then
fi

# 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
helm uninstall --namespace otel-demo --ignore-not-found opentelemetry-demo-postgresql
helm uninstall --namespace otel-demo --ignore-not-found opentelemetry-demo
kubectl delete --namespace otel-demo --ignore-not-found -f postgres-service.yaml

0 comments on commit 838789a

Please sign in to comment.