[英]REST api call between two pods in minikube
I'm running a REACT application on top of a minikube cluster which includes frontend and the backend in the same namespace default
.我在 minikube 集群上运行一个 REACT 应用程序,该集群包括相同命名空间default
中的前端和后端。 When frontend send a request to backend, request doesn't reach to the backend.当前端向后端发送请求时,请求不会到达后端。 Load balancing happens via ingress-nginx
.负载平衡通过ingress-nginx
发生。
service for front end...前端服务...
apiVersion: v1
kind: Service
metadata:
name: frontend-service
spec:
type: ClusterIP
selector:
app: frontend-panel
ports:
- port: 3000
targetPort: 3000
Service for backend后端服务
apiVersion: v1
kind: Service
metadata:
name: backend-service
spec:
type: ClusterIP
selector:
app: backend-panel
ports:
- protocol: TCP
port: 8080
targetPort: 8080
Front end is a react application which calls different services which run in side of the same minikube cluster.., Configfile of react.前端是一个 react 应用程序,它调用在同一个 minikube 集群中运行的不同服务..,react 的配置文件。
window.config = {
backend: {
backend_service: "http://backend-service:8080/"
}
}
Result of kubectl describe svc backend-service
. kubectl describe svc backend-service
的结果。
Name: backend-service
Namespace: default
Labels: <none>
Annotations: Selector: app=backend-panel
Type: ClusterIP
IP: 10.106.135.236
Port: <unset> 8080/TCP
TargetPort: 8080/TCP
Endpoints: 172.17.0.10:8080
Session Affinity: None
Events: <none>
Other than "http://backend-service:8080/"
I tried "http://backend-service.default.svc.cluster.local:8080/"
.除了"http://backend-service:8080/"
我试过"http://backend-service.default.svc.cluster.local:8080/"
。 But without failing the request it hangs for a longtime.但是在没有失败请求的情况下,它会挂起很长时间。
Service looks good because it has got POD IP and PORT as Endpoints
.服务看起来不错,因为它有 POD IP 和 PORT 作为Endpoints
。 Verify if you are able to access the pod directly via PODIP and PORT using curl 172.17.0.10:8080
from another pod in the cluster.验证您是否能够从集群中的另一个 pod 使用curl 172.17.0.10:8080
直接通过 PODIP 和 PORT 访问 pod。 If that does not work then there could be two reasons如果这不起作用,那么可能有两个原因
Application is not listening on port 8080
.应用程序未在端口8080
上侦听。 Just specifying containerPort: 8080
in pod yaml does not make the application listen on port 8080
.仅在 pod yaml 中指定containerPort: 8080
不会使应用程序侦听端口8080
。
Application is listening on 127.0.0.1
instead of 0.0.0.0
.应用程序正在侦听127.0.0.1
而不是0.0.0.0
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.