setting custom port for ingress load balancer

9/1/2017

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
-- Ajay
devops
kubernetes
rancher

2 Answers

9/1/2017

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.

-- Janos Lenart
Source: StackOverflow

9/11/2019

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.

-- IamsagarTu
Source: StackOverflow