Valentin
Valentin

Reputation: 5488

Can't add internal API to KONG api gateway running on GKE

I'm running Kong API gateway on GKE and trying to add my own service.

I have 3 pods

and 2 services(node ports)

I'm trying to add apiindex api to API gateway using

curl -i -X POST http://kong-proxy:8001/apis -d 'name=test' -d 'uris=/' -d 'upstream_url=http://apiindex/'

But then http://kong-proxy:8000/ returns

503 {"message": "Service unavailable"}

It works fine when I add some public website inside curl -i -X POST http://kong-proxy:8001/apis -d 'name=test' -d 'uris=/' -d 'upstream_url=http://httpbin.org/'

curl http://apiindex/ returns 200 from kong pod.

Is it possible to add API using kong without exposing apiindex service?

Upvotes: 2

Views: 902

Answers (1)

Valentin
Valentin

Reputation: 5488

You need to use the fully qualified name of the service (FQDN) in kubernetes https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

So instead of apiindex need to use apiindex.default.svc.cluster.local

curl -i -X POST http://kong-proxy:8001/apis -d 'name=testapi' -d 'uris=/' -d 'upstream_url=http://apiindex.default.svc.cluster.local/'

Upvotes: 3

Related Questions