docker - K8s:无法卷曲到 POD ID
问题描述
我是 Kubernetes 新手,使用 minikube 在本地机器上尝试了一些东西。我使用创建了一个新的 pod
kubectl run apache --image=httpd:2.2
当我这样做时get pod
,我看到吊舱启动并运行
kubectl get pod
NAME READY STATUS RESTARTS AGE
apache-6dbf894fbc-kc5d8 1/1 Running 0 33m
当我描述 pod 时,我也看到了 pod 的 IP
kubectl get pod apache-6dbf894fbc-kc5d8 -o yaml
...
containerStatuses:
- containerID: docker://b05ca94634b40595b83fcd08bab4c8f3f055dbf5fe821708f72ea464cf758eb4
image: httpd:2.2
imageID: docker-pullable://httpd@sha256:9784d70c8ea466fabd52b0bc8cde84980324f9612380d22fbad2151df9a430eb
lastState: {}
name: apache
ready: true
restartCount: 0
started: true
state:
running:
startedAt: "2020-08-21T15:42:38Z"
hostIP: 172.17.0.2
phase: Running
podIP: 172.18.0.3
podIPs:
- ip: 172.18.0.3
我相信我应该可以 curl 到这个端口,但是操作超时
curl -I 172.18.0.3
curl: (7) Failed to connect to 172.18.0.3 port 80: Operation timed out
我不确定我做错了什么。在我正在阅读的一份文档中,它表明我们应该能够卷曲。
PIP=$(kubectl get pod apache -o jsonpath='{.status.podIP}') && echo $PIP 10.32.0.4
ubuntu@ip-172-31-3-67:~$
ubuntu@ip-172-31-3-67:~$ curl -I $PIP
HTTP/1.1 200 OK
Date: Tue, 18 Feb 2020 20:05:06 GMT
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/1.0.1t DAV/2 Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "c0050-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Content-Type: text/html
ubuntu@ip-172-31-3-67:~$
另外,当我这样做时docker container ls
,我看不到这个容器。再说一次,我一定是错过了什么。
提前感谢所有帮助。
解决方案
首先使用 exec 进入 pod kubectl exec -it pod_name -- /bin/sh
,然后执行curl POD_IP:port
然后你应该看到结果。
推荐阅读
- python - Python字典,返回字典中所有键的恒定复杂方式包含特定字符串
- java - Java 8 从“字符串”值来自自定义对象的每个字段中删除字符串值
- python - 将 Python wtform datetime 与 sqlalchemy 和 sqlite 一起使用的示例
- flutter - Flutter中的Future.delayed与Timer有什么区别
- javascript - 将 PDF 作为 Blob 从 Azure 传递到 Node 以进行 React
- ckeditor - CKEditor 添加
在空 div 中标记
- css - 在 bulma 全高英雄中显示 chartjs 图表
- docker - Gunicorn/Uvicorn 工作人员在 AWS Fargate 上超时
- javascript - 在某些条件下用数组中的字符串更改整数值
- elasticsearch - Ballerina 集成器和 Elasticsearch