Deploying Kubernetes Application on a Cluster Created with ARM Template and Custom Script Extension

152 views Asked by At

I am working on an offering for the Azure Marketplace of type 'managed application'. I have created an ARM template that deploys an AKS (Azure Kubernetes Service) cluster as part of this offering. The cluster infrastructure is correctly created using the ARM template.

However, I am trying to understand if it is possible to use Azure's Custom Script Extension to deploy my Kubernetes application on the cluster once the infrastructure is in place. I would like to run a script to initialize the environment with the necessary components of the application.

My question is: How to effectively use the Custom Script Extension to deploy a Kubernetes application on an AKS cluster created with an ARM template?

1

There are 1 answers

4
Naveen Sharma On

You can use the Custom Script Extension to run scripts on the AKS cluster deployed via ARM template by packaging your application with your custom script, along with the Kubernetes manifests, into a compressed file so that it is accessible to the nodes later

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

Upload your custom script to your Storage account.

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

Modify your ARM template to include the Custom Script Extension.
enter image description here

Deploy the ARM template from portal or CLI

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>