bash - 在 Azure 中触发 shell 脚本
问题描述
我在 Azure 中使用运行入口控制器的 Kubernetes 集群。入口控制器通过给定的上下文根路由到不同的服务。
为了添加另一个服务并将其连接到我的入口,我构建了一个简单的 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 休息调用来触发脚本。
有谁知道如何做到这一点?到目前为止我知道:
我需要带有 Kubernetes 的 Azure cli 来运行 kubectl 命令
我需要一些东西来构建 HTTP 触发器。我尝试使用 AzureFunctions,但无法在 Azure 门户上的 Azure Functions 中安装 Azure cli,也无法在 Docker 容器中安装 Azure cli + Azure Functions。
有谁知道如何在 Azure cli 存在的环境中通过 Azure 中的 HTTP 触发我的 shell 脚本?
解决方案
在我看来,最简单的方法是设置一个 Azure 实例,kubectl
并将 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
是您的部署的名称。
推荐阅读
- c# - 删除其他进程使用的文件
- java - 在 JFrame 中与棋子的交互
- apache-kafka - 寻找云功能替代品——Kafka
- awk - AWK FS 仅使用第一个实例并忽略其余实例
- python - 如果在本地导入中引用了一个类,Python `exec()` 将无法加载该类
- android - 在 Fragment/Activity 中持有 ViewDataBinding 的引用导致内存泄漏
- python - 有没有办法跳过 AttributeError: 'NoneType' object has no attribute 'parent'
- database - 删除表记录时如何保存用户信息(谁,何时,为什么)?
- excel - 通过 VBA & XMLHttpRequest 选择属性值
- python-3.x - Python strptime() 格式不正确