Skip to content
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
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Release History
===============
0.4.45
+++++
* Add "--aks-custom-headers" for "az aks nodepool add" and "az aks update"

0.4.43
+++++
* Fix issues with monitoring addon enabling with CLI versions 2.4.0+
Expand Down
6 changes: 6 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@
- name: --aad-tenant-id
type: string
short-summary: The ID of an Azure Active Directory tenant.
- name: --aks-custom-headers
type: string
short-summary: Send custom headers. When specified, format should be Key1=Value1,Key2=Value2
examples:
- name: Enable cluster-autoscaler within node count range [1,5]
text: az aks update --enable-cluster-autoscaler --min-count 1 --max-count 5 -g MyResourceGroup -n MyManagedCluster
Expand Down Expand Up @@ -511,6 +514,9 @@
- name: --mode
type: string
short-summary: The mode for a node pool which defines a node pool's primary function. If set as "System", AKS prefers system pods scheduling to node pools with mode `System`. Learn more at https://aka.ms/aks/nodepool/mode.
- name: --aks-custom-headers
type: string
short-summary: Send custom headers. When specified, format should be Key1=Value1,Key2=Value2
"""

helps['aks nodepool scale'] = """
Expand Down
2 changes: 2 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def load_arguments(self, _):
c.argument('disable_pod_security_policy', action='store_true')
c.argument('attach_acr', acr_arg_type, validator=validate_acr)
c.argument('detach_acr', acr_arg_type, validator=validate_acr)
c.argument('aks_custom_headers')

with self.argument_context('aks scale') as c:
c.argument('nodepool_name', type=str,
Expand Down Expand Up @@ -146,6 +147,7 @@ def load_arguments(self, _):
c.argument('spot_max_price', type=float, validator=validate_spot_max_price)
c.argument('labels', nargs='*', validator=validate_nodepool_labels)
c.argument('mode', arg_type=get_enum_type([CONST_NODEPOOL_MODE_SYSTEM, CONST_NODEPOOL_MODE_USER]))
c.argument('aks_custom_headers')

for scope in ['aks nodepool show', 'aks nodepool delete', 'aks nodepool scale', 'aks nodepool upgrade', 'aks nodepool update']:
with self.argument_context(scope) as c:
Expand Down
32 changes: 20 additions & 12 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,15 +1009,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
tier="Paid"
)

headers = {}
if aks_custom_headers is not None:
if aks_custom_headers != "":
for pair in aks_custom_headers.split(','):
parts = pair.split('=')
if len(parts) != 2:
raise CLIError('custom headers format is incorrect')

headers[parts[0]] = parts[1]
headers = get_aks_custom_headers(aks_custom_headers)

# Due to SPN replication latency, we do a few retries here
max_retry = 30
Expand Down Expand Up @@ -1096,7 +1088,8 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
attach_acr=None,
detach_acr=None,
aad_tenant_id=None,
aad_admin_group_object_ids=None):
aad_admin_group_object_ids=None,
aks_custom_headers=None):
update_autoscaler = enable_cluster_autoscaler or disable_cluster_autoscaler or update_cluster_autoscaler
update_acr = attach_acr is not None or detach_acr is not None
update_pod_security = enable_pod_security_policy or disable_pod_security_policy
Expand Down Expand Up @@ -1244,7 +1237,8 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
if aad_admin_group_object_ids is not None:
instance.aad_profile.admin_group_object_ids = _parse_comma_separated_list(aad_admin_group_object_ids)

return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, name, instance)
headers = get_aks_custom_headers(aks_custom_headers)
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, name, instance, custom_headers=headers)


def aks_show(cmd, client, resource_group_name, name): # pylint: disable=unused-argument
Expand Down Expand Up @@ -2071,6 +2065,7 @@ def aks_agentpool_add(cmd, # pylint: disable=unused-argument,too-many-local
spot_max_price=float('nan'),
labels=None,
mode="User",
aks_custom_headers=None,
no_wait=False):
instances = client.list(resource_group_name, cluster_name)
for agentpool_profile in instances:
Expand Down Expand Up @@ -2124,7 +2119,8 @@ def aks_agentpool_add(cmd, # pylint: disable=unused-argument,too-many-local
if node_osdisk_size:
agent_pool.os_disk_size_gb = int(node_osdisk_size)

return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, agent_pool)
headers = get_aks_custom_headers(aks_custom_headers)
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, agent_pool, custom_headers=headers)


def aks_agentpool_scale(cmd, # pylint: disable=unused-argument
Expand Down Expand Up @@ -2677,3 +2673,15 @@ def format_bright(msg):

def format_hyperlink(the_link):
return f'\033[1m{colorama.Style.BRIGHT}{colorama.Fore.BLUE}{the_link}{colorama.Style.RESET_ALL}'


def get_aks_custom_headers(aks_custom_headers=None):
headers = {}
if aks_custom_headers is not None:
if aks_custom_headers != "":
for pair in aks_custom_headers.split(','):
parts = pair.split('=')
if len(parts) != 2:
raise CLIError('custom headers format is incorrect')
headers[parts[0]] = parts[1]
return headers
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open as open1
from setuptools import setup, find_packages

VERSION = "0.4.44"
VERSION = "0.4.45"
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down