GCE ingress to route traffic to multiple services

I am trying to use GCE ingress to send external traffic to my frontend and backend services deployed to GKE using a global static ip. This is part of my test project hence there is no use of dns and all. So my target is simple, i.e.,

curl "ingress-ip"           # should send traffic to my frontend service
curl "ingress-ip/api/"      # should send the traffic to my backend api service

When I tested with LoadBalancer service type (in service.yaml instead of NodePort) it worked well for the backend and frontend services, but I want to have one single ip for both my backend and frontend and with the following helm chart yaml it does not seems to be working.

After the ingress is deployed it took some time to get into ‘OK’ state, but when I am hitting my frontend, only the app title is fetched, rest the body of the webpage is blank. And in case of backend service I’m getting 404. I waited at least 15mins between ingress provisioning and hitting the url from my browser.

Any help would be appreciated.

ingress.yaml

apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: {{ .Values.ingress.name }}
      annotations:
        kubernetes.io/ingress.class: gce
        kubernetes.io/ingress.global-static-ip-name: {{ .Values.ingress.gke_static_ip }}
    spec:
      rules:
      - http:
          paths:
          - path: /*
            pathType: ImplementationSpecific
            backend:
              service:
                name: {{ .Values.frontend.name }}
                port:
                  number: {{ .Values.frontend.port }}
          - path: /api/bpcalc/*
            pathType: ImplementationSpecific
            backend:
              service:
                name: {{ .Values.backend.name }}
                port:
                  number: {{ .Values.backend.port }}

service.yaml (both the services have similar config)

apiVersion: v1
    kind: Service
    metadata:
      name: {{ .Values.container.name }}-service
    spec:
      type: NodePort
      selector:
        repo: bpcalc
      ports:
      - protocol: TCP
        port: 80
        targetPort: {{ .Values.container.port }}

Hi @anupx73 ,

Can you share any documentations or guides that you used or followed prior to the setup of GCE Ingress?

For this part, can you share a screenshot for the error 404 as well as with the webpage showing blank? Thanks!

Hi @Marvin_Lucero thanks for your reply.

I have followed Configure Ingress for external load balancing | Google Kubernetes Engine (GKE) | Google Cloud

The frontend service issue seems to be getting the js and css files from static folder. See the image below of 404 for the js and css file, not the main index.html file. While I tested with LoadBalancer instead of nodeport and GCE ingress, the path was resolved correctly. Is the any config in GCE ingress which can achieve the similar behavior like LoadBalancer service type?

I can confirm my nginx.conf has the following and the static folder is available in the root folder.

server {
  listen 8080;
  location / {
    root   /usr/share/nginx/html;
  }
}

Hi @anupx73 ,

Since you are using a GCE ingress, your services must be NodePort type.

You can follow this working example shown in this discussion. This can be your basis or guide to make nodeport type of service work.

If you look at my original post, I am using NodePort only, I used LoadBalancer service type to test if it works, and it does. But with NodePort and GCE Ingress the problem is mentioned above.