How to create cluster aks on azure stack hci with arm template

Chaima KHEMIRI 0 Reputation points
2024-05-09T17:59:24.4766667+00:00

I always create a local AKS (Azure Kubernetes Service) cluster on Azure Stack HCI using the command New-AksHciCluster -name mycluster -nodePoolName nodepool1 -nodeCount 1 -nodeVmSize Standard_K8S3_v1 -osType linux. However, when attempting to automate this process with Terraform, the cluster isn't being created locally in my infrastructure. As an alternative, I'm considering using ARM (Azure Resource Manager) templates. Is it possible to achieve this with ARM templates?

Azure Stack HCI
Azure Stack HCI
A hyperconverged infrastructure operating system delivered as an Azure service that provides security, performance, and feature updates.
367 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,166 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,292 questions
Azure Kubernetes Service Edge Essentials
Azure Kubernetes Service Edge Essentials
An on-premises implementation of Azure Kubernetes Service that automates running containerized apps at scale on lightweight PC-class devices.
5 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 12,816 Reputation points
    2024-05-09T23:01:31.9733333+00:00

    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, and planID. 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.

    0 comments No comments

  2. Sinn, Gunnar 0 Reputation points
    2024-11-13T08:27:34.1233333+00:00

    HI, I am ultimately interested in rather deploying the ARC AKS cluster on azure HCI STACK using terraform instead, what is the status on that, what provider can be used and is it maintained frequently? Can you pls share some reference material? I understand from situation in May that you had challenges with usage of TF, has that been finally resolved? Rgds

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.