Using nginx-ingess to access an application in a kubernetes cluster

3/9/2020

I have a bare metal Kubernetes (1 master and 3 nodes) and using metallb to provide load-balancing.
I also have Jupyterhub and nginx-ingress installed as services.

nginx-ingress:

NAME                            TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)                      AGE
nginx-ingress-controller        LoadBalancer   10.108.54.171   192.168.1.240   80:31463/TCP,443:30231/TCP   5m11s
nginx-ingress-default-backend   ClusterIP      10.98.47.19     <none>          80/TCP                       5m11s

Jupyterhub

NAME           TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)                      AGE
proxy-public   LoadBalancer   10.102.251.6    192.168.1.242   80:32691/TCP,443:31737/TCP   8h

I can access the jupyterhub from the external IP BUT cannot access it thru the nginx-ingress

nginx-ingress config.yaml

apiVersion: extensions/v1beta1
ingress
     enabled: true
     hosts:
kind: Ingress
metadata:
     annotations:
        kubernetes.io/ingress.class: nginx
     name: myingress
     namespace: default
rbac:
   create: true
spec:
  rules:
  - host: example.com
    http:
      paths:
      - backend:
        serviceName: jhub
        servicePort: 80
      path: /classes

My question is, how do I access the jupyterhub (proxy-public) via nginx-ingress

-- ChrisJ
kubernetes
nginx-ingress

2 Answers

3/9/2020

You'll need a DNS record or hosts file entry pointing example.com (maybe change this) to the external IP of the ingress controller (192.168.1.240).

The ingress controller will only route requests to the service backend defined in the ingress if if the URI of the request matches the host field in the ingress.

-- switchboard.op
Source: StackOverflow

3/9/2020

The proxy-public backend service should be of type ClusterIP instead of type LoadBalancer just like the nginx-ingress-default-backend service. The service name in ingress should be proxy-public instead of jhub.

You should be able to access it via http://192.168.1.240/classes

-- Arghya Sadhu
Source: StackOverflow