azure - 如何使用部署在 Azure Kubernetes 服务中的容器化应用从 Postman 访问 API
问题描述
我使用 Node 和 Express 创建了一个示例 API 应用程序,以进行容器化并部署到 Azure Kubernetes 服务 (AKS)。但是,我无法通过从已部署的 service.yml 生成的外部 API 访问 API 端点。
我利用 AKS 中的部署中心将我的应用程序部署到 AKS 并生成相关的 deployment.yml 和 service.yml。以下是包含外部 IP 的运行服务。
以下是邮递员的回复。我尝试过使用或不使用端口号和 IP 地址,kubectl get endpoints
但无济于事。请求最终会超时,无法访问 api。
以下是dockerfile配置
我曾尝试四处寻找解决方案,但无法解决。如果您遇到类似的问题并能够分享您的经验,我将不胜感激,谢谢。
解决方案
From client machine where kubectl is installed do
kubectl get pods -o wide -n restapicluster5ca2
this will give you all the pods with the ip of the Pods
kubectl describe svc restapicluster-bb91 -n restapicluster5ca2
this will give details about the service and then check LoadBalancer Ingress: for the external IP address, Port: for the port to access, TargetPort: the port on the containers to access i.e 5000 in your case, Endpoints: to verify if all IP of the pod with correct port i.e 5000 is displaying or not.
Log into any of the machines in the AKS cluster do the following
curl [CLUSTER-IP]:[PORT]/api/posts i.e curl 10.-.-.67:5000
check if you get the response.
For reference to use kubectl locally with AKS cluster check the links below
推荐阅读
- c++ - 错误:没有匹配的函数调用“getline”
- python - 使用 WX 显示文件路径
- ruby-on-rails - Bootstrap Modal 在使用 Rails 6 应用程序的 Heroku 中导致“Uncaught TypeError: Cannot convert undefined or null to object”错误
- python - 基于 Groupby Python 的条件标志
- hadoop - http://localhost:50070 显示无法连接,但 http://localhost:50030 正在工作
- php - 如何将数组插入数据库?Laravel PHP
- codenameone - 代号一 在多行上垂直对齐组件
- android - React Native 项目没有在 android 模拟器上启动并且没有显示错误
- scilab - 将 SIVP 模块加载到 scilab 时出现错误是否有任何解决方案
- c# - Emgu CV 位图到图像不再工作