Rest Call to Kong container by Pod name

I want to call Kong Container of the Kong Pod from our service pods in the same Kubernetes Cluster
I want to pass the different data to Kong Pods.
But My request is fail.
How can I call each kong pods?

First of all, I changed the Kong Pod Type to StatefulSet.
Kong Pod succefully running with StatfulSet.

Second, I request with kong-proxy service, data is normally transferred to kong container.

curl -k https: //kong-proxy.namespace/service

Third, when I specifying a kong pod, data is not transmitted to the kong container.

curl -k https: //kong-0.kong-proxy.namespace/service
Error Log: curl: (6) Could not resolve host: kong-0.kong-proxy.namespace; Unknown error

For reference

kong-proxy NodePort 10.5.225.114 80: 80 / TCP, 443: 443 / TCP 0,443 port.

kong-0 2/2 Running 2 19h

< Env >

  • Currently, Redis and Kafka are not considered.
  • kong:1.4.2
  • kong-ingress-controller:0.6.0
  • Baremetal
  • Kubernetes

When you are directly trying to reach the pod and not through svc, you will need to use the port exposed on the container. In this case, assuming that you have only one container running in your kong pod, check the port on pod on which the container is listening.

Thank you for your help

I use 4 port in kong pod and I checked listening in the kong pod

apiVersion: v1
kind: Service
metadata:
  labels:
    app: kong
  name: kong-proxy
  namespace: cos
spec:
  clusterIP: 10.7.83.159
  externalTrafficPolicy: Local
  ipFamily: IPv4
  ports:
  - name: kong-proxy
    nodePort: 80
    port: 80
    protocol: TCP
    targetPort: 8000
  - name: kong-proxy-tls
    nodePort: 443
    port: 443
    protocol: TCP
    targetPort: 8443
  selector:
    app: kong
    component: app
    release: kong
  type: NodePort


> kubectl exec -it kong-0 sh -c kong
/ # netstat -lntp
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:9542            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:8443            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:8444            0.0.0.0:*               LISTEN      -
tcp        0      0 :::10254                :::*                    LISTEN      -

How can I use direct request address to kong pod?
Can I change like this?

> curl -k https://kong-0.namespace:8443/service

Can you confirm whether your curl -k https: //kong-proxy.namespace/service is working or not?

Based on your yaml, it looks like your kong svc is running in “cos” namespace. In that case, you will have to use something like curl -k https://kong-proxy.cos.svc.cluster.local:8001/services/ (Refer to https://github.com/kubernetes/dns/blob/master/docs/specification.md, https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/ for the DNS name in your environment)

Here 8001 is kong’s admin port which should be exposed as target port too

Thank you for your help

I wnat to send request StatefulSet Kong Pod with kong Pod DNS like “kong-{0…N-1}.kong-proxy.namespace”
refer : “StatefulSets | Kubernetes

I can call my other services like “pod-0.service.namespace”
But I can not request kong pod with pod name like "“kong-0.kong-proxy.namespace”
I can call by “kong-proxy” service like “kong-proxy.namespace”.
My custom services pod has 1 container but kong pod has 2 containers, that is different

.
.
.
.
.
.
.

==> That is working, different namespace is my mistake

My kong admin port is 8444 also opened.
I also requested by 8444, but result was same and my custom plugin working with kong-proxy service

Pod dnsPolicy: ClusterFirst