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 new paramter node_labels for agent_pool #577

Merged
merged 2 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions plugins/modules/azure_rm_aks.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
- 'System'
- 'User'
type: str
node_labels:
description:
- Agent pool node labels to be persisted across all nodes in agent pool.
type: dict
vnet_subnet_id:
description:
- Specifies the VNet's subnet identifier.
Expand Down Expand Up @@ -333,6 +337,7 @@
os_disk_size_gb: Null
os_type: Linux
moode: System
node_labels: { "environment": "dev", "release": "stable" }
ports: Null
storage_profile: ManagedDisks
vm_size: Standard_B2s
Expand Down Expand Up @@ -462,6 +467,7 @@ def create_agent_pool_profiles_dict(agentpoolprofiles):
mode=profile.mode,
enable_auto_scaling=profile.enable_auto_scaling,
max_count=profile.max_count,
node_labels=profile.node_labels,
min_count=profile.min_count,
max_pods=profile.max_pods
) for profile in agentpoolprofiles] if agentpoolprofiles else None
Expand Down Expand Up @@ -519,6 +525,7 @@ def create_addon_profiles_spec():
mode=dict(type='str', choice=['System', 'User'], requried=True),
enable_auto_scaling=dict(type='bool'),
max_count=dict(type='int'),
node_labels=dict(type='dict'),
min_count=dict(type='int'),
max_pods=dict(type='int')
)
Expand Down Expand Up @@ -740,6 +747,7 @@ def compare_addon(origin, patch, config):
enable_auto_scaling = profile_self['enable_auto_scaling']
mode = profile_self['mode']
max_count = profile_self['max_count']
node_labels = profile_self['node_labels']
min_count = profile_self['min_count']
max_pods = profile_self['max_pods']

Expand Down Expand Up @@ -775,6 +783,9 @@ def compare_addon(origin, patch, config):
elif mode is not None and profile_result['mode'] != mode:
self.log(("Agent Profile Diff - Origin {0} / Update {1}".format(str(profile_result), str(profile_self))))
to_be_updated = True
elif node_labels is not None and profile_result['node_labels'] != node_labels:
self.log(("Agent Profile Diff - Origin {0} / Update {1}".format(str(profile_result), str(profile_self))))
to_be_updated = True
if not matched:
self.log("Agent Pool not found")
to_be_updated = True
Expand Down Expand Up @@ -888,6 +899,7 @@ def create_update_agentpool(self, to_update_name_list):
vm_size=profile["vm_size"],
os_disk_size_gb=profile["os_disk_size_gb"],
max_count=profile["max_count"],
node_labels=profile["node_labels"],
min_count=profile["min_count"],
max_pods=profile["max_pods"],
enable_auto_scaling=profile["enable_auto_scaling"],
Expand Down
51 changes: 51 additions & 0 deletions tests/integration/targets/azure_rm_aks/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
vm_size: Standard_B2s
type: VirtualMachineScaleSets
mode: System
node_labels: {"release":"stable"}
max_pods: 42
availability_zones:
- 1
Expand Down Expand Up @@ -66,6 +67,7 @@
vm_size: Standard_B2s
type: VirtualMachineScaleSets
mode: System
node_labels: {"release":"stable"}
max_pods: 42
availability_zones:
- 1
Expand Down Expand Up @@ -95,6 +97,55 @@
- fact.aks[0].id == output.id
- fact.aks[0].properties.agentPoolProfiles[0].availabilityZones == ["1", "2"]
- fact.aks[0].properties.agentPoolProfiles[0].mode == "System"
- fact.aks[0].properties.agentPoolProfiles[0].nodeLabels | length == 1

- name: Update an AKS instance node_labels
azure_rm_aks:
name: "aks{{ rpfx }}"
resource_group: "{{ resource_group }}"
location: eastus
dns_prefix: "aks{{ rpfx }}"
kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
service_principal:
client_id: "{{ azure_client_id }}"
client_secret: "{{ azure_secret }}"
linux_profile:
admin_username: azureuser
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
agent_pool_profiles:
- name: default
count: 1
vm_size: Standard_B2s
type: VirtualMachineScaleSets
mode: System
node_labels: {"release":"stable", "environment":"dev"}
max_pods: 42
availability_zones:
- 1
- 2
node_resource_group: "node{{ noderpfx }}"
enable_rbac: yes
network_profile:
load_balancer_sku: standard
register: output

- name: Assert the AKS instance is well update
assert:
that:
- output.changed

- name: Get AKS fact
azure_rm_aks_info:
name: "aks{{ rpfx }}"
resource_group: "{{ resource_group }}"
register: fact

- name: Assert fact returns the created one
assert:
that:
- "fact.aks | length == 1"
- fact.aks[0].id == output.id
- fact.aks[0].properties.agentPoolProfiles[0].nodeLabels | length == 2

- name: Get AKS upgrade versions
azure_rm_aksupgrade_info:
Expand Down