ansible-collections / azure

Development area for Azure Collections
https://galaxy.ansible.com/azure/azcollection
GNU General Public License v3.0
247 stars 331 forks source link

How to create AKS Agent Nodepool with custom configuration file #1445

Closed aaron-armada closed 5 months ago

aaron-armada commented 8 months ago
SUMMARY

Azure documentation describes how to add a node pool with custom configuration files: https://learn.microsoft.com/en-us/azure/aks/custom-node-configuration?tabs=linux-node-pools#add-a-node-pool-using-custom-configuration-files

I do not see how to do this in either the documentation or source for the azure.azcollection.azure_rm_aksagentpool module.

ISSUE TYPE
COMPONENT NAME

azure_rm_aksagentpool

ANSIBLE VERSION
ansible [core 2.16.3]
  config file = None
  configured module search path = ['/Users/foo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/foo/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.11.7 (main, Dec  4 2023, 18:10:11) [Clang 15.0.0 (clang-1500.1.0.2.5)] (/opt/homebrew/opt/python@3.11/bin/python3.11)
  jinja version = 3.1.3
  libyaml = True
Fred-sun commented 8 months ago

@aaron-armada Do you want to add a node agent pool as follows?


 - name: Create a kubernet service with minimal parameters
  azure_rm_aks:
    name: "min{{ rpfx }}"
    location: eastus
    resource_group: "{{ resource_group }}"
    kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
    dns_prefix: "aks{{ rpfx }}"
    enable_rbac: true
    aad_profile:
      managed: true
    agent_pool_profiles:
      - name: default
        count: 1
        vm_size: Standard_B2s
        mode: System
    api_server_access_profile:
      authorized_ip_ranges:
        - "192.0.2.0"
        - "198.51.100.0"
        - "203.0.113.0"
      enable_private_cluster: false
    network_profile:
      load_balancer_sku: standard
      outbound_type: loadBalancer
  register: output

- name: Add node agent pool
  azure_rm_aksagentpool:
    resource_group: "{{ resource_group }}"
    cluster_name: "min{{ rpfx }}"
    name: default03
    count: 1
    vm_size: Standard_B2s
    type_properties_type: VirtualMachineScaleSets
    mode: System
    node_labels: {"release":"stable"}
    max_pods: 42
    enable_auto_scaling: true
    min_count: 1
    max_count: 10
    orchestrator_version: "{{ agentpool_version.azure_orchestrator_version[0] }}"
    availability_zones:
      - 1
      - 2
  register: output
aaron-armada commented 8 months ago

@aaron-armada Do you want to add a node agent pool as follows?

 - name: Create a kubernet service with minimal parameters
  azure_rm_aks:
    name: "min{{ rpfx }}"
    location: eastus
    resource_group: "{{ resource_group }}"
    kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
    dns_prefix: "aks{{ rpfx }}"
    enable_rbac: true
    aad_profile:
      managed: true
    agent_pool_profiles:
      - name: default
        count: 1
        vm_size: Standard_B2s
        mode: System
    api_server_access_profile:
      authorized_ip_ranges:
        - "192.0.2.0"
        - "198.51.100.0"
        - "203.0.113.0"
      enable_private_cluster: false
    network_profile:
      load_balancer_sku: standard
      outbound_type: loadBalancer
  register: output

- name: Add node agent pool
  azure_rm_aksagentpool:
    resource_group: "{{ resource_group }}"
    cluster_name: "min{{ rpfx }}"
    name: default03
    count: 1
    vm_size: Standard_B2s
    type_properties_type: VirtualMachineScaleSets
    mode: System
    node_labels: {"release":"stable"}
    max_pods: 42
    enable_auto_scaling: true
    min_count: 1
    max_count: 10
    orchestrator_version: "{{ agentpool_version.azure_orchestrator_version[0] }}"
    availability_zones:
      - 1
      - 2
  register: output

No I would like to be able to do something like this:

- name: Add node agent pool
  azure_rm_aksagentpool:
    resource_group: "{{ resource_group }}"
    cluster_name: "min{{ rpfx }}"
    name: default03
    count: 1
    vm_size: Standard_B2s
    type_properties_type: VirtualMachineScaleSets
    mode: System
    node_labels: {"release":"stable"}
    max_pods: 42
    enable_auto_scaling: true
    min_count: 1
    max_count: 10
    orchestrator_version: "{{ agentpool_version.azure_orchestrator_version[0] }}"
    availability_zones:
      - 1
      - 2
    os_config:
      - {"transparentHugePageEnabled": "madvise"}
      - {"transparentHugePageDefrag": "defer+madvise"}
      - {"swapFileSizeMB": 1500}
  register: output
Fred-sun commented 7 months ago

Added in #1477