For my project, I need to send UDP packets to a Kubernetes Pod from an outside cluster. How can I do this?
I am using Kubeadm for creating the cluster. I tried to use nodePort but it seems that my requirement cannot be fulfilled with Nodeport.
Kubernetes Services support TCP (default), UDP, and SCTP protocols. One of the most popular ways to use Kubernetes Services in AWS is with the LoadBalancer type.
Summary. In Kubernetes, pods can communicate with each other a few different ways: Containers in the same Pod can connect to each other using localhost , and then the port number exposed by the other container. A container in a Pod can connect to another Pod using its IP address.
Kubernetes assumes that pods can communicate with other pods, regardless of which host they land on. Kubernetes gives every pod its own cluster-private IP address, so you do not need to explicitly create links between pods or map container ports to host ports.
Kubectl port-forward is a method to access, interact and manage internal Kubernetes clusters directly from your local network. This method is popularly used to investigate issues concerning your applications. Kubectl is a command-line tool that is used to run commands and control Kubernetes clusters.
Actually, NodePort
can be used to expose ports within TCP and UDP protocols. What was the problem in your case?
You can consider using Nginx Ingress Controller
and creating ReplicationController
to implement Nginx ingress
in order to expose your Pods across UDP port as described Here or you can check this Link.
Create ConfigMap and specify External port like <namespace/service name>:<service port>
which you want to access from outside Kubernetes cluster.
Finally, Nginx ingress can be exposed, i.e., using Kubernetes ExternalIP.
I am able to find the solution for my requirement.
I have exposed the UDP port for my pod and it works fine.
Example
kubectl expose pod udp-server-deployment-8c8d6d868-c77zx --port=10001 --protocol=UDP --external-ip=10.1.11.82 --name=udp-server
Thank you all for your support :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With