Trouble witn Nginx ingress controller routing

572 views
Skip to first unread message

Pål Kristensen

unread,
Apr 4, 2017, 9:42:20 AM4/4/17
to Kubernetes user discussion and Q&A
Hi

I have a working Kubernetes cluster running on AWS, and have applied the nginx ingress controller. The default 404 error page does show up, so I'm under the impression that the nginx controllers and default backend 404 service works as expected.

https://services3.geodataonline.no/

I have deployed the example echoheaders app/service and tried to make an ingress rule to route to the service, but with no luck.

This is my setup and configs.

eachheaders backend
apiVersion: extensions/v1beta1
kind
: Deployment
metadata
:
  name
: echo
spec
:
  replicas
: 1
 
template:
    metadata
:
      labels
:
        app
: echoapp
    spec
:
      containers
:
     
- name: webserver
        image
: gcr.io/google_containers/echoserver:1.4
        ports
:
       
- containerPort: 8080

eachheaders service
apiVersion: v1
kind
: Service
metadata
:
  name
: echo-service
  labels
:
    app
: echoapp
spec
:
 
#type: NodePort
  ports
:
 
- port: 80
    targetPort
: 8080
    protocol
: TCP
  selector
:
    app
: echoapp

eachheaders ingress
apiVersion: extensions/v1beta1
kind
: Ingress
metadata
:
  annotations
:
    kubernetes
.io/ingress.class: "nginx"
    ingress
.kubernetes.io/ssl-redirect: "true"
   
#ingress.kubernetes.io/affinity:
  name
: echo-ingress
 
namespace: default
spec
:
  rules
:
 
- host: services3.geodataonline.no
    http
:
      paths
:
     
- path: /echo
        backend
:
          serviceName
: echo-service
          servicePort
: 80

Describing the echo-service
Name:                   echo-service
Namespace:              default
Labels:                 app=echoapp
Selector:               app=echoapp
Type:                   ClusterIP
IP
:                     10.96.87.124
Port:                   <unset> 80/TCP
Endpoints:              10.200.90.3:8080
Session Affinity:       None
No events.

Describing the default 404 service
Name:                   nginx-default-backend
Namespace:              default
Labels:                 k8s-addon=ingress-nginx.addons.k8s.io
Selector:               app=nginx-default-backend
Type:                   ClusterIP
IP
:                     10.96.198.193
Port:                   <unset> 80/TCP
Endpoints:              10.200.21.5:8080,10.200.90.4:8080
Session Affinity:       None
No events.

Describing the ingress
Name:                   echo-ingress
Namespace:              default
Address:                a3574dbd6190811e7a16306feaed6268-504934399.eu-west-1.elb.amazonaws.com
Default backend:        default-http-backend:80 (<none>)
Rules:
 
Host                          Path    Backends
 
----                          ----    --------
  services3
.geodataonline.no
                               
/echo   echo-service:80 (<none>)
Annotations:
  ssl
-redirect: true
Events:
 
FirstSeen     LastSeen        Count   From                    SubObjectPath   Type            Reason  Message
 
---------     --------        -----   ----                    -------------   --------        ------  -------
 
2h            15m             4       {ingress-controller }                   Normal          UPDATE  Ingress default/echo-ingress
 
1h            15m             3       {ingress-controller }                   Normal          UPDATE  Ingress default/echo-ingress


And from the nginx controller log its seems like the correct endpoints are found and used
I0404 13:25:18.482666       5 controller.go:985] getting endpoints for service default/nginx-default-backend and port http
I0404
13:25:18.482723       5 controller.go:1045] endpoints found: [{10.200.21.5 8080 0 0} {10.200.90.4 8080 0 0}]
I0404
13:25:18.482790       5 dns.go:56] nameservers IP address/es to use: [10.96.0.10]
...
I0404
13:25:18.483080       5 main.go:110] No default affinity was found for Ingress echo-ingress
I0404
13:25:18.483086       5 controller.go:769] creating upstream default-echo-service-80
I0404
13:25:18.483091       5 controller.go:813] obtaining port information for service default/echo-service
I0404
13:25:18.483094       5 controller.go:985] getting endpoints for service default/echo-service and port 8080
I0404
13:25:18.483102       5 controller.go:1045] endpoints found: [{10.200.90.3 8080 0 0}]
I0404
13:25:18.483126       5 dns.go:56] nameservers IP address/es to use: [10.96.0.10]


I would expect this link to function, but it doesn't.
https://services3.geodataonline.no/echo
The default 404 page is displayed. The echo app does work when browsed directly on the node where it is deployed.

PS, I have setup a CNAME for services3.geodataonline.no to point to a3574dbd6190811e7a16306feaed6268-504934399.eu-west-1.elb.amazonaws.com


Any suggestions?

Regards,
Pål

Pål Kristensen

unread,
Apr 4, 2017, 10:16:42 AM4/4/17
to Kubernetes user discussion and Q&A
Interesting

Removing the
  - host: services3.geodataonline.no
from the rule did the trick. But I would like to use the host mapping. What do I need to do to get that part working?

Regards,
Pål
Reply all
Reply to author
Forward
0 new messages