kubernetes - 从另一个 pod 连接到 svc 时连接被拒绝
问题描述
我有简单的 python 应用程序
RUN pip install -r requirements.txt
EXPOSE 8000
CMD ["gunicorn", "main:api", "-c", "/app/gunicorn_conf.py" ,"--reload"]
我的gunicorn conf文件在哪里:
import multiprocessing
bind = '0.0.0.0:8000'
workers = multiprocessing.cpu_count() * 2 + 1
timeout = 30
worker_connections = 1000
和我的部署 YAML 文件:
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: test-deployment
spec:
selector:
matchLabels:
app: test-pod
replicas: 1
template:
metadata:
labels:
app: test-pod
spec:
containers:
- name: test-container
image: localhost:5000/test123:v4
ports:
- name: http
containerPort: 8000
---
apiVersion: v1
kind: Service
metadata:
name: test-svc
spec:
ports:
- protocol: TCP
port: 5000
targetPort: http
selector:
app: test-pod
当我从 test-pod 尝试 curl 命令时,它的工作文件
curl -X POST localhost:8000/test
但是当我尝试从其他 pod 卷曲时,我收到连接被拒绝错误。(忙箱吊舱)
curl -X POST test-svc:5000/test
我的 kubectl 描述 svc test-svc
Name: test-svc
Namespace: default
Labels: <none>
Annotations: Selector: app=test-pod
Type: ClusterIP
IP: 10.99.11.154
Port: <unset> 5000/TCP
TargetPort: http/TCP
Endpoints: 10.1.0.11:8000
Session Affinity: None
Events: <none>
nslookup 工作正常
Name: test-svc.default.svc.cluster.local
Address: 10.99.11.154
解决方案
推荐阅读
- ios - 如何在 Swift 中从 AppDelegate 中的其他类访问数组?
- php - 如何在php中创建具有索引的多维数组?
- excel - excel将序列分配给组内的组
- java - 从 IntentService 多次发送结果
- node.js - 在heroku master上推送nodejs应用程序
- gulp - Handlebars 编译一个没有数据在 Gulp 任务中运行的空模板
- algorithm - 4个字符的压缩算法
- python - 如何在此代码 Python 中处理 ValueError?
- shopify - Shopify Image 滑块复制图像
- ssms - 使用 Management Studio 13 将数据库附加到 SQL Server 2016