[英]Unable to access React Application from Minikube
I've a simple HelloWorld ReactJs application Docker image and I created the deployment as:我有一个简单的 HelloWorld ReactJs 应用程序 Docker 映像,我将部署创建为:
kind: Deployment
apiVersion: apps/v1
metadata:
name: minikube-react-app
spec:
replicas: 2
selector:
matchLabels:
app: minikube-react-app
template:
metadata:
labels:
app: minikube-react-app
spec:
containers:
- name: minikube-react-app
image: hello-react:1.0.1
imagePullPolicy: Never
ports:
- containerPort: 80
resources:
requests:
memory: "100Mi"
cpu: "300m"
limits:
memory: "200Mi"
cpu: "600m"
restartPolicy: Always
---
kind: Service
apiVersion: v1
metadata:
name: minikube-react-app
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
protocol: TCP
nodePort: 31000
selector:
app: minikube-react-app
I ran, kubectl apply -f deployent.yaml我跑了,kubectl apply -f deployent.yaml
But when I access http://localhost:31000 it's not working(This site can't be reached).但是当我访问 http://localhost:31000 时它不起作用(无法访问此站点)。
Can someone help me with this please?有人可以帮我吗?
Should use 'node ip' instead of 'localhost' to acccess node port.应该使用“node ip”而不是“localhost”来访问节点端口。
Run shell minikube ip
to obtain ip of minikube node.运行 shell
minikube ip
获取 minikube 节点的 ip。
Check the service type: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types检查服务类型: https : //kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
Run the following command to get the actual address to connect with your app from host machine.运行以下命令以从主机获取与您的应用程序连接的实际地址。
minikube service --url <service-name>
Ref: https://minikube.sigs.k8s.io/docs/handbook/accessing/参考: https : //minikube.sigs.k8s.io/docs/handbook/accessing/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.