Host in Ingress Controller Gets Routes to Default Backend

6/19/2017

I setup an ingress controller, a service with a node port, setup health routes, and verified that my service is running, but my request are still getting routed to my default backend and not to my ingress controller. I have no idea why and don't really know how to debug this.

I've check that:

  1. My pods are healthy (and have a health route)
  2. I have a node port
  3. There are no errors in the describe for the service
  4. My service works from another pod

When I curl my URL, I get this:

$ curl image-pin.thejsj.com -v
* Rebuilt URL to: image-pin.thejsj.com/
*   Trying 35.186.225.114...
* Connected to image-pin.thejsj.com (35.186.225.114) port 80 (#0)
> GET / HTTP/1.1
> Host: image-pin.thejsj.com
> User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
> Accept: */*
> Referer:
>
< HTTP/1.1 404 Not Found
< Date: Mon, 19 Jun 2017 05:06:09 GMT
< Content-Length: 21
< Content-Type: text/plain; charset=utf-8
< Via: 1.1 google
<
* Connection #0 to host image-pin.thejsj.com left intact
default backend - 404

My Resource Declarations:

Ingress Controller:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "main-ingress"
  labels:
    # Timestamp used in order to force reload of the secret
    last_updated: "1497848257"
spec:
  rules:
  - host: image-pin.thejsj.com
    http:
      paths:
      - path: /*
        backend:
          serviceName: imagepin
          servicePort: 80

Service:

apiVersion: v1
kind: Service
metadata:
  name: imagepin
spec:
  selector:
    app: imagepin
  type: NodePort
  ports:
  - protocol: "TCP"
    port: 80
    nodePort: 32222
    targetPort: 80

Deployment:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: imagepin
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: imagepin
    spec:
      containers:
        - name: imagepin
          image: quay.io/hiphipjorge/imagepin_server:latest
          args:
            - "npm"
            - "start"
          ports:
            - containerPort: 80
          env: ...
          readinessProbe:
            httpGet:
              path: /
              port: 80
          livenessProbe:
            httpGet:
              path: /
              port: 80

Current State:

Ingress Controller:

Every 2.0s: kubectl describe ingress  main-ingress                               Jorges-MacBook-Pro-2.local: Sun Jun 18 22:01:35 2017

Name:                   main-ingress
Namespace:              default
Address:                35.186.225.114
Default backend:        default-http-backend:80 (10.0.0.6:8080)
Rules:
  Host                  Path    Backends
  ----                  ----    --------
  image-pin.thejsj.com
                        /*      imagepin:80 (<none>)
Annotations:
  forwarding-rule:      k8s-fw-default-main-ingress--02988768680308cd
  target-proxy:         k8s-tp-default-main-ingress--02988768680308cd
  url-map:              k8s-um-default-main-ingress--02988768680308cd
  backends:             {"k8s-be-31582--02988768680308cd":"HEALTHY","k8s-be-32222--02988768680308cd":"HEALTHY"}
Events:
  FirstSeen     LastSeen        Count   From                    SubObjectPath   Type            Reason  Message
  ---------     --------        -----   ----                    -------------   --------        ------  -------
  3m            3m              1       loadbalancer-controller                 Normal          CREATE  ip: 35.186.225.114
  3m            3m              2       loadbalancer-controller                 Normal          Service no user specified default bac
kend, using system default

Service

$ kubectl describe service imagepin
Name:           imagepin
Namespace:      default
Labels:         <none>
Annotations:        kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"imagepin","namespace":"default"},"spec":{"ports":[{"nodePort":32222,"port":80,...
Selector:       app=imagepin
Type:           NodePort
IP:         10.3.241.98
Port:           <unset> 80/TCP
NodePort:       <unset> 32222/TCP
Endpoints:      10.0.2.6:80
Session Affinity:   None
Events:         <none>
-- Jorge Silva
google-compute-engine
kubernetes

1 Answer

6/19/2017

Try sending your curl request as follows:

curl ingress-ip/ -H "Host: image-pin.thejsj.com"

This might work for you.

-- chaitu kopparthi
Source: StackOverflow