Hello Chaima KHEMIRI,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
Problem
Sequel to your questions, I understand that you are having trouble automating the setup of a local AKS (Azure Kubernetes Service) cluster on Azure Stack HCI with Terraform. Even though you've tried to automate it, the cluster isn't showing up in their infrastructure like it should. To tackle this, you're thinking about using ARM (Azure Resource Manager) templates instead to deploy the AKS cluster on Azure Stack HCI with Terraform.
Scenario
Chaima, an Azure infrastructure engineer, is responsible for managing the deployment of Azure Kubernetes Service (AKS) clusters on Azure Stack HCI. Recently, he encountered challenges automating the creation of local AKS clusters using Terraform. Although he is proficient in using Terraform for managing infrastructure as code, the automation process failed to deploy the AKS clusters locally within the Azure Stack HCI environment. After multiple attempts to troubleshoot the Terraform scripts and configuration, he is exploring alternative approaches to automate the AKS cluster deployment. Considering the robust capabilities of ARM templates for Azure resource deployment, he decides to investigate the feasibility of using ARM templates to provision the AKS clusters on Azure Stack HCI.
Solution
This prescribed solution was based on the scenario given and your questions, while focusing on the problem statement.
Let me start with your question:
Is it possible to achieve this with ARM templates?
Yes, you can definitely use ARM templates to deploy Azure Kubernetes Service (AKS) clusters on Azure Stack HCI. ARM templates provide a declarative way to define the infrastructure and resources that you want to deploy in Azure.
Another of question:
How to create cluster AKS on Azure stack HCI with ARM template?
- In the Azure portal, navigate to the Marketplace page.
- Select your desired AKS application.
- Choose the required plan and go to the Usage Information + Support tab.
- Copy the values for publisherID, productID, and planID. You’ll need these later.
- In the Azure portal, navigate to the Marketplace page.
- Select your desired AKS application.
- Choose the required plan and go to the Usage Information + Support tab.
- Copy the values for
publisherID,
productID,
andplanID
. You’ll need these later. - Select the Create button and fill out the application details.
- At the bottom of the Review + Create tab, click Download a template for automation. This will give you the ARM template in JSON format.
- Save the ARM template to a file on your computer.
This is an example of how you can create an AKS cluster on Azure Stack HCI using an ARM template, you will need to change the parameter to your :
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"clusterName": {
"type": "string",
"defaultValue": "myAKSCluster"
},
"nodeCount": {
"type": "int",
"defaultValue": 1
},
"nodeVMSize": {
"type": "string",
"defaultValue": "Standard_K8S3_v1"
},
"osType": {
"type": "string",
"defaultValue": "Linux"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.ContainerService/managedClusters",
"apiVersion": "2021-02-01",
"name": "[parameters('clusterName')]",
"location": "[resourceGroup().location]",
"properties": {
"kubernetesVersion": "1.20.7",
"agentPoolProfiles": [
{
"name": "nodepool1",
"count": "[parameters('nodeCount')]",
"vmSize": "[parameters('nodeVMSize')]",
"osType": "[parameters('osType')]"
}
]
}
}
],
"outputs": {}
}
Finally
Before deploying the AKS cluster, you need to accept its terms and agreements. You can do this using either Azure CLI or Azure PowerShell:
- Using Azure CLI:
az vm image terms accept --offer <Product ID> --plan <Plan ID> --publisher <Publisher ID>
- OR Using Azure PowerShell:
Get-AzureRmMarketplaceTerms -Publisher <Publisher ID> -Product <Product ID> -Name <Plan ID>
Replace <Product ID>
, <Plan ID>
, and <Publisher ID>
with the values you copied earlier.
References
Source: Deploy an Azure Kubernetes application by using an ARM template. https://learn.microsoft.com/en-us/azure/aks/deploy-application-template. Accessed. 5/9/2024.
Source: Setup Azure Kubernetes Cluster (AKS) in Cloud Accessed. 5/9/2024.
Also, read further the additional resources and training available by the right side of this page.
Accept Answer
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam NR.