Kubernetes Ingress servicePort alternative?

10/16/2017

Ingress example from https://kubernetes.io/docs/concepts/services-networking/ingress/ shows that in order to specify ingress bancked, we have to specify servicePort and serviceName, for example:

backend:
      serviceName: test
      servicePort: 80

I want to create services with random ports and avoid specifying them in the ingress definition. Are there any alternatives to servicePort? Maybe use port name or targetPort that are assigned in the service?

-- Tom chan
docker-ingress
gcp
kubectl
kubernetes
kubernetes-helm

1 Answer

10/17/2017

Kubernetes ingress supports so far (1.8) only specific ports: https://kubernetes.io/docs/api-reference/v1.8/#ingressbackend-v1beta1-extensions

AFAIK usual pattern is to use Ingress with a service type ClusterIP, so you will not be concerned about port collisions.
You may have separate service with same selector for e.g. NodePort if needed, but this will not be concern of Ingress.

-- Alex
Source: StackOverflow