How do you specify a custom port for the ingress controller on Minikube?

12/10/2019

It seems to listen on 80 by default - sensible - but if I wanted it to listen for requests on (for example) 8000, how would I specify this?

For clarity, this is via the nginx controller enabled via minikube addons enable ingress)

-- user1381745
kubernetes
minikube

3 Answers

12/20/2019

nginx-ingress controller actually allows changing http and https ports.

See the configuration parameters:

controller.service.ports.http
controller.service.ports.https
-- r a f t
Source: StackOverflow

5/8/2020

While in general, Ingress does not allow you to expose random things on random ports, in case of nginx-ingress, you can do it. But you have to use additional annotation.

For instance, if your pod exposes 443, but you want it to be available on port 8081 you have to do following trick:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: myservice
  namespace: mynamespace
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.org/listen-ports-ssl: "8081"

spec:
  tls:
  - hosts:
    - host.org
    secretName: my-host-tls-cert
  rules:
  - host: host.org
    http:
      paths:
      - path: /
        backend:
          serviceName: my-service
          servicePort: 443
-- Vlad A.
Source: StackOverflow

12/10/2019

Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.

It means that it'll use default ports for HTTP and HTTPS ports.

From the documentation we can read:

An Ingress does not expose arbitrary ports or protocols. Exposing services other than HTTP and HTTPS to the internet typically uses a service of type Service.Type=NodePort or Service.Type=LoadBalancer.

-- mWatney
Source: StackOverflow