Skip to content

Commit

Permalink
Add tempo (#67)
Browse files Browse the repository at this point in the history
* fix down command

* Add tempo
  • Loading branch information
zalbiraw authored Nov 5, 2024
1 parent f4daf88 commit 3a4d53c
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 94 deletions.
18 changes: 0 additions & 18 deletions src/deployments/jaeger/health-svc-template.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions src/deployments/jaeger/ingress.sh

This file was deleted.

15 changes: 15 additions & 0 deletions src/deployments/jaeger/jaeger-svc-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: tyk-jaeger
namespace: replace_namespace
spec:
type: ClusterIP
selector:
app.kubernetes.io/instance: tyk-tempo
app.kubernetes.io/name: tempo
ports:
- name: tempo-query-jaeger-ui
port: 16686
protocol: TCP
targetPort: 16686
19 changes: 0 additions & 19 deletions src/deployments/jaeger/jaeger.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions src/deployments/jaeger/load-balancer.sh

This file was deleted.

4 changes: 1 addition & 3 deletions src/deployments/jaeger/main.safe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ if [ -z "$jaegerRegistered" ]; then
jaegerReleaseName="tyk-jaeger";
jaegerDeploymentPath="src/deployments/jaeger";

source "src/deployments/cert-manager/main.safe.sh";
source "$jaegerDeploymentPath/load-balancer.sh";
source "$jaegerDeploymentPath/ingress.sh";
source "src/deployments/tempo/main.safe.sh";
source "$jaegerDeploymentPath/main.sh";
fi
46 changes: 2 additions & 44 deletions src/deployments/jaeger/main.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,8 @@
logger "$INFO" "installing $jaegerReleaseName in $namespace namespace...";

setVerbose;
helm upgrade "$jaegerReleaseName" jaegertracing/jaeger-operator --version v2.46.2 \
--install \
--namespace "$namespace" \
"${helmFlags[@]}" > /dev/null;

sed "s/replace_service_type/$JAEGER_SERVICE_TYPE/g" "$jaegerDeploymentPath/jaeger.yaml" | \
sed "s/replace_enabled_ingress/$JAEGER_INGRESS_ENABLED/g" | \
sed "s/replace_ingress_className/$INGRESS_CLASSNAME/g" | \
sed "s/replace_namespace/$namespace/g" "$jaegerDeploymentPath/jaeger-svc-template.yaml" | \
kubectl apply --namespace "$namespace" -f - > /dev/null;

helm upgrade tyk-otel-collector open-telemetry/opentelemetry-collector --version 0.99.0 \
--install \
--set "mode=deployment" \
--set "image.repository=otel/opentelemetry-collector-k8s" \
--set "config.receivers.otlp.protocols.http.endpoint=0.0.0.0:4318" \
--set "config.receivers.otlp.protocols.grpc.endpoint=0.0.0.0:4317" \
--set "config.exporters.otlphttp.endpoint=$jaegerReleaseName-collector.$namespace.svc:14250" \
--set "config.exporters.otlphttp.tls.insecure=true" \
--set "config.extensions.pprof.endpoint=\:1888" \
--set "config.extensions.zpages.endpoint=\:55679" \
--set "config.service.extensions[0]=pprof" \
--set "config.service.extensions[1]=zpages" \
--set "config.service.extensions[2]=health_check" \
--set "config.service.pipelines.traces.receivers[0]=otlp" \
--set "config.service.pipelines.traces.processors[0]=batch" \
--set "config.service.pipelines.traces.exporters[0]=otlphttp" \
--namespace "$namespace" \
"${helmFlags[@]}" > /dev/null;
unsetVerbose;

args=(--set-string "tyk-gateway.gateway.extraEnvs[$gatewayExtraEnvsCtr].name=TYK_GW_OPENTELEMETRY_ENABLED" \
--set-string "tyk-gateway.gateway.extraEnvs[$gatewayExtraEnvsCtr].value=true" \
--set-string "tyk-gateway.gateway.extraEnvs[$(($gatewayExtraEnvsCtr + 1))].name=TYK_GW_OPENTELEMETRY_EXPORTER" \
--set-string "tyk-gateway.gateway.extraEnvs[$(($gatewayExtraEnvsCtr + 1))].value=grpc" \
--set-string "tyk-gateway.gateway.extraEnvs[$(($gatewayExtraEnvsCtr + 2))].name=TYK_GW_OPENTELEMETRY_ENDPOINT" \
--set-string "tyk-gateway.gateway.extraEnvs[$(($gatewayExtraEnvsCtr + 2))].value=tyk-otel-collector-opentelemetry-collector:4317");

gatewayExtraEnvsCtr=$((gatewayExtraEnvsCtr + 3));

addDeploymentArgs "${args[@]}";

sed "s/replace_release_name/$jaegerReleaseName/g" "$jaegerDeploymentPath/health-svc-template.yaml" | \
sed "s/replace_namespace/$namespace/g" | \
kubectl apply --namespace "$namespace" -f - > /dev/null;

addService "$jaegerReleaseName-query";
addService "$jaegerReleaseName-health";
addService "tyk-jaeger";
33 changes: 33 additions & 0 deletions src/deployments/opentelemetry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## OpenTelemetry
Deploys the OpenTelemetry collector using the
`open-telemetryopentelemetry-collector` chart version `0.108.1` and configures
the Tyk deployment to send telemetry data to Grafana Tempo through the OpenTelemetry
collector.

### Example
```
./up.sh --deployments opentelemetry tyk-stack
```

### Support
| Item | Status |
|:------------:|:------------------:|
| OpenShift | :white_check_mark: |
| ARM | :white_check_mark: |
| CI Tests | N/A |
| Postman Test | N/A |
| SSL | N/A |

### Supported Service Types with `--expose` flag
| Item | Status |
|:-------------:|:------:|
| Port Forward | N/A |
| Ingress | N/A |
| Load Balancer | N/A |

| Icon | Description |
|:------------------:|:-------------------------:|
| :white_check_mark: | Supported and tested |
| :warning: | Not tested |
| :x: | Not supported |
| :no_entry: | Not supported by the tool |
9 changes: 9 additions & 0 deletions src/deployments/opentelemetry/main.safe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if [ -z "$opentelemetryRegistered" ]; then
opentelemetryRegistered=true;

opentelemetrReleaseName="tyk-opentelemetry";
opentelemetryDeploymentPath="src/deployments/opentelemetry";

source "src/deployments/cert-manager/main.safe.sh";
source "$opentelemetryDeploymentPath/main.sh";
fi
35 changes: 35 additions & 0 deletions src/deployments/opentelemetry/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
logger "$INFO" "installing $opentelemetrReleaseName in $namespace namespace...";

setVerbose;
helm upgrade tyk-otel-collector open-telemetry/opentelemetry-collector --version 0.108.1 \
--install \
--set "mode=deployment" \
--set "image.repository=otel/opentelemetry-collector-contrib" \
--set "config.receivers.otlp.protocols.http.endpoint=0.0.0.0:4318" \
--set "config.receivers.otlp.protocols.grpc.endpoint=0.0.0.0:4317" \
--set "config.processors.transform.error_mode=ignore" \
--set "config.processors.transform.metric_statements[0].context=datapoint" \
--set "config.processors.transform.metric_statements[0].statements[0]=replace_all_patterns(attributes\, \"value\"\, \"[^a-zA-Z0-9]\"\, \"_\")" \
--set "config.exporters.otlp/tempo.endpoint=$tempoReleaseName.$namespace.svc:4317" \
--set "config.exporters.otlp/tempo.tls.insecure=true" \
--set "config.extensions.pprof.endpoint=\:1888" \
--set "config.extensions.zpages.endpoint=\:55679" \
--set "config.service.extensions[0]=pprof" \
--set "config.service.extensions[1]=zpages" \
--set "config.service.extensions[2]=health_check" \
--set "config.service.pipelines.traces.receivers[0]=otlp" \
--set "config.service.pipelines.traces.processors[0]=batch" \
--set "config.service.pipelines.traces.exporters[0]=otlp/tempo" \
--namespace "$namespace" \
"${helmFlags[@]}" > /dev/null;
unsetVerbose;

args=(--set-string "tyk-gateway.gateway.extraEnvs[$gatewayExtraEnvsCtr].name=TYK_GW_OPENTELEMETRY_ENABLED" \
--set-string "tyk-gateway.gateway.extraEnvs[$gatewayExtraEnvsCtr].value=true" \
--set-string "tyk-gateway.gateway.extraEnvs[$(($gatewayExtraEnvsCtr + 1))].name=TYK_GW_OPENTELEMETRY_EXPORTER" \
--set-string "tyk-gateway.gateway.extraEnvs[$(($gatewayExtraEnvsCtr + 1))].value=grpc" \
--set-string "tyk-gateway.gateway.extraEnvs[$(($gatewayExtraEnvsCtr + 2))].name=TYK_GW_OPENTELEMETRY_ENDPOINT" \
--set-string "tyk-gateway.gateway.extraEnvs[$(($gatewayExtraEnvsCtr + 2))].value=tyk-otel-collector-opentelemetry-collector:4317");

gatewayExtraEnvsCtr=$((gatewayExtraEnvsCtr + 3));
addDeploymentArgs "${args[@]}";
5 changes: 5 additions & 0 deletions src/deployments/prometheus-grafana/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ helm upgrade "$grafanaReleaseName" grafana/grafana --version 8.3.6 \
--set "datasources.datasources\.yaml.datasources[0].url=http://$prometheusReleaseName-server:$PROMETHEUS_SERVICE_PORT" \
--set "datasources.datasources\.yaml.datasources[0].access=proxy" \
--set "datasources.datasources\.yaml.datasources[0].isDefault=true" \
--set "datasources.datasources\.yaml.datasources[1].name=Tempo" \
--set "datasources.datasources\.yaml.datasources[1].type=tempo" \
--set "datasources.datasources\.yaml.datasources[1].url=http://$tempoReleaseName:3100" \
--set "datasources.datasources\.yaml.datasources[1].access=proxy" \
--set "datasources.datasources\.yaml.datasources[1].isDefault=false" \
--set "dashboardProviders.dashboardproviders\.yaml.apiVersion=1" \
--set "dashboardProviders.dashboardproviders\.yaml.providers[0].name=Tyk" \
--set "dashboardProviders.dashboardproviders\.yaml.providers[0].orgId=1" \
Expand Down
30 changes: 30 additions & 0 deletions src/deployments/tempo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Tempo
Deploys the Tempo using the `grafana/tempo` chart version `v1.10.3`.

### Example
```
./up.sh --deployments tempo tyk-stack
```

### Support
| Item | Status |
|:------------:|:------------------:|
| OpenShift | :white_check_mark: |
| ARM | :white_check_mark: |
| CI Tests | :white_check_mark: |
| Postman Test | :white_check_mark: |
| SSL | :no_entry: |

### Supported Service Types with `--expose` flag
| Item | Status |
|:-------------:|:------------------:|
| Port Forward | :white_check_mark: |
| Ingress | :white_check_mark: |
| Load Balancer | :white_check_mark: |

| Icon | Description |
|:------------------:|:-------------------------:|
| :white_check_mark: | Supported and tested |
| :warning: | Not tested |
| :x: | Not supported |
| :no_entry: | Not supported by the tool |
10 changes: 10 additions & 0 deletions src/deployments/tempo/main.safe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if [ -z "$tempoRegistered" ]; then
tempoRegistered=true;

tempoReleaseName="tyk-tempo";
tempoDeploymentPath="src/deployments/tempo";

source "src/deployments/opentelemetry/main.safe.sh";
source "src/deployments/prometheus-grafana/main.safe.sh";
source "$tempoDeploymentPath/main.sh";
fi
9 changes: 9 additions & 0 deletions src/deployments/tempo/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
logger "$INFO" "installing $tempoReleaseName in $namespace namespace...";

setVerbose;
helm upgrade "$tempoReleaseName" grafana/tempo --version v1.10.3 \
--install \
--namespace "$namespace" \
--set "tempoQuery.enabled=true" \
"${helmFlags[@]}" > /dev/null;
unsetVerbose;
4 changes: 2 additions & 2 deletions src/helpers/down/crds.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
set +e;
policies=$(kubectl get tykpolicies --namespace "$namespace" 2> /dev/null | awk '{print $1}' | tail -n +2 | tr '\n' ' ');
apis=$(kubectl get tykapis --namespace "$namespace" 2> /dev/null | awk '{print $1}' | tail -n +2 | tr '\n' ' ');
oasapis=$(kubectl get tykoasapis --namespace "$namespace" 2> /dev/null | awk '{print $1}' | tail -n +2 | tr '\n' ' ');
oasapis=$(kubectl get tykoas --namespace "$namespace" 2> /dev/null | awk '{print $1}' | tail -n +2 | tr '\n' ' ');
supergraphs=$(kubectl get supergraphs --namespace "$namespace" 2> /dev/null | awk '{print $1}' | tail -n +2 | tr '\n' ' ');
subgraphs=$(kubectl get subgraphs --namespace "$namespace" 2> /dev/null | awk '{print $1}' | tail -n +2 | tr '\n' ' ');

kubectl delete --namespace "$namespace" tykpolicies $policies &> /dev/null;
kubectl delete --namespace "$namespace" tykapis $apis &> /dev/null;
kubectl delete --namespace "$namespace" tykoasapis $oasapis &> /dev/null;
kubectl delete --namespace "$namespace" tykoas $oasapis &> /dev/null;
kubectl delete --namespace "$namespace" supergraphs $supergraphs &> /dev/null;
kubectl delete --namespace "$namespace" subgraphs $subgraphs &> /dev/null;
set -e;

0 comments on commit 3a4d53c

Please sign in to comment.