Reputation: 387
I've developed a KrakenD plugin that validates JWT token of incoming request. The plugin is intended for HTTP server and it has single dependency of version v5.2.1. Our DevOps engineers cloned official KrakenD CE and modified it and I need to integrate this JWT validator plugin into our KrakenD gateway.
My environment:
The plugin was built in other directory (for testing purposes) with KrakenD Builder 2.7.2 Docker image. In both directories KrakenD is the same version. It works with official KrakenD image (devopsfaith/krakend:2.7.2
) but not with modified one. The plugin was built with this command:
MSYS_NO_PATHCONV=1 docker run -it -v "$PWD:/app" -w /app krakend/builder:2.7.2 go build -buildmode=plugin -o jwt-validator.so
(MSYS_NO_PATHCONV=1
var is for Git Bash. It handles $PWD as Git Bash's location. I can't execute it without builder because -buildmode=plugin
is not supported for Windows)
Building plugin by non-Docker approach (linux-generic) raises another error:
$ MSYS_NO_PATHCONV=1 docker run -it -v "$PWD:/app" -w /app krakend/builder:2.7.2-linux-generic go build -buildmode=plugin -o jwt-validator.so .
...
plugin #0 (/etc/krakend/out/kt-jwt-validator.so): plugin.Open("/etc/krakend/out/kt-jwt-validator.so"): Error loading shared library libresolv.so.2: No such file or directory (needed by /etc/krakend/out/kt-jwt-validator.so)
When I try integrating plugin into modified KrakenD repository it throws debug messages describing that plugin couldn't be integrated because it was built with a different version of package internal/godebugs
and therefore it was disabled:
$ mv ../jwt-validator-plugin/jwt-validator.so .
$ docker-compose up
[+] Running 1/0
✔ Container krakend Created 0.0s
Attaching to krakend
krakend | Parsing configuration file: /etc/krakend/krakend.json
krakend | [KRAKEND] 2025/01/13 - 07:28:38.995 ▶ DEBUG [SERVICE: telemetry/logging] Improved logging started.
krakend | [KRAKEND] 2025/01/13 - 07:28:38.995 ▶ INFO Starting KrakenD v2.7.2
krakend | [KRAKEND] 2025/01/13 - 07:28:38.995 ▶ INFO Working directory is /etc/krakend
krakend | [KRAKEND] 2025/01/13 - 07:28:38.995 ▶ DEBUG [SERVICE: Plugin Loader] Starting loading process
krakend | [KRAKEND] 2025/01/13 - 07:28:39.343 ▶ DEBUG [SERVICE: Executor Plugin] plugin #0 (/etc/krakend/out/kt-jwt-validator.so): plugin.Open("/etc/krakend/out/kt-jwt-validator"): plugin was built with a different version of package internal/godebugs
krakend | [KRAKEND] 2025/01/13 - 07:28:39.345 ▶ DEBUG [SERVICE: Handler Plugin] plugin #0 (/etc/krakend/out/kt-jwt-validator.so): plugin.Open("/etc/krakend/out/kt-jwt-validator.so"): plugin was built with a different version of package internal/godebugs (previous failure)
krakend | [KRAKEND] 2025/01/13 - 07:28:39.349 ▶ DEBUG [SERVICE: Modifier Plugin] plugin #0 (/etc/krakend/out/kt-jwt-validator.so): plugin.Open("/etc/krakend/out/kt-jwt-validator.so"): plugin was built with a different version of package internal/godebugs (previous failure)
krakend | [KRAKEND] 2025/01/13 - 07:28:39.350 ▶ DEBUG [SERVICE: Plugin Loader] Loading process completed
Does KrakenD builder and KrakenD have different Go versions? Because there is no godebugs
dependency in my plugin's source code. I think it's in Go's runtime and it seems there are 2 different runtimes - one in builder's image and the other one in KrakenD. If so how can I
Upvotes: 1
Views: 57
Reputation: 187
As @alo commented above, KrakenD is built using its own builder, so it shouldn't happen. More info here: github.com/krakend/krakend-ce/blob/master/Makefile#L80-L81
Check and ensure that your Dockerfile is built FROM the same specific KrakenD version (maj.min.fix)?
Upvotes: 0