Kubernetes Ingress Port to Port route

71 Views Asked by At

I want to open my services outside. I decided to use ingress for this. But directly over the IP without the hostname. For example, for an application running on port 9090, when I type IP:9090, it should go to the corresponding application. likewise 9091,8080,7070 etc.

I didn't choose to use NodePort, because it restricts between 30000 and 32767.Dec.

Ingress can I solve this problem with a general rule? or is Ingress a suitable choice for this?

1

There are 1 best solutions below

0
Adedamola On

If you want to expose services directly via IP and port without using hostnames, you should use Kubernetes Services of type LoadBalancer instead of Ingress. Ingress is primarily designed for HTTP/HTTPS routing based on hostnames, whereas Services of type LoadBalancer allow you to expose services directly via an external IP address and port.

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: my-app
  ports:
    - protocol: TCP
      port: 9090
      targetPort: 9090
    
  type: LoadBalancer