Skip to content

Commit

Permalink
Merge pull request #21 from TykTechnologies/split-otel-fix-manifest
Browse files Browse the repository at this point in the history
split out otel and fix manifest
  • Loading branch information
zalbiraw authored Dec 18, 2023
2 parents ce04b4b + 90128a7 commit 000e108
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 78 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ jobs:

- name: Copy Env Files
run: cp .env.example .env

- name: Build Go Plugin
run: make go-build

- name: Bundle Go Plugin
run: TYK_VERSION=v5.2.0 docker-compose run --rm --entrypoint "bundle/bundle-entrypoint.sh" tyk-gateway
run: DOCKER_USER=root make go-bundle

- name: Upload Bundle
uses: actions/upload-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea/*
tyk/middleware/bundles/*
tyk/bundle/manifest.json
**/.env
**/*.so
**/*.zip
Expand Down
38 changes: 31 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
#
###############################################################################

export TYK_VERSION := v5.2.2
export TYK_VERSION := v5.2.4

ifeq ($(origin DOCKER_USER), undefined)
DOCKER_USER := 1000
endif

# Default task: sets up development environment
install: up build
Expand All @@ -26,9 +30,15 @@ log: docker-gateway-log
# Brings up the project - Pro
up: docker-up bootstrap docker-status

# Brings up the project - Pro w/ oTel
up-otel: docker-up-otel bootstrap docker-status

# Brings up the project - OSS
up-oss: docker-up-oss bootstrap-oss docker-status

# Brings up the project - OSS w/ oTel
up-oss-otel: docker-up-oss-otel bootstrap-oss docker-status

# Brings down the project
down: docker-down docker-status

Expand Down Expand Up @@ -60,6 +70,21 @@ docker-gateway-log:
docker-up:
docker-compose up -d --remove-orphans tyk-dashboard tyk-gateway

# Bring docker containers up /w oTel
.PHONY: docker-up-otel
docker-up-otel:
docker-compose -f docker-compose.yml -f deployments/otel/docker-compose.yml up -d --remove-orphans tyk-dashboard tyk-gateway

# Bring docker containers up in OSS
.PHONY: docker-up-oss
docker-up-oss:
docker-compose -f docker-compose-oss.yml up -d --remove-orphans tyk-gateway

# Bring docker containers up in OSS /w oTel
.PHONY: docker-up-oss-otel
docker-up-oss-otel:
docker-compose -f docker-compose-oss.yml -f deployments/otel/docker-compose.yml up -d --remove-orphans tyk-gateway

# Bootstrap dashboard
.PHONY: bootstrap
bootstrap:
Expand Down Expand Up @@ -116,7 +141,9 @@ coverage:
# Builds production-ready Go plugin bundle as non-root user, using Tyk Bundler tool
.PHONY: go-bundle
go-bundle: go-build
docker-compose run --rm --user=1000 --entrypoint "bundle/bundle-entrypoint.sh" tyk-gateway
sed "s/replace_version/$(TYK_VERSION)/g" tyk/bundle/manifest-template.json | \
sed "s/replace_platform/amd64/g" > tyk/bundle/manifest.json
docker-compose run --rm --user=$(DOCKER_USER) --entrypoint "bundle/bundle-entrypoint.sh" tyk-gateway

# Cleans application files
.PHONY: go-clean
Expand All @@ -125,18 +152,15 @@ go-clean:
-rm -rf ./go/src/go.mod
-rm -rf ./go/src/go.sum
-rm -f ./tyk/middleware/CustomGoPlugin*.so
-rm -f ./tyk/bundle/CustomGoPlugin.so
-rm -f ./tyk/bundle/CustomGoPlugin*.so
-rm -f ./tyk/bundle/manifest.so
-rm -f ./tyk/bundle/bundle.zip

# Restarts the Tyk Gateway to instantly load new iterations of the Go plugin
.PHONY: restart-gateway
restart-gateway:
docker-compose restart tyk-gateway

.PHONY: docker-up-oss
docker-up-oss:
docker-compose -f docker-compose-oss.yml up -d

