Ingress not working in google kubernetes engine for multiple services (Spring Boot)

10/29/2018

I deployed two services in a cluster in google cloud.

When I run: kubectl get services I get->

NAME           TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
hello-java-1   NodePort    10.7.254.204   <none>        8080:31848/TCP   21m
hello-java-2   NodePort    10.7.246.52    <none>        8080:30624/TCP   19m
kubernetes     ClusterIP   10.7.240.1     <none>        443/TCP          23m

Now, I followed as per google cloud docs: Ingress and configured the fanout-ingress as:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: fanout-ingress
spec:
  rules:
  - http:
      paths:
      - path: /product/*
        backend:
          serviceName: hello-java-1
          servicePort: 8080
      - path: /list/*
        backend:
          serviceName: hello-java-2
          servicePort: 8080

Now:

$kubectl get ingress fanout-ingress
NAME             HOSTS     ADDRESS         PORTS     AGE
fanout-ingress   *         35.190.55.204   80        17m

I get these results.

I checked the command: kubectl describe ingress fanout-ingress

The output is:

  *
        /product/*   hello-java-1:8080 (<none>)
        /list/*      hello-java-2:8080 (<none>)
Annotations:
  ingress.kubernetes.io/backends:         {"k8s-be-30624--e761000d52fd1c80":"HEALTHY","k8s-be-31726--e761000d52fd1c80":"HEALTHY","k8s-be-31848--e761000d52fd1c80":"HEALTHY"}
  ingress.kubernetes.io/forwarding-rule:  k8s-fw-default-fanout-ingress--e761000d52fd1c80
  ingress.kubernetes.io/target-proxy:     k8s-tp-default-fanout-ingress--e761000d52fd1c80
  ingress.kubernetes.io/url-map:          k8s-um-default-fanout-ingress--e761000d52fd1c80
Events:
  Type    Reason   Age               From                     Message
  ----    ------   ----              ----                     -------
  Normal  ADD      18m               loadbalancer-controller  default/fanout-ingress
  Normal  CREATE   17m               loadbalancer-controller  ip: 35.190.55.204
  Normal  Service  8m (x4 over 17m)  loadbalancer-controller  no user specified default backend, using system default

Now when I access http://35.190.55.204/product/home I get spring whitelabel error.. but \home is defined in the application! Why this happens?

-- Dillz
google-kubernetes-engine
kubernetes
kubernetes-ingress

1 Answer

10/29/2018

I got the issue! For the path to be /product/*, all the URL mappings of our first service Requestpath in spring application should start with /product/

ex: /product/list, /product/add, /product/delete etc

Also for Ingress path rule /list/*, all the URL mappings in our second service Requestpath in spring application should start with /list/

ex: /list/sort, /list/add, /list/delete etc

-- Dillz
Source: StackOverflow