Problem summary:
I have a k3s instance running on 192.168.23.231. Port 30001 is mapped to a REST API app I built. Port 31166 is mapped to Krakend. When I enter http://192.168.23.231:31166/datamanager/hello into my browser, I get an HTTP 500 error message stating "http://192.168.23.231 is currently unable to handle this request."
If I browse to http://192.168.23.231:30001/hello, I get "Hello World" as expected, so I know the REST API is running correctly. My expectation is the Krakend endpoint would return the same thing, but it does not.
Here is an excerpt from my krakend.json config file showing the end point configuration:
"endpoints": [
{
"endpoint": "/datamanager/hello",
"method": "GET",
"output_encoding": "string",
"extra_config": {},
"backend": [
{
"url_pattern": "/hello",
"encoding": "json",
"sd": "static",
"method": "GET",
"extra_config": {},
"host": [
"http://datamanager.my-test.svc.cluster.local:4567"
],
"disable_host_sanitize": false
}
]
},
Unless I'm mistaken, 192.168.23.231:31166/datamanager/hello
should be routed to datamanager.my-test.svc.cluster.local:4567/hello
by Krakend.
I have tried to google around, but the results did not seem to align closely with my issue.
The 500 error is the default status code when KrakenD is unable to process your backend response.
In the KrakenD configuration you are showing, we can see that you are telling KrakenD that the response from your backend (the encoding
) is a JSON object, but instead your backend returns a string Hello World
, which is not a JSON.
The KrakenD logs will show something like:
Error #01: invalid character 'H' looking for beginning of value
And that H
is from H
ello World.
If you'd like to consume strings instead of json use string
as the value of encoding
. If you want the response as is from your backend, use no-op
both in encoding
and output_encoding