docker - Kubernetes:无法 curl minikube pod

标签 docker deployment kubernetes minikube

发生了什么:
我一直在遵循以下准则: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

我期望发生的事情:
当我 curl pod 时,它应该给出正确的答复(如快速入门: https://kubernetes.io/docs/setup/minikube/ )

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

最佳答案

不确定你从哪里得到的端口 9500 from 但这就是它不起作用的原因。 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-

关于docker - Kubernetes:无法 curl minikube pod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52289583/

相关文章:

javascript - 当我想要 dockerize 我的 nextjs 项目时出现问题

Docker:无法将 docker 容器端口路由到主机

docker - 使用容器名称而不是容器ID保存Docker容器日志

javascript - 如何在 Express [MEAN] 中发送 header

docker - 将 Kubernetes 用于 TileServer-GL 以及自定义配置和样式文件

https - 如果在 kubernetes 中将方案设置为 HTTPS,Liveness 探测器是否会验证证书?

rest - 如何使用 REST API 与 Docker 引擎交互?

go - 无法通过 kubectl logs 命令检索 go 客户端中的 POD 日志

tomcat - 使用 Ant 将简单的 Web 应用程序部署到 Tomcat

azure - Windows 代理池只能使用 Azure-CNI 添加到 AKS 群集