Home > OS >  how to communicate with daemonset pod from another pod in another node?
how to communicate with daemonset pod from another pod in another node?

Time:12-27

I have a daemonset configuration that runs on all nodes. every pod listens on port 34567. I want from other pod on different node to communicate with this pod. how can I achieve that?

CodePudding user response:

Find the target Pod's IP address as shown below

controlplane $ k get po -o wide
NAME                                       READY   STATUS    RESTARTS   AGE     IP            NODE           NOMINATED NODE   READINESS GATES
coredns-fb8b8dccf-42pq8                    1/1     Running   1          5m43s   10.88.0.4     node01         <none>           <none>
coredns-fb8b8dccf-f9n5x                    1/1     Running   1          5m43s   10.88.0.3     node01         <none>           <none>
etcd-controlplane                          1/1     Running   0          4m38s   172.17.0.23   controlplane   <none>           <none>
katacoda-cloud-provider-74dc75cf99-2jrpt   1/1     Running   3          5m42s   10.88.0.2     node01         <none>           <none>
kube-apiserver-controlplane                1/1     Running   0          4m33s   172.17.0.23   controlplane   <none>           <none>
kube-controller-manager-controlplane       1/1     Running   0          4m45s   172.17.0.23   controlplane   <none>           <none>
kube-keepalived-vip-smkdc                  1/1     Running   0          5m27s   172.17.0.26   node01         <none>           <none>
kube-proxy-8sxkt                           1/1     Running   0          5m27s   172.17.0.26   node01         <none>           <none>
kube-proxy-jdcqc                           1/1     Running   0          5m43s   172.17.0.23   controlplane   <none>           <none>
kube-scheduler-controlplane                1/1     Running   0          4m47s   172.17.0.23   controlplane   <none>           <none>
weave-net-8cxqg                            2/2     Running   1          5m27s   172.17.0.26   node01         <none>           <none>
weave-net-s4tcj                            2/2     Running   1          5m43s   172.17.0.23   controlplane   <none>           <none>

Next "exec" into the originating pod - kube-proxy-8sxkt in my example

kubectl -n kube-system exec -it kube-proxy-8sxkt sh

Next, you will use the destination pod's IP and port (10256 - my example) number to connect. Please note that you may have to install curl/telnet if your originating container's image does not include the application

# curl telnet://172.17.0.23:10256

HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close

CodePudding user response:

You can call via pod's IP.

enter image description here

Note: This IP can only be used in the k8s cluster.

CodePudding user response:

POD address (IP) is a good option you can use it, unless you know the POD IP which might get changed from time to time due to deployment and scaling changes.

i would suggest trying out the Daemon set by exposing it using the service type Node port if you have a fix amount of Node and not much autoscaling there.

If you want to connect your POD with a specific POD you can use the Node IP on which POD is scheduled and use the Node port service.

Node IP:Node port

Read more at : https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport

If you don't want to connect to a specific POD and just any of the Daemon sets replica will work to connect with you can use the service name to connect PODs with each other.

my-svc.my-namespace.svc.cluster-domain.example

Read more about the service and POD DNS

https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

  • Related