Ingress paths not working with dynamic endpoint

1,807 views
Skip to first unread message
Assigned to placi...@gmail.com by me

Jonathan Mejías

unread,
May 13, 2018, 1:17:47 PM5/13/18
to Kubernetes user discussion and Q&A
Hello..

I got an angular deployment in a kubernetes cluster, and i want to define the app access with ingress paths. By example

path: foo.bar.com/appi1   ----> goes to my angular app

if i goes to foo.bar.com/app1/login, this response with the default backend. Giving me an 404 error. (foo.bar.com/login)  { that's not what i want!)

My ingress definition is:

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /   (THIS NOT WORK! IN GKE INGRESS)
  name: angular-app-ingress 
  namespace: default
spec:
  rules:
    http:
      paths:
      - backend:
          serviceName: angular-svc
          servicePort: 80
        path: /angular                   ( /angular/ , /angular/*    NOT WORK EITHER! )
      - backend:
          serviceName: angular-svc
          servicePort: 80
        path: /angular2

the browser redirects me to my angular backend service, but not at my "http://foo.bar.com/angular/login" point.

is necessary to use a NGINX ingress type?? I want to user an ingress with dynamic endpoints. NOT with static endpoints (like the "hello-app" exist).


 
 

Sunil Bhai

unread,
May 13, 2018, 10:53:35 PM5/13/18
to Kubernetes user discussion and Q&A
pls have a check on this. It helps you in addressing the issue



For reference how its configured on Minikube check this

davidsha...@gmail.com

unread,
May 21, 2018, 1:09:15 PM5/21/18
to Kubernetes user discussion and Q&A
I have same problem. Did you mane to resolve?

Jonathan Mejias

unread,
May 21, 2018, 1:45:00 PM5/21/18
to kubernet...@googlegroups.com
The only way that i resolve the problem was changing to an nginx controller, instead a gke. Installing nginx-controller with kubernetes helm and using rewrite option. Gke is limited in configuration option i do not recommend.

PD: Nginx-controller uses network load balancer (TCP) not HTTP.



On Mon, May 21, 2018, 13:09 <davidsha...@gmail.com> wrote:
I have same problem. Did you mane to resolve?

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Tim Hockin

unread,
May 21, 2018, 7:43:44 PM5/21/18
to Kubernetes user discussion and Q&A

Ahmet Alp Balkan

unread,
May 21, 2018, 8:00:30 PM5/21/18
to kubernet...@googlegroups.com
+1 to Tim. Your "rewrite-target" annotation won't work on GKE (it's only for nginx-ingress).

Also note that "Services exposed through an Ingress must serve a response with HTTP 200 status to the GET requests on "/". This is used for health checking. If your application does not serve HTTP 200 on "/", the backend will be marked unhealthy and will not get traffic."

So I would say make sure:

1. Your "GET /" of the load balancer returns a 200 OK. (Looks like you're not handling "/", only /angular and /angular2)
2. All backend services listed (in your case "angular-svc") returns HTTP 200 OK for "GET /" when called directly (not through the created load balancer), you can test this with "kubectl port-forward"
3. "path: /angular" will not work for "/angular/foo". As Tim said, use "/angular/*".

Jonathan Mejias

unread,
May 23, 2018, 4:11:14 PM5/23/18
to kubernet...@googlegroups.com
Ahmet i did all that you mention it. 

/angular, /angular/, /angular/*  and if a get the healtcheck to " / " i will get the response of a default backend (404). Insted my app have an "healthCheck" path response (resolve an HTTP 200). 

My path didn`t work. All the problems get solution when you change to an Nginx Controller using L4 GLB

Use Nginx Controller and rewrite-target 


2018-05-21 20:00 GMT-04:00 'Ahmet Alp Balkan' via Kubernetes user discussion and Q&A <kubernet...@googlegroups.com>:
+1 to Tim. Your "rewrite-target" annotation won't work on GKE (it's only for nginx-ingress).

Also note that "Services exposed through an Ingress must serve a response with HTTP 200 status to the GET requests on "/". This is used for health checking. If your application does not serve HTTP 200 on "/", the backend will be marked unhealthy and will not get traffic."

So I would say make sure:

1. Your "GET /" of the load balancer returns a 200 OK. (Looks like you're not handling "/", only /angular and /angular2)
2. All backend services listed (in your case "angular-svc") returns HTTP 200 OK for "GET /" when called directly (not through the created load balancer), you can test this with "kubectl port-forward"
3. "path: /angular" will not work for "/angular/foo". As Tim said, use "/angular/*".
On Mon, May 21, 2018 at 4:43 PM 'Tim Hockin' via Kubernetes user discussion and Q&A <kubernetes-users@googlegroups.com> wrote:
On Mon, May 21, 2018 at 10:44 AM Jonathan Mejias <drumb...@gmail.com> wrote:
The only way that i resolve the problem was changing to an nginx controller, instead a gke. Installing nginx-controller with kubernetes helm and using rewrite option. Gke is limited in configuration option i do not recommend.

PD: Nginx-controller uses network load balancer (TCP) not HTTP.



On Mon, May 21, 2018, 13:09 <davidsha...@gmail.com> wrote:
I have same problem. Did you mane to resolve?

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.



--
Saludos Cordiales...
 
Atte. Jonathan Mejías

Tim Hockin

unread,
May 23, 2018, 8:34:26 PM5/23/18
to Kubernetes user discussion and Q&A
can you try to repro with a manual LB and /* - that should match all sub-paths.

On Wed, May 23, 2018 at 1:11 PM Jonathan Mejias <drumb...@gmail.com> wrote:
Ahmet i did all that you mention it. 

/angular, /angular/, /angular/*  and if a get the healtcheck to " / " i will get the response of a default backend (404). Insted my app have an "healthCheck" path response (resolve an HTTP 200). 

My path didn`t work. All the problems get solution when you change to an Nginx Controller using L4 GLB

Use Nginx Controller and rewrite-target 

2018-05-21 20:00 GMT-04:00 'Ahmet Alp Balkan' via Kubernetes user discussion and Q&A <kubernet...@googlegroups.com>:
+1 to Tim. Your "rewrite-target" annotation won't work on GKE (it's only for nginx-ingress).

Also note that "Services exposed through an Ingress must serve a response with HTTP 200 status to the GET requests on "/". This is used for health checking. If your application does not serve HTTP 200 on "/", the backend will be marked unhealthy and will not get traffic."

So I would say make sure:

1. Your "GET /" of the load balancer returns a 200 OK. (Looks like you're not handling "/", only /angular and /angular2)
2. All backend services listed (in your case "angular-svc") returns HTTP 200 OK for "GET /" when called directly (not through the created load balancer), you can test this with "kubectl port-forward"
3. "path: /angular" will not work for "/angular/foo". As Tim said, use "/angular/*".
On Mon, May 21, 2018 at 4:43 PM 'Tim Hockin' via Kubernetes user discussion and Q&A <kubernet...@googlegroups.com> wrote:
On Mon, May 21, 2018 at 10:44 AM Jonathan Mejias <drumb...@gmail.com> wrote:
The only way that i resolve the problem was changing to an nginx controller, instead a gke. Installing nginx-controller with kubernetes helm and using rewrite option. Gke is limited in configuration option i do not recommend.

PD: Nginx-controller uses network load balancer (TCP) not HTTP.



On Mon, May 21, 2018, 13:09 <davidsha...@gmail.com> wrote:
I have same problem. Did you mane to resolve?

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.



--
Saludos Cordiales...
 
Atte. Jonathan Mejías

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages