Need help to create multi path base routing in GKE ingress (Not nginx). I have a host pointed to the GKE ingress and it's working fine with single backend, Now I tried to updated another backend with different path (/app1) and service name But it's giving error "Cannot GET /app1".
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
namespace: default
annotations:
kubernetes.io/ingress.global-static-ip-name: "ingress"
spec:
rules:
- host: "mydomain.com"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: my-app
port:
number: 8080
- path: /app1
pathType: ImplementationSpecific
backend:
service:
name: app1
port:
number: 8080
I got 404 error while accessing /app1
There are three possibilities for this issue:
1. Check whether the container ports opened. You can check it using netstat:
2. The issue might also be caused by the Firewall configuration. Make sure you have proper firewall settings.
3. Another reason might be misconfiguration between port, containerPort and targetPort. Verify whether you have set proper port, targetPort and servicePort.
GCP Ingress supports multiple paths. I have tested ingress multipath based routing using Setting up HTTPS(S) Load balancing with Ingress by using both Hello-world v1 and v2.
Here are the configuration files which I have deployed.
First Deployment Configuration file:
$ nano Deploy.yaml
Second Deployment Configuration file:
$ nano second.yaml
Ingress resource Configuration file:
Ingress is a Kubernetes resource that encapsulates a collection of rules and configuration for routing external HTTP(S) traffic to internal services.
$ nano Ingress.yaml
Now, find out the external IP address of the load balancer serving your application by running:
NOTE : You can specify a default backend by providing a defaultBackend field in your Ingress manifest. Any requests that don't match the paths in the rules field are sent to the Service and port specified in the defaultBackend field. For example, in the above Ingress, any requests that don't match / or /app1 are sent to a Service named first-service on port 5001.