This question is similar to the question but this is more around the path in the rule that can be configured.
The ingress should be able to handle both the internal services and an external service. The Url for the external service should be something like http://host_name:80/es. When the user hits this url, this should be redirected to the external service.
The service definition and the ingress rule are configured as below but it leads to 404. Where am i going wrong?
Ingress rules
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: external-service
annotations:
kubernetes.io/ingress.class: “nginx”
nginx.ingress.kubernetes.io/ingress.class: “nginx”
nginx.ingress.kubernetes.io/ssl-redirect: “false”
spec:
rules:
- host:
http:
paths:
- backend:
serviceName: external-ip
servicePort: 80
path: /es
Service and End Point definitions
apiVersion: v1
kind: Service
metadata:
name: external-ip
spec:
ports:
- name: app
port: 80
protocol: TCP
targetPort: 80
---
apiVersion: v1
kind: Endpoints
metadata:
name: external-ip
subsets:
- addresses:
- ip: <ip to external service>
ports:
- name: app
port: 80
protocol: TCP
It works when i try with the URL http://host_name:80 and the following ingress rule. Please note the difference in the path in the ingress rule.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: external-service
annotations:
kubernetes.io/ingress.class: “nginx”
nginx.ingress.kubernetes.io/ingress.class: “nginx”
nginx.ingress.kubernetes.io/ssl-redirect: “false”
spec:
rules:
- host:
http:
paths:
- backend:
serviceName: external-ip
servicePort: 80
path: /