Skip to content
Open
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
9 changes: 9 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,9 @@
long-summary: |
Azure provides a different workload-runtime to enable Kata supported workloads in your nodepools. The following values can be specified:
- "KataVmIsolation" for Kata.
- name: --enable-artifact-streaming
type: bool
short-summary: Enable artifact streaming for VirtualMachineScaleSets managed by a node pool, to speed up the cold-start of containers on a node through on-demand image loading. This option is only valid for Linux nodepools. To use this feature, container images must also enable artifact streaming on ACR. If not specified, the default is false.

examples:
- name: Create a nodepool in an existing AKS cluster with ephemeral os enabled.
Expand Down Expand Up @@ -2168,6 +2171,12 @@
- name: --gpu-driver
type: string
short-summary: Whether to install driver for GPU node pool. Possible values are "Install" or "None".
- name: --enable-artifact-streaming
type: bool
short-summary: Enable artifact streaming for VirtualMachineScaleSets managed by a Linux node pool, to speed up the cold-start of containers on a node through on-demand image loading. To use this feature, container images must also enable artifact streaming on ACR. If not specified, the default is false.
- name: --disable-artifact-streaming
type: bool
short-summary: Disable artifact streaming for VirtualMachineScaleSets managed by a Linux node pool.
examples:
- name: Reconcile the nodepool back to its current state.
text: az aks nodepool update -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster
Expand Down
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
validate_custom_ca_trust_certificates,
validate_bootstrap_container_registry_resource_id,
validate_gateway_prefix_size,
validate_artifact_streaming,
)
from azure.cli.core.commands.parameters import (
edge_zone_type, file_type, get_enum_type,
Expand Down Expand Up @@ -1095,6 +1096,7 @@ def load_arguments(self, _):
c.argument("gateway_prefix_size", type=int, validator=validate_gateway_prefix_size)
c.argument('localdns_config', help='Path to a JSON file to configure the local DNS profile for a new nodepool.')
c.argument('workload_runtime', arg_type=get_enum_type(workload_runtime_types), help="The workload runtime to use on the nodepool.")
c.argument('enable_artifact_streaming', action='store_true', validator=validate_artifact_streaming)

with self.argument_context('aks nodepool update', resource_type=ResourceType.MGMT_CONTAINERSERVICE, operation_group='agent_pools') as c:
c.argument('enable_cluster_autoscaler', options_list=[
Expand Down Expand Up @@ -1128,6 +1130,8 @@ def load_arguments(self, _):
c.argument("if_none_match")
c.argument('localdns_config', help='Path to a JSON file to configure the local DNS profile for a new nodepool.')
c.argument('gpu_driver', arg_type=get_enum_type(gpu_driver_install_modes))
c.argument('enable_artifact_streaming', action='store_true', validator=validate_artifact_streaming)
c.argument('disable_artifact_streaming', action='store_true', validator=validate_artifact_streaming)

with self.argument_context('aks nodepool upgrade') as c:
c.argument('max_surge', validator=validate_max_surge)
Expand Down
17 changes: 17 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,3 +971,20 @@ def validate_gateway_prefix_size(namespace):
raise ArgumentUsageError("--gateway-prefix-size can only be set for Gateway-mode nodepools")
if namespace.gateway_prefix_size < 28 or namespace.gateway_prefix_size > 31:
raise InvalidArgumentValueError("--gateway-prefix-size must be in the range [28, 31]")


def validate_artifact_streaming(namespace):
"""Validates artifact streaming flags for mutual exclusivity and OS support."""
enable_artifact_streaming = getattr(namespace, "enable_artifact_streaming", False)
disable_artifact_streaming = getattr(namespace, "disable_artifact_streaming", False)

if enable_artifact_streaming and disable_artifact_streaming:
raise MutuallyExclusiveArgumentError(
"Cannot specify both --enable-artifact-streaming and --disable-artifact-streaming at the same time."
)

if hasattr(namespace, "os_type") and str(namespace.os_type).lower() == "windows":
if enable_artifact_streaming:
raise ArgumentUsageError('--enable-artifact-streaming can only be set for Linux nodepools')
if disable_artifact_streaming:
raise ArgumentUsageError('--disable-artifact-streaming can only be set for Linux nodepools')
Comment thread
mxj220 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,35 @@ def get_disable_fips_image(self) -> bool:
# read the original value passed by the command
return self.raw_param.get("disable_fips_image")

def get_enable_artifact_streaming(self) -> bool:
"""Obtain the value of enable_artifact_streaming.

:return: bool
"""
# read the original value passed by the command
enable_artifact_streaming = self.raw_param.get("enable_artifact_streaming")
# In create mode, try to read the property value corresponding to the parameter from the `agentpool` object
if self.decorator_mode == DecoratorMode.CREATE:
if (
self.agentpool and
self.agentpool.artifact_streaming_profile is not None and
self.agentpool.artifact_streaming_profile.enabled is not None
):
enable_artifact_streaming = self.agentpool.artifact_streaming_profile.enabled

if enable_artifact_streaming and self.get_disable_artifact_streaming():
raise MutuallyExclusiveArgumentError(
'Cannot specify both --enable-artifact-streaming and --disable-artifact-streaming.'
)
return enable_artifact_streaming
Comment thread
mxj220 marked this conversation as resolved.

def get_disable_artifact_streaming(self) -> bool:
"""Obtain the value of disable_artifact_streaming.
:return: bool
"""

return self.raw_param.get("disable_artifact_streaming")

def get_zones(self) -> Union[List[str], None]:
"""Obtain the value of zones.

Expand Down Expand Up @@ -2188,6 +2217,16 @@ def set_up_gpu_profile(self, agentpool: AgentPool) -> AgentPool:

return agentpool

def set_up_artifact_streaming(self, agentpool: AgentPool) -> AgentPool:
"""Set up artifact streaming property for the AgentPool object."""
self._ensure_agentpool(agentpool)

if self.context.get_enable_artifact_streaming():
if agentpool.artifact_streaming_profile is None:
agentpool.artifact_streaming_profile = self.models.AgentPoolArtifactStreamingProfile() # pylint: disable=no-member
agentpool.artifact_streaming_profile.enabled = True
return agentpool

def set_up_agentpool_gateway_profile(self, agentpool: AgentPool) -> AgentPool:
"""Set up agentpool gateway profile for the AgentPool object.

Expand Down Expand Up @@ -2297,6 +2336,8 @@ def construct_agentpool_profile_default(self, bypass_restore_defaults: bool = Fa
agentpool = self.set_up_gpu_properties(agentpool)
# set up agentpool network profile
agentpool = self.set_up_agentpool_network_profile(agentpool)
# set up artifact streaming
agentpool = self.set_up_artifact_streaming(agentpool)
# set up agentpool pod ip allocation mode
agentpool = self.set_up_pod_ip_allocation_mode(agentpool)
# set up agentpool windows profile
Expand Down Expand Up @@ -2636,6 +2677,23 @@ def update_gpu_profile(self, agentpool: AgentPool) -> AgentPool:

return agentpool

def update_artifact_streaming(self, agentpool: AgentPool) -> AgentPool:
"""Update artifact streaming property for the AgentPool object.
:return: the AgentPool object
"""
self._ensure_agentpool(agentpool)

if self.context.get_enable_artifact_streaming():
if agentpool.artifact_streaming_profile is None:
agentpool.artifact_streaming_profile = self.models.AgentPoolArtifactStreamingProfile() # pylint: disable=no-member
agentpool.artifact_streaming_profile.enabled = True

if self.context.get_disable_artifact_streaming():
if agentpool.artifact_streaming_profile is None:
agentpool.artifact_streaming_profile = self.models.AgentPoolArtifactStreamingProfile() # pylint: disable=no-member
agentpool.artifact_streaming_profile.enabled = False
return agentpool
Comment thread
mxj220 marked this conversation as resolved.

def update_agentpool_profile_default(self, agentpools: List[AgentPool] = None) -> AgentPool:
"""The overall controller used to update AgentPool profile by default.

Expand Down Expand Up @@ -2668,6 +2726,8 @@ def update_agentpool_profile_default(self, agentpools: List[AgentPool] = None) -
agentpool = self.update_localdns_profile(agentpool)
# update gpu profile
agentpool = self.update_gpu_profile(agentpool)
# update artifact streaming
agentpool = self.update_artifact_streaming(agentpool)
return agentpool

def update_agentpool(self, agentpool: AgentPool) -> AgentPool:
Expand Down
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2988,6 +2988,7 @@ def aks_agentpool_add(
gateway_prefix_size=None,
# local DNS
localdns_config=None,
enable_artifact_streaming=False,
):
# DO NOT MOVE: get all the original parameters and save them as a dictionary
raw_parameters = locals()
Expand Down Expand Up @@ -3051,6 +3052,8 @@ def aks_agentpool_update(
# local DNS
localdns_config=None,
gpu_driver=None,
enable_artifact_streaming=False,
disable_artifact_streaming=False,
):
# DO NOT MOVE: get all the original parameters and save them as a dictionary
raw_parameters = locals()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,20 @@ aks nodepool add:
undrainable_node_behavior:
rule_exclusions:
- option_length_too_long
enable_artifact_streaming:
rule_exclusions:
- option_length_too_long
aks nodepool update:
parameters:
undrainable_node_behavior:
rule_exclusions:
- option_length_too_long
enable_artifact_streaming:
rule_exclusions:
- option_length_too_long
disable_artifact_streaming:
rule_exclusions:
- option_length_too_long
aks nodepool upgrade:
parameters:
undrainable_node_behavior:
Expand Down
Loading
Loading