# Bootstrap dashboard
.PHONY: bootstrap-oss
bootstrap-oss:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ To get started, please review our documentation on [Open Telemetry Overview](htt

You can refer to our official documentation on [How to instrument Custom Go Plugins with OpenTelemetry](https://tyk.io/docs/product-stack/tyk-gateway/advanced-configurations/plugins/otel-plugins/).

To stand up, oTel example:
```shell
$ make up-otel build
```

To stand up, oTel example in OSS:
```shell
$ make up-oss-otel build
```

### Examples
- [Open Telemetry Instrumentation](plugins/otel-instrumentation/)

Expand Down
36 changes: 36 additions & 0 deletions deployments/otel/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.8'
services:

tyk-gateway:
depends_on:
- otel-jaeger-all-in-one
- otel-collector-gateway
environment:
- TYK_GW_OPENTELEMETRY_ENABLED=true
- TYK_GW_OPENTELEMETRY_EXPORTER=grpc
- TYK_GW_OPENTELEMETRY_ENDPOINT=otel-collector-gateway:4317

otel-jaeger-all-in-one:
image: jaegertracing/all-in-one:1.47
ports:
- "16686:16686"
- "14268"
- "14250"
networks:
- tyk

otel-collector-gateway:
image: otel/opentelemetry-collector:0.81.0
volumes:
- ./deployments/otel/confs/otel-collector.yml:/etc/otel-collector.yml
command: [ "--config=/etc/otel-collector.yml" ]
ports:
- "1888:1888" # pprof extension
- "13133:13133" # health_check extension
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP http receiver
- "55670:55679" # zpages extension
depends_on:
- otel-jaeger-all-in-one
networks:
- tyk
36 changes: 2 additions & 34 deletions docker-compose-oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@ version: '3.8'
services:

tyk-plugin-compiler:
image: tykio/tyk-plugin-compiler:${TYK_VERSION:-v5.2.0}
image: tykio/tyk-plugin-compiler:${TYK_VERSION:-v5.2.4}
volumes:
- ./go/src:/plugin-source

tyk-gateway:
image: tykio/tyk-gateway:${TYK_VERSION:-v5.2.0-amd64}
depends_on:
- otel-jaeger-all-in-one
- otel-collector-gateway
image: tykio/tyk-gateway:${TYK_VERSION:-v5.2.4-amd64}
ports:
- "8080:8080"
volumes:
- ./tyk/bundle:/opt/tyk-gateway/bundle
- ./tyk/middleware:/opt/tyk-gateway/middleware
environment:
- TYK_GW_OPENTELEMETRY_ENABLED=true
- TYK_GW_OPENTELEMETRY_EXPORTER=grpc
- TYK_GW_OPENTELEMETRY_ENDPOINT=otel-collector-gateway:4317
env_file:
- ./tyk/confs/tyk-oss.env
networks:
Expand All @@ -43,31 +36,6 @@ services:
- redis-data:/data
networks:
- tyk

otel-jaeger-all-in-one:
image: jaegertracing/all-in-one:1.47
ports:
- "16686:16686"
- "14268"
- "14250"
networks:
- tyk

otel-collector-gateway:
image: otel/opentelemetry-collector:0.81.0
volumes:
- ./deployments/otel/confs/otel-collector.yml:/etc/otel-collector.yml
command: [ "--config=/etc/otel-collector.yml" ]
ports:
- "1888:1888" # pprof extension
- "13133:13133" # health_check extension
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP http receiver
- "55670:55679" # zpages extension
depends_on:
- otel-jaeger-all-in-one
networks:
- tyk

volumes:
mongo-data:
Expand Down
32 changes: 0 additions & 32 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@ services:

tyk-gateway:
image: tykio/tyk-gateway:${TYK_VERSION}
depends_on:
- otel-jaeger-all-in-one
- otel-collector-gateway
platform: linux/amd64
ports:
- "8080:8080"
volumes:
- ./tyk/bundle:/opt/tyk-gateway/bundle
- ./tyk/middleware:/opt/tyk-gateway/middleware
environment:
- TYK_GW_OPENTELEMETRY_ENABLED=true
- TYK_GW_OPENTELEMETRY_EXPORTER=grpc
- TYK_GW_OPENTELEMETRY_ENDPOINT=otel-collector-gateway:4317
env_file:
- ./tyk/confs/tyk.env
networks:
Expand Down Expand Up @@ -70,31 +63,6 @@ services:
- redis-data:/data
networks:
- tyk

otel-jaeger-all-in-one:
image: jaegertracing/all-in-one:1.47
ports:
- "16686:16686"
- "14268"
- "14250"
networks:
- tyk

otel-collector-gateway:
image: otel/opentelemetry-collector:0.81.0
volumes:
- ./deployments/otel/confs/otel-collector.yml:/etc/otel-collector.yml
command: [ "--config=/etc/otel-collector.yml" ]
ports:
- "1888:1888" # pprof extension
- "13133:13133" # health_check extension
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP http receiver
- "55670:55679" # zpages extension
depends_on:
- otel-jaeger-all-in-one
networks:
- tyk

volumes:
mongo-data:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"file_list": [
"CustomGoPlugin_v5.2.0_linux_amd64.so"
"CustomGoPlugin_replace_version_linux_replace_platform.so"
],
"custom_middleware": {
"pre": [
Expand Down

0 comments on commit 000e108

Please sign in to comment.