为什么无法访问我在 Minikube 中 运行 的 gRPC REST 服务?
Why can't access my gRPC REST service that is running in Minikube?
最近在学习Kubernetes,遇到这个小问题。对于一些健全性检查,这里是我的 grpc 应用程序 运行ning 在本地的功能:
> docker run -p 8080:8080 -it olamai/simulation:0.0.1
< omitted logs >
> curl localhost:8080/v1/todo/all
{"api":"v1","toDos":[{}]}
原来如此!我现在要做的就是将它部署在 Minikube 中并公开端口,以便我可以调用它。我的最终目标是将它部署到 GKE 或 Azure 集群并从那里调用它(同样,只是为了学习和掌握一切。)
Here is the yaml I'm using to deploy to minikube
这就是我 运行 在 minikube 上部署它的原因
> kubectl create -f deployment.yaml
然后我运行这个得到url
> minikube service sim-service --url
http://192.168.99.100:30588
但这就是我调用它时发生的情况
> curl http://192.168.99.100:30588/v1/todo/all
curl: (7) Failed to connect to 192.168.99.100 port 30588: Connection refused
我做错了什么?
编辑:我明白了,您应该能够在链接文件中看到更新。我将拉取策略设置为从不,所以它已经过时
我现在有一个新问题...我现在可以在 minikube 中创建部署(没有 NodePort)并且仍然调用 api...部署不需要用于公开端口的 NodePort 服务?
我检查了你的 yaml 文件,它工作正常。但只有我意识到你为你的服务设置了 2 种类型,LoadBalancer
和不需要的 NodePort
。
就像您从 LoadBalancer 的 this documentation 定义中检查一样,您会看到
LoadBalancer: Exposes the service externally using a cloud provider’s
load balancer. NodePort and ClusterIP services, to which the external
load balancer will route, are automatically created.
作为下一个问题的答案,您可能将 type: LoadBalancer
放入部署 yaml 文件,这就是您无论如何都能看到 NodePort 的原因。
如果您将 type: ClusterIP
放入您的 yaml,则服务将仅在集群内公开,您将无法访问集群外的服务。
来自同一个 documentation:
ClusterIP: Exposes the service on a cluster-internal IP. Choosing this
value makes the service only reachable from within the cluster. This
is the default ServiceType
最近在学习Kubernetes,遇到这个小问题。对于一些健全性检查,这里是我的 grpc 应用程序 运行ning 在本地的功能:
> docker run -p 8080:8080 -it olamai/simulation:0.0.1
< omitted logs >
> curl localhost:8080/v1/todo/all
{"api":"v1","toDos":[{}]}
原来如此!我现在要做的就是将它部署在 Minikube 中并公开端口,以便我可以调用它。我的最终目标是将它部署到 GKE 或 Azure 集群并从那里调用它(同样,只是为了学习和掌握一切。)
Here is the yaml I'm using to deploy to minikube
这就是我 运行 在 minikube 上部署它的原因
> kubectl create -f deployment.yaml
然后我运行这个得到url
> minikube service sim-service --url
http://192.168.99.100:30588
但这就是我调用它时发生的情况
> curl http://192.168.99.100:30588/v1/todo/all
curl: (7) Failed to connect to 192.168.99.100 port 30588: Connection refused
我做错了什么?
编辑:我明白了,您应该能够在链接文件中看到更新。我将拉取策略设置为从不,所以它已经过时
我现在有一个新问题...我现在可以在 minikube 中创建部署(没有 NodePort)并且仍然调用 api...部署不需要用于公开端口的 NodePort 服务?
我检查了你的 yaml 文件,它工作正常。但只有我意识到你为你的服务设置了 2 种类型,LoadBalancer
和不需要的 NodePort
。
就像您从 LoadBalancer 的 this documentation 定义中检查一样,您会看到
LoadBalancer: Exposes the service externally using a cloud provider’s load balancer. NodePort and ClusterIP services, to which the external load balancer will route, are automatically created.
作为下一个问题的答案,您可能将 type: LoadBalancer
放入部署 yaml 文件,这就是您无论如何都能看到 NodePort 的原因。
如果您将 type: ClusterIP
放入您的 yaml,则服务将仅在集群内公开,您将无法访问集群外的服务。
来自同一个 documentation:
ClusterIP: Exposes the service on a cluster-internal IP. Choosing this value makes the service only reachable from within the cluster. This is the default ServiceType