I am trying to connect react application that is available through ingress to my kubectl backend service. How should I go about it without exposing the backend with ingress?
Here is the ingress yaml:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
defaultBackend:
service:
name: frontend
port:
number: 80
rules:
- host: myapp-hello.me
- http:
paths:
- path: /frontend
pathType: Prefix
backend:
service:
name: frontend
port:
number: 80
Backend service:
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
default service/backend ClusterIP 10.107.95.144 <none> 5000/TCP
And inside react app:
fetch('http://') // what address to put here?
.then(response => {
response.text().then(text => {
console.log(text);
setData(text);
})
})