1

I have an application running in the tomcat path /app1, how should I access this from the ingress path?

When accessing "/", it gives the default tomcat 404 - not found page, and when accessing via /app1 it shows "default backend -404"

What I wanna know is: Is there anyway to configure the context path without using ngnix's ingress controller? (Just using GKE's default ingress controller)

Here is a sample of my ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: gke-my-ingress-1
  annotations:
    kubernetes.io/ingress.global-static-ip-name: gke-my-static-ip
    networking.gke.io/managed-certificates: gke-my-certificate
spec:
  rules:
  - host: mydomain.web.com
    http:
      paths:
      - path: /
        backend:
          serviceName: my-service
          servicePort: my-port

Edit: service output

kubectl get svc
my-service   NodePort    <IP_REDACTED>   <none>        8080:30310/TCP   5d16h
kubectl describe svc my-service
Name:                     my-service
Namespace:                default
Labels:                   <none>
Annotations:              kubectl.kubernetes.io/last-applied-configuration:
                            {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"my-service","namespace":"default"},"spec":{"ports":[{"name"...
Selector:                 app=my-deployment-1
Type:                     NodePort
IP:                       <IP_REDACTED>
Port:                     my-port  8080/TCP
TargetPort:               8080/TCP
NodePort:                 my-port  30310/TCP
Endpoints:                <IP_REDACTED>:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

and this is my Node Port service yaml:

---
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  ports:
  - name: my-port
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: my-deployment-1
  type: NodePort
user10518
  • 117
  • 2
  • 11
  • GKE's default ingress controller should work just fine. Have you configured all the required `Services` that expose specific parts of your app. Could you show the output of `kubectl get svc` relevant to those `Services` ? – mario Mar 09 '20 at 13:19
  • Hi @mario I have added the details – user10518 Mar 10 '20 at 00:52
  • Could you specify how you can access this application directly using your `NodePort` `Service` ? Is it available under `:` or rather on `:/app1` ? – mario Mar 10 '20 at 11:20
  • It is accessed on :/app1 – user10518 Mar 11 '20 at 00:50

1 Answers1

1

Unfortunately current implementation of default GKE Ingress Controller doesn't support rewrite targets. There is still an open github issue that you can find here.

What you're trying to achieve is rewriting your ingress path to some specific path exposed by your application, in your case Apache Tomcat web server.

Isn't there any possibility to reconfigure your app to be served from the main path by Apache Tomcat ? If so, you can make it available on <IngressLoadBalancerIP>/app1 by configuring the following path in your ingress resource like in the example below:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: default-backend
          servicePort: 8080
      - path: /app1
        backend:
          serviceName: my-service
          servicePort: 8080

But unfortunately you cannot configure rewrite in the way that when you go to <IngressLoadBalancerIP>/app1 it rewrites to your <my-service>/app1.

It seems that for now the only solution is to install different ingress controller such as mentioned nginx insgress controller.

mario
  • 9,858
  • 1
  • 26
  • 42
  • Yes, I found that they have last responded to a ticket about rewrite targets here: https://issuetracker.google.com/u/0/issues/72484862 It's quite unfortunate, but I eventually managed to get my ingress setup working using Nginx Ingress Controller, as suggested, thank you. – user10518 Mar 12 '20 at 02:31