So, I have an ingress controller routing traffic to three different services, but only one is working, all others are returning 503. INGRESS YAML
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: dev
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
rules:
- host: localhost
http:
paths:
- path: /equip
backend:
serviceName: web-equip-svc-2
servicePort: 18001
- path: /hello
backend:
serviceName: hello-service
servicePort: 80
- path: /equip-ws
backend:
serviceName: web-equip-svc-2
servicePort: 18000
WORKING SVC YAML
apiVersion: v1
kind: Service
metadata:
name: hello-service
namespace: linkerd-test
labels:
app: hello
spec:
type: ClusterIP
selector:
app: hello
ports:
- port: 80
targetPort: 8080
protocol: TCP
NOT WORKING SVC YAML
---
apiVersion: v1
kind: Service
metadata:
name: web-equip-svc-2
namespace: dev
labels:
app: equipment-service
spec:
type: ClusterIP
selector:
app: equipment-service
ports:
- name: "http"
port: 18001
targetPort: 8080
protocol: TCP
- name: "websocket"
port: 18000
targetPort: 8080
protocol: TCP
So, I've already tried to change annotations from ingress, change svc from clusterIP to loadBalancer... and nothing worked, any help would be welcomed
You should keep your services as ClusterIP if you can. The point of the Ingress Controller is to have one centralised ingress into your cluster.
First thing to try
Test your services independently first. (The two that are not working). Exec into another pod that is running, and do:
curl http://web-equip-svc-2:18001
and see if you get a response back going directly to the service rather than via your ingress. If that works fine, then you know its a problem with your ingress rule configuration and/or controller.
If it doesn't work, then you know its just your actual container/pod that is running those two services, and you can focus there and fix the problem there first.
Second thing to try
Simplify your ingress rule. Remove the path for /equip-ws
as a start, and have just your paths for /hello
and for /equip
.
- path: /equip-ws
backend:
serviceName: web-equip-svc-2
servicePort: 18000
Then test http://localhost/hello
and http://localhost/equip
again with the simplified ingress rule changed.
If this works then you know that your two equip paths in your ingress rule are causing issues and you can fix the conflict/issue there.
Finally found the solution, As @Shogan suggested I split the rules on different hosts, but still no success, so instead of using Paths, I added prefixes to the host and it worked.
rules:
- host: hello.localhost
http:
paths:
- path: /hello
backend:
serviceName: hello-service
servicePort: 280
- host: equip.localhost
http:
paths:
- backend:
serviceName: web-equip-svc
servicePort: 18001
- host: ws.equip.localhost
http:
paths:
- backend:
serviceName: web-equip-svc
servicePort: 18000