【问题标题】:Allow Node.js app to talk to a pod on a Kubernetes Cluster允许 Node.js 应用程序与 Kubernetes 集群上的 pod 通信
【发布时间】:2018-09-28 18:06:48
【问题描述】:

我在 Azure 中有一个 Node.js 应用程序,我希望它能够连接/对话 kubernetes 集群上的一个 pod(这个 pod 有一个外部 IP 并且是一个负载均衡器)。单击我的 Node.js 应用程序上的提交按钮后,我希望能够将 bash 命令发送到 Kubernetes 集群上的 pod。

您知道如何将应用程序连接到 pod 吗?我知道 index.js 文件中有 server.listen 函数,但是我不太确定如何处理这种情况。

感谢您的帮助

【问题讨论】:

    标签: node.js azure load-balancing azure-load-balancer


    【解决方案1】:

    不确定,但您可以像在 Node.js 应用程序中一样连接数据库或其他服务时连接 Kubernetes 集群中的 pod。

    总而言之,您应该通过命令 az aks get-credentials 获取 AKS 的凭据,以创建与 Kubernetes 集群的隧道。然后就可以使用命令kubectl exec在pod中执行bash shell命令了。

    另外,你可以看看Executing commands in Pods using K8s API,也许会有帮助。

    以下是管理 Kubernetes Cluster pod 中的 pod 的示例。见kubernetes-client

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-03
      • 1970-01-01
      • 2018-08-04
      • 2022-06-10
      • 2018-09-18
      • 2019-12-07
      • 2020-11-23
      • 1970-01-01
      相关资源
      最近更新 更多