I have many tenants running on one Kubernetes cluster (on AWS), where every tenant has one Pod that exposes one TCP port (not HTTP) and one UDP port.
I have the following service so far:
apiVersion: v1
kind: Service
metadata:
name: my-service
labels:
app: my-app
spec:
type: NodePort
ports:
- port: 8111
targetPort: 8111
protocol: UDP
name: my-udp
- port: 8222
targetPort: 8222
protocol: TCP
name: my-tcp
selector:
app: my-app
What is the way to go?
NodePort
to ClusterIP
tcp-services
in the ingress-nginx
namespace adding :data: "8222": your-namespace/my-service:8222
udp-services
:data: "8111": your-namespace/my-service:8111
Now, you can access your application externally using the nginx-controller IP <ip:8222>
(TCP) and <ip:8111>
(UDP)
The description provided by @ffledgling is what you need.
But I have to mention that if you want to expose ports, you have to use a load balancer or expose nodes to the Internet. For example, you can expose a node to the Internet and allow access only to some necessary ports.