setting custom port for ingress load balancer

1.9k views Asked by At

My configuration is below. How do I set a different port for ingress load balancer?

Service:

kind: Service
apiVersion: v1
metadata:
  name: docker-service
  namespace: mp-prod
spec:
  type: NodePort
  selector:
    app: dockerprod
  ports:
    - name: http
      protocol: TCP
      port: 0909
      targetPort: 8909

Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: dockeringress
  namespace: mp-prod
spec:
  backend:
    serviceName: docker-service
    servicePort: 0909
2

There are 2 answers

0
Janos Lenart On

There is no portable (between different type of ingresses/cloud providers) way of achieving this at the moment.

You can use something like proxy-to-server and create an L4 loadbalancer yourself.

0
IamsagarTu On

Maybe you can try this out.

  1. Add an ConfigMap like this
kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-config
data:
   public-ports: "80;443;<custom port>"
   private-ports: "80;443;<custom port>"
  1. Add annotation in your ingress like this
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.bluemix.net/tcp-ports: "serviceName=docker-service ingressPort=<custom port> servicePort=0909"
  name: dockeringress
  namespace: mp-prod
spec:
  backend:
    serviceName: docker-service
    servicePort: 0909

After that, you can access your service by specific port through the ingress.