Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link_to_subnet and link_to_pod_subnet for aks deployments #1184

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nricciar
Copy link

@nricciar nricciar commented Feb 3, 2025

The changes in this PR are as follows:

  • adds link_to_subnet to agent pool config
  • adds link_to_pod_subnet to agent pool config

I have read the contributing guidelines and have completed the following:

  • Tested my code end-to-end against a live Azure subscription.
  • Updated the documentation in the docs folder for the affected changes.
  • Written unit tests against the modified code that I have made.
  • Updated the release notes with a new entry for this PR.
  • Checked the coding standards outlined in the contributions guide and ensured my code adheres to them.

If I haven't completed any of the tasks above, I include the reasons why here:

Below is a minimal example configuration that includes the new features, which can be used to deploy to Azure:

#r "nuget:Farmer"

open System
open System.IO
open Farmer
open Farmer.Arm.ContainerService
open Farmer.Builders
open Farmer.ContainerService

type AksDeploymentRequestV1 =
    { ManagementResourceGroupName: string
      TenantMsi: UserAssignedIdentityConfig
      PodSubnet: ResourceId
      NodeSubnet: ResourceId }

type KubenetBuilder() =
    inherit NetworkProfileBuilder()

    member _.Yield = {
        NetworkPlugin = Some ContainerService.NetworkPlugin.AzureCni
        LoadBalancerSku = None
        DnsServiceIP = None
        DockerBridgeCidr = None
        ServiceCidr = None
    }

let aksResourceV1 (req: AksDeploymentRequestV1) =
    let networkProfile = KubenetBuilder()
    aks {
        name $"{req.ManagementResourceGroupName}-aks"
        tier Tier.Standard
        service_principal_use_msi
        add_identity req.TenantMsi
        kubelet_identity req.TenantMsi
        network_profile networkProfile.Yield
        enable_workload_identity
        enable_image_cleaner
        enable_private_cluster
        dns_prefix "aks"
        add_agent_pools
            [ agentPool {
                  name "systempool"
                  count 2
                  disk_size 128<Gb>
                  add_availability_zones [ "1"; "2"; "3" ]
                  vm_size (Vm.CustomImage "Standard_D2s_v3")
                  link_to_subnet req.NodeSubnet
                  link_to_pod_subnet req.PodSubnet
              }
              agentPool {
                  name "userpool"
                  user_mode
                  disk_size 128<Gb>
                  add_availability_zones [ "1"; "2"; "3" ]
                  enable_autoscale
                  autoscale_min_count 2
                  autoscale_max_count 4
                  vm_size (Vm.CustomImage "Standard_D4s_v3")
                  link_to_subnet req.NodeSubnet
                  link_to_pod_subnet req.PodSubnet
              } ]
    }

let msi = userAssignedIdentity { name "aks-rg-msi" }
let aksDeploy = 
    { ManagementResourceGroupName = "aks-rg"
      TenantMsi = msi
      PodSubnet = Arm.Network.subnets.resourceId (ResourceName "aks-rg", ResourceName "aksPod" )
      NodeSubnet = Arm.Network.subnets.resourceId (ResourceName "aks-rg", ResourceName "aksNode" ) }

arm {
    location Location.EastUS2
    add_resources [
        msi
        aksResourceV1 aksDeploy
    ]
}
|> Writer.quickWrite "aks-on-vnet"

@Larocceau Larocceau requested a review from ninjarobot February 7, 2025 16:05
@ninjarobot ninjarobot added this to the 1.9.12 milestone Feb 8, 2025
@@ -186,6 +186,8 @@ type ManagedCluster = {
AvailabilityZones: string list
VirtualNetworkName: ResourceName option
SubnetName: ResourceName option
Copy link
Collaborator

@ninjarobot ninjarobot Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should replace the existing SubnetName and PodSubnetName with these new properties rather than duplicating them. Otherwise both can be set and it's not clear from the record what will be happen (people will have to reverse engineer the code to see SubnetName takes precedence over Subnet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants