在使用 ARM 模板和自定义脚本扩展创建的集群上部署 Kubernetes 应用程序

问题描述 投票:0回答:1

我正在为 Azure 市场开发“托管应用程序”类型的产品。我创建了一个 ARM 模板,用于部署 AKS(Azure Kubernetes 服务)集群作为此产品的一部分。使用 ARM 模板正确创建集群基础设施。

但是,我试图了解一旦基础设施到位,是否可以使用 Azure 的自定义脚本扩展在集群上部署我的 Kubernetes 应用程序。我想运行一个脚本来使用应用程序的必要组件初始化环境。

我的问题是:如何有效地使用自定义脚本扩展在使用 ARM 模板创建的 AKS 集群上部署 Kubernetes 应用程序?

azure-aks azure-resource-manager kubernetes-deployment azure-managed-app
1个回答
0
投票

您可以使用自定义脚本扩展在通过 ARM 模板部署的 AKS 集群上运行脚本,方法是将应用程序与自定义脚本以及 Kubernetes 清单一起打包到压缩文件中,以便稍后可供节点访问

tar -czvf sample-app.tar.gz k8s-manifests

#!/bin/bash
wget -O sample-app.tar.gz <URL to your tar or zip>
tar -xzvf sample-app.tar.gz

kubectl apply -f k8s-manifests

将您的自定义脚本上传到您的存储帐户。

az storage blob upload --account-name <your-storage-account-name> --container-name scripts --type block --name deploy.sh --type block --file deploy.sh

修改您的 ARM 模板以包含自定义脚本扩展。
enter image description here

从门户或 CLI 部署 ARM 模板

az deployment group create --resource-group <your-resource-group-name> --template-file azuredeploy.json --parameters storageAccountName=<your-storage-account-name> --parameters storageAccountId=<your-storage-account-id>

© www.soinside.com 2019 - 2024. All rights reserved.