gpt4 book ai didi

bash - 在 Azure 中触发 shell 脚本

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:22:27 25 4
gpt4 key购买 nike

我正在 Azure 中使用运行入口 Controller 的 Kubernetes 集群。入口 Controller 通过给定的上下文根路由到不同的服务。

为了添加另一个服务并将其连接到我的入口,我构建了一个简单的 shell 脚本,如下所示:

kubectl apply -f  $1'-svc.yaml'
some script magic here to add a new route in the hello-world-ingress.json
kubectl apply -f 'hello-world-ingress.json'

我在本地计算机上测试了该脚本,一切都按预期工作。现在我想通过 Azure 上的 HTTP 休息调用来触发脚本。

有人知道如何做到这一点吗?到目前为止我知道:

  1. 我需要带有 Kubernetes 的 Azure cli 来运行 kubectl 命令

  2. 我需要一些东西来构建 HTTP 触发器。我尝试使用 AzureFunctions,但无法在 Azure 门户上的 Azure Functions 中安装 Azure cli,并且无法在 Docker 容器中安装 Azure cli + Azure Functions。

有人知道如何在存在 Azure cli 的环境中通过 Azure 中的 HTTP 触发我的 shell 脚本吗?

最佳答案

在我看来,最简单的方法是使用 kubectl 设置一个 Azure 实例,并将 Azure cli 配置为与您的集群通信,并在同一台服务器上设置类似 shell2http 的内容。 。例如:

shell2http -export-all-vars /mybash "yourbash.sh"
shell2http -form /apply "kubectl apply -f $v'-svc.yaml'"
shell2http -export-all-vars /domore "domore.sh"

其中上面的 $v 是您的部署的名称。

关于bash - 在 Azure 中触发 shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52724985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com