【问题标题】:Kubernetes: Can not curl minikube podKubernetes:无法卷曲 minikube pod
【发布时间】:2019-02-16 18:21:21
【问题描述】:

发生了什么: 我一直遵循以下准则:https://kubernetes.io/docs/setup/minikube/ 并且在尝试 curl 应用程序时遇到“连接被拒绝”问题。这是我做的步骤

~~> minikube status
minikube: Stopped
cluster: 
kubectl: 
~~> minikube start
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.
~~> kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=9500
deployment.apps/hello-minikube created
~~> kubectl expose deployment hello-minikube --type=NodePort
service/hello-minikube exposed
~~> kubectl get pod
NAME                              READY     STATUS    RESTARTS   AGE
hello-minikube-79577c5997-24gt8   1/1       Running   0          39s
~~> curl $(minikube service hello-minikube --url)
curl: (7) Failed to connect to 192.168.99.100 port 31779: Connection refused

我预计会发生什么: 当我卷曲 pod 时,它应该会给出正确的回复(如在快速入门中:https://kubernetes.io/docs/setup/minikube/

minikube 日志:https://docs.google.com/document/d/1o2-ebiZTsoCzQNSn_rQSkcuVzOJABmwT2KKzGoUQNiQ/edit

【问题讨论】:

  • 是的,我可以重现此错误。现在正在调查原因……
  • 我喜欢你这篇文章的结构。不错!

标签: docker deployment kubernetes minikube


【解决方案1】:

不确定您从哪里获得端口9500,但这就是它不起作用的原因。 NGINX 服务于端口8080。这应该有效(至少对我有用):

$ kubectl expose deployment hello-minikube \
          --type=NodePort \
          --port=8080 --target-port=8080


$ curl $(minikube service hello-minikube --url)

Hostname: hello-minikube-79577c5997-tf49z

Pod Information:
        -no pod information available-

Server values:
        server_version=nginx: 1.13.3 - lua: 10008

Request Information:
        client_address=172.17.0.1
        method=GET
        real path=/
        query=
        request_version=1.1
        request_scheme=http
        request_uri=http://192.168.64.11:8080/

Request Headers:
        accept=*/*
        host=192.168.64.11:32141
        user-agent=curl/7.54.0

Request Body:
        -no body in request-

【讨论】:

  • 非常感谢您的帮助!我不认为使用不同的端口会导致这样的问题
  • 不客气,请接受此答案为正确答案,以便您知道它可以帮助您解决问题。
猜你喜欢
  • 1970-01-01
  • 2019-06-29
  • 2020-09-01
  • 1970-01-01
  • 2019-03-12
  • 2021-09-17
  • 2018-04-13
  • 2016-12-24
  • 2019-08-26
相关资源
最近更新 更多