# Rest Call to Kong container by Pod name

**URL:** <https://discuss.konghq.com/t/rest-call-to-kong-container-by-pod-name/5987>\
**Category:** General\
**Created:** [April 10, 2020, 1:53am UTC](https://discuss.konghq.com/t/rest-call-to-kong-container-by-pod-name/5987 "2020-04-10T01:53:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HYUN\_SUK\_JUNG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hyun_suk_jung/32/1122_2.png) [@HYUN\_SUK\_JUNG](https://discuss.konghq.com/u/HYUN_SUK_JUNG)\
**Post date:** [April 10, 2020, 1:53am UTC](https://discuss.konghq.com/t/rest-call-to-kong-container-by-pod-name/5987/1 "2020-04-10T01:53:43Z")

</div>

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](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](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

---

<div class="post-metadata">

**Author:** ![smuthunoori](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/smuthunoori/32/1831_2.png) [@smuthunoori](https://discuss.konghq.com/u/smuthunoori)\
**Post date:** [April 10, 2020, 3:34am UTC](https://discuss.konghq.com/t/rest-call-to-kong-container-by-pod-name/5987/2 "2020-04-10T03:34:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![HYUN\_SUK\_JUNG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hyun_suk_jung/32/1122_2.png) [@HYUN\_SUK\_JUNG](https://discuss.konghq.com/u/HYUN_SUK_JUNG)\
**Post date:** [April 10, 2020, 4:09am UTC](https://discuss.konghq.com/t/rest-call-to-kong-container-by-pod-name/5987/3 "2020-04-10T04:09:52Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![smuthunoori](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/smuthunoori/32/1831_2.png) [@smuthunoori](https://discuss.konghq.com/u/smuthunoori)\
**Post date:** [April 10, 2020, 5:02pm UTC](https://discuss.konghq.com/t/rest-call-to-kong-container-by-pod-name/5987/4 "2020-04-10T17:02:54Z")

</div>

Can you confirm whether your curl -k https: [//kong-proxy.namespace/service](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/](https://kong-proxy.cos.svc.cluster.local:8001/services/) (Refer to [https://github.com/kubernetes/dns/blob/master/docs/specification.md](https://github.com/kubernetes/dns/blob/master/docs/specification.md), [https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/](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

---

<div class="post-metadata">

**Author:** ![HYUN\_SUK\_JUNG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hyun_suk_jung/32/1122_2.png) [@HYUN\_SUK\_JUNG](https://discuss.konghq.com/u/HYUN_SUK_JUNG)\
**Post date:** [April 13, 2020, 12:40am UTC](https://discuss.konghq.com/t/rest-call-to-kong-container-by-pod-name/5987/5 "2020-04-13T00:40:50Z")

</div>

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](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/)”

**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

.  
.  
.  
.  
.  
.  
.

> [@smuthunoori](#):
>
> Can you confirm whether your curl -k https: [//kong-proxy.namespace/service](https://kong-proxy.namespace/service) is working or not?

==\> 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
