1. Assigning AKS agent pool with specific virtual machine sizes

    TypeScript

    When working with Azure Kubernetes Service (AKS), an agent pool is a collection of nodes, which are essentially virtual machines that run your applications and services in the Kubernetes cluster. AKS allows you to specify the size of these virtual machines when you create or update an agent pool, so you can match the resources available to your workload needs.

    To define an AKS agent pool with a specific virtual machine size using Pulumi and the TypeScript programming language, you'll want to use the azure-native.containerservice.AgentPool resource. This resource allows you to specify various properties for an agent pool, including the size of the virtual machines (VMs) that will be part of the agent pool (vmSize), the number of nodes (count), and the mode (mode), among other configurations.

    Here is a TypeScript program that demonstrates how to create an AKS agent pool with a specific virtual machine size:

    import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; // Create a new resource group if not using an existing one const resourceGroup = new azure_native.resources.ResourceGroup("myResourceGroup"); // Create a new AKS cluster if not using an existing one const aksCluster = new azure_native.containerservice.ManagedCluster("myAksCluster", { resourceGroupName: resourceGroup.name, agentPoolProfiles: [{ count: 1, vmSize: "Standard_DS2_v2", // This is an example VM size. Adjust as needed. name: "agentpool1", mode: "System", // Possible values include: 'System', 'User', or 'LB' (for load balancer). }], // ... (other required AKS cluster configurations) }); // Create an AKS agent pool with a specific virtual machine size const agentPool = new azure_native.containerservice.AgentPool("myAgentPool", { resourceGroupName: resourceGroup.name, resourceName: aksCluster.name, count: 3, // The number of agent VMs you want in your pool vmSize: "Standard_DS2_v2", // This should be adjusted to your desired VM size mode: "User", // Mode can be "System", "User", or "LB" osType: "Linux", // The operating system type - "Linux" or "Windows" // ... (other optional configurations) }); // Export the kubeconfig to access our cluster export const kubeconfig = aksCluster.kubeConfig;

    In the above program, you will need to provide properties to the ManagedCluster resource such as agentPoolProfiles which defines the configurations for your initial agent pool. The AgentPool resource specifically creates and manages the additional agent pools. Some of the key properties used are:

    • resourceGroupName: Specifies the target resource group's name in which the AKS cluster and agent pool will be deployed.
    • resourceName: Specifies the name of the AKS cluster to which the agent pool will be attached.
    • count: This is the number of desired agent VMs in the pool.
    • vmSize: Here, you define the VM size of the nodes. For instance, "Standard_DS2_v2" specifies a VM size that is small but can be scaled up based on your actual need.
    • mode: Determines whether the pool will contain system nodes, user nodes, or nodes attached to a load balancer.
    • osType: Specifies the operating system type of the agent VMs (Linux or Windows).

    This is just a simple illustration of creating an AKS agent pool with a specific virtual machine size. You might need to specify additional properties based on your requirements.

    Remember to adjust the VM size (vmSize) to the specific size that fits your workload. You can find a list of available sizes here.

    Lastly, the kubeconfig export will provide you with the configuration necessary to connect to your AKS cluster using kubectl or other Kubernetes tooling.