2

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

I have 3 pods

  • cassandra
  • kong
  • apiindex

and 2 services(node ports)

  • apiindex (80/443/8080 ports are open)
  • kong-proxy(8000/8001/8443)

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?

4

1 回答 1

3

您需要在 kubernetes https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/中使用服务的完全限定名称(FQDN)

所以而不是apiindex需要使用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/ '

于 2017-07-17T10:57:09.947 回答