python - FastApi 使用 Python 将请求从 Kubernetes 内部的一个 api 发布到另一个
问题描述
我在 pod 中使用 FastApi 创建了 2 个 API,我需要一个来连接另一个:我在 API A 中有这样的东西:
@router.post(
"/API-A")
response = requests.post(
"URL I SHOULD ADD BUT IT IS NOT WORKING"
headers={
"content-type": "application/json",
},
verify=False,
data=payload.json
).json()
return response
有人告诉我,由于 API B 部署在 kubernetes 中,我应该调用服务名称而不是 DNS,但是,它似乎不起作用。我试过了:
url= api-service/prices (being prices the endpoint of API B, and api-service the serviceName)
我收到此错误:
Invalid URL 'api-service/prices': No schema supplied.
我做错了吗?这是我第一次在 Kubernetes 中调用 API,所以我真的不知道应该怎么做。
非常感谢您。
解决方案
推荐阅读
- image - Flutter Network Image does not fit in Circular Avatar
- axapta - Update table using only variables
- apache-spark - model.freqItemsets FPGROWTH 算法是 spark 2.4 没有显示完整数据集的任何结果
- android - 像餐厅页面或带有项目重复和标题的回收站视图的 zomato
- javascript - 问题:WebView 中的画布图模糊
- javascript - How to create show the content above the button using toggle?
- php - preg_match or preg_replace to get only number from html code
- java - 在 Java 中强制转换 ArrayList
- javascript - 重置边框样式
- python - 添加具有默认值的缺失日期索引