I have a working Kubernetes gossip-based cluster deployed on AWS using Kops. I have been studying ingress using both of these.
https://github.com/kubernetes/ingress-nginx
https://github.com/appscode/voyager
I followed the steps using both on seperate clusters. I am using without RBAC for now. So far things have worked better using ingress-nginx. Am expecting more from voyager based on what I read on the site.
After setup I ran this command kubectl create -f my-ingress.yml with following content in the yml file
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-ingress
annotations:
ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /web
backend:
serviceName: service2
servicePort: 80
- path: /
backend:
serviceName: service2
servicePort: 80
- path: /exp
backend:
serviceName: service1
servicePort: 8080When using voyager unlike with ingress-nginx I cannot see the load balancer external url in output of "kubectl describe ing <ingressname> But thats ok. I figured out how to reach it. Voyager creates a service for this load balancer. I reached the external endpoint url from that service.
Issue is that in voyager unlike with ingress-nginx I am only able to access what is mapped under root i.e. / and not what is mapped under /web or /exp.
Please suggest.
Tried codefx's suggestion. Problem is still there in voyager. I tried moving the paths up and down. The root i.e. / still works. But there is basically a a variation of one of these 2 error messages for the other 2 paths /web and /exp.
Variation 1
<html><body><h1>Whitelabel Error Page</h1>
<p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p>
<div id='created'>Sun Oct 22 20:32:20 UTC 2017</div>
<div>There was an unexpected error (type=Not Found, status=404).</div>
<div>No message available</div>
</body></html>
Variation 2
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.13.5</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->Will try again tomorrow. Codefx, I hope you also read my comments below
There are 2 issues here:
Voyager does not support rewrite-target annotation currently. You can achieve the same functionality using the rewriteRule option. But this will require using Voyager's CRD instead of standard ingress. Without path rewrite nginx keeps returning 404. This is tracked here: https://github.com/appscode/voyager/issues/657
In Voyager, the order of rules and paths are important as Voyager will use them in the order provided by user, instead of automatically reordering them. So, if you move the / path to the last, it should do what you expect.
Below is a fully working example that I tested:
kubectl run nginx --image=nginx
kubectl expose deployment nginx --name=web --port=80 --target-port=80
kubectl run test-server --image=appscode/test-server:1.1
kubectl expose deployment test-server --name=exp --port=80 --target-port=8080
kubectl run echoserver --image=gcr.io/google_containers/echoserver:1.4
kubectl expose deployment echoserver --name=rest --port=80 --target-port=8080Ingress YAML using Voyager CRD (note the apiVersion):
apiVersion: voyager.appscode.com/v1beta1
kind: Ingress
metadata:
name: fanout-demo
annotations:
ingress.appscode.com/type: NodePort
ingress.appscode.com/force-service-port: "false"
spec:
rules:
- http:
paths:
- path: /web
backend:
serviceName: web
servicePort: 80
rewriteRules:
- '^([^\ ]*\ /)web(.*) \1\2'
- path: /exp
backend:
serviceName: exp
servicePort: 80
- path: /
backend:
serviceName: rest
servicePort: 80To use the CRD with kubectl, you need to use full resource name: kubectl describe ingress.voyager.appscode.com fanout-demo
Please try it. It should solve your issue.
Edit: - rewrite-target annotations are currently supported by Voyager. (Feb, 2018)