【发布时间】:2019-07-20 14:59:43
【问题描述】:
一些简单的背景知识:在 golang 中创建一个应用程序,在 MacOS 10.14.2 上的 minikube 上运行
karlewr [0] $ kubectl version
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.1", GitCommit:"b1b29978270dc22fecc592ac55d903350454310a", GitTreeState:"clean", BuildDate:"2018-07-18T11:37:06Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.4", GitCommit:"f49fa022dbe63faafd0da106ef7e05a29721d3f1", GitTreeState:"clean", BuildDate:"2018-12-14T06:59:37Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}
问题: 我无法通过集群内部的 pod IP 访问我的 pod。这个问题只发生在这个 pod 上,这让我相信我在某处有错误配置。
我的 pod 规格如下:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /ping
port: 8080
initialDelaySeconds: 60
readinessProbe:
httpGet:
path: /ping
port: 8080
initialDelaySeconds: 60
奇怪的是,我可以通过在端口 8080 上转发该 pod 并在 liveness 和 readiness 探针运行之前以及在 pod 初始化之后运行 curl localhost:8080/ping 来访问它。这将返回 200 OK。
同样在 CrashLoopBackoff 之前的这段时间内,如果我 ssh 进入我的 minikube 节点并运行 curl http://172.17.0.21:8080/ping 我会得到 curl: (7) Failed to connect to 172.17.0.21 port 8080: Connection refused。使用的 IP 是我的 pod 的 IP。
但是当我在initialDelaySeconds 期间之后描述 pod 时,我看到了这个:
Warning Unhealthy 44s (x3 over 1m) kubelet, minikube Readiness probe failed: Get http://172.17.0.21:8080/ping: dial tcp 172.17.0.21:8080: connect: connection refused
Warning Unhealthy 44s (x3 over 1m) kubelet, minikube Liveness probe failed: Get http://172.17.0.21:8080/ping: dial tcp 172.17.0.21:8080: connect: connection refused
为什么我的连接只会被 Pod 的 IP 拒绝?
编辑我没有运行任何自定义网络的东西,只是开箱即用的 minikube
【问题讨论】:
标签: docker kubernetes minikube