Skip to content

Commit

Permalink
Merge pull request #1170 from mafteiu/aks-features-scaling
Browse files Browse the repository at this point in the history
Aks features: SKU, pod subnet and node pool autoscaling
  • Loading branch information
ninjarobot authored Dec 6, 2024
2 parents d81de41 + a7a6264 commit 77273c7
Show file tree
Hide file tree
Showing 8 changed files with 814 additions and 680 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Release Notes
- Support gallery references for VMs (`operating_system`)
- Support for VM/VMSS security profile options (#1163)

## 1.9.7
- AKS Cluster: support for Sku and Tier. Support for pod subnet in agent pool config. Support for node pool autoscaling

## 1.9.6
- Network Interface: Support for adding Network Security Group (NSG) to Network Interface (NIC)

Expand Down
35 changes: 22 additions & 13 deletions docs/content/api-overview/resources/aks-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ The AKS builder (`aks`) constructs AKS clusters.
| Keyword | Purpose |
|-------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
| name | Sets the name of the AKS cluster. |
| sku | Specifies the SKU of the AKS cluster - default is 'Base'. |
| tier | Specifies the tier of the AKS cluster - default is 'Free'. |
| dns_prefix | Sets the DNS prefix of the AKS cluster. |
| enable_defender | Enables Defender for the containers running in the cluster. |
| enable_image_cleaner | Enables a service to periodically purge images that are no longer used. |
Expand Down Expand Up @@ -43,18 +45,23 @@ The AKS builder (`aks`) constructs AKS clusters.
#### Agent Pool Builder keywords
The Agent Pool builder (`agentPool`) constructs agent pools in the AKS cluster.

| Keyword | Purpose |
|-------------|--------------------------------------------------------------------------------------------------|
| name | Sets the name of the agent pool. |
| count | Sets the count of VM's in the agent pool. |
| user_mode | Sets the agent pool to user mode. |
| disk_size | Sets the disk size for the VM's in the agent pool. |
| enable_fips | Uses a FIPS compliant OS image for VM's in the agent pool. |
| max_pods | Sets the maximum number of pods in the agent pool. |
| os_type | Sets the OS type of the VM's in the agent pool. |
| subnet | Sets the name of a virtual network subnet where this AKS cluster should be attached. |
| vm_size | Sets the size of the VM's in the agent pool. |
| vnet | Sets the name of a virtual network in the same region where this AKS cluster should be attached. |
| Keyword | Purpose |
|-----------------------------------|--------------------------------------------------------------------------------------------------|
| name | Sets the name of the agent pool. |
| count | Sets the count of VM's in the agent pool. |
| user_mode | Sets the agent pool to user mode. |
| disk_size | Sets the disk size for the VM's in the agent pool. |
| enable_fips | Uses a FIPS compliant OS image for VM's in the agent pool. |
| max_pods | Sets the maximum number of pods in the agent pool. |
| os_type | Sets the OS type of the VM's in the agent pool. |
| pod_subnet | Sets the name of a virtual network subnet where this AKS cluster should be attached. |
| subnet | Sets the name of a virtual network subnet where this AKS cluster should be attached. |
| vm_size | Sets the size of the VM's in the agent pool. |
| vnet | Sets the name of a virtual network in the same region where this AKS cluster should be attached. |
| enable_autoscale | Enables node pool autoscale |
| autoscale_scale_down_mode | Optional. Use with enable_autoscaling. Options are Delete and Deallocate |
| autoscale_min_count | Use with enable_autoscaling. Minimum node count in node pool |
| autoscale_max_count | Use with enable_autoscaling. Maximum node count in node pool |

#### Kubenet Builder
The Kubenet builder (`kubenetNetworkProfile`) creates Kubenet network profiles on the AKS cluster.
Expand All @@ -77,6 +84,7 @@ The CNI builder (`azureCniNetworkProfile`) creates Azure CNI network profiles on

The simplest cluster uses a system assigned managed identity and
default settings for the node pool (size of 3).
The pricing tier is 'Free'.

```fsharp
open Farmer
Expand All @@ -89,10 +97,11 @@ let myAks = aks {
}
```

#### Customizing agent pool and network profile
#### Standard pricing tier. Customizing agent pool and network profile
```fsharp
let myAks = aks {
name "k8s-cluster"
tier Tier.Standard
dns_prefix "testaks"
add_agent_pools [
agentPool {
Expand Down
1 change: 1 addition & 0 deletions samples/scripts/aks.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ let msi = userAssignedIdentity { name "aks-user" }
let makeAks (n: int) =
aks {
name (aksName n)
tier Tier.Standard
dns_prefix (aksDns n)
enable_rbac
add_identity msi
Expand Down
26 changes: 26 additions & 0 deletions src/Farmer/Arm/ContainerService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Farmer.Arm.ContainerService

open Farmer
open Farmer.Identity
open Farmer.ContainerService
open Farmer.Vm

let managedClusters =
Expand Down Expand Up @@ -160,8 +161,13 @@ type SecurityProfileSettings = {
WorkloadIdentity = None
}

type ScaleDownMode =
| Delete
| Deallocate

type ManagedCluster = {
Name: ResourceName
Sku: ContainerServiceSku
Location: Location
Dependencies: ResourceId Set
/// Dependencies that are expressed in ARM functions instead of a resource Id
Expand All @@ -179,6 +185,11 @@ type ManagedCluster = {
VmSize: VMSize
VirtualNetworkName: ResourceName option
SubnetName: ResourceName option
PodSubnetName: ResourceName option
AutoscaleSetting: FeatureFlag option
ScaleDownMode: ScaleDownMode option
MinCount: int option
MaxCount: int option
|} list
DnsPrefix: string
EnableRBAC: bool
Expand Down Expand Up @@ -247,6 +258,10 @@ type ManagedCluster = {
this.DependencyExpressions |> Seq.map (fun r -> r.Eval())
]
|> Seq.concat
sku = {|
name = this.Sku.Name.ArmValue
tier = this.Sku.Tier.ArmValue
|}
identity = // If using MSI but no identity was set, then enable the system identity like the CLI
if
this.ServicePrincipalProfile.ClientId = "msi"
Expand Down Expand Up @@ -284,6 +299,17 @@ type ManagedCluster = {
match agent.VirtualNetworkName, agent.SubnetName with
| Some vnet, Some subnet -> subnets.resourceId(vnet, subnet).Eval()
| _ -> null
podSubnetID =
match agent.VirtualNetworkName, agent.PodSubnetName with
| Some vnet, Some pod_subnet -> subnets.resourceId(vnet, pod_subnet).Eval()
| _ -> null
enableAutoScaling = agent.AutoscaleSetting |> Option.mapBoxed _.AsBoolean
scaleDownMode =
match agent.ScaleDownMode with
| Some scaledownmode -> string scaledownmode
| _ -> null
minCount = agent.MinCount |> Option.toNullable
maxCount = agent.MaxCount |> Option.toNullable
|})
dnsPrefix = this.DnsPrefix
enableRBAC = this.EnableRBAC
Expand Down
Loading

0 comments on commit 77273c7

Please sign in to comment.