I'm setting a bare-metal kubernetes cluster for a web application in a google cloud instance, I am connecting to microservices through an ingress controller. How do I access the ingress controller from all incoming hosts?
There is a pod running angular web application and another pod running a node api microservice. Angular Web Application has been exposed globally. When accessing the microservice externally and passing the header with the hostname I was able to get the expected response. On removing the host in the ingress yaml I am not able to access the ingress.
kind: Ingress
metadata:
annotations:
ingress.kubernetes.io/rewrite-target: nginx
creationTimestamp: "2019-08-12T07:41:37Z"
generation: 7
name: test
namespace: default
resourceVersion: "546400"
selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/test
uid: 374836d2-34c3-4053-b0e3-9fe3f63167cc
spec:
rules:
- host: bar.com
http:
paths:
- backend:
serviceName: login-service
servicePort: 3000
path: /login-service
- backend:
serviceName: organization-service
servicePort: 3000
path: /organization-service
status:
loadBalancer:
ingress:
- ip: 10.128.0.16
- ip: 203.0.113.2
I except the ingress to be accessed from all the hosts other than the specified host(bar.com) in ingress.
Any other way to access the API microservice from the outside cluster(globally)?
In order to access the API service From outside the cluster(Globally).
Create a proxy nginx server and expose the port of the nginx proxy server. From the web application server, call a request to the proxy server through the external IP and exposed Port. The proxy server will pass the request to the respected API microservice and return the expected response.
Edit the nginx.conf file.
location /<your_requested_URL> {
proxy_pass http://service_name:port;
}