Skip to content

Commit 4fa7b8e

Browse files
committed
Add property to MC model
1 parent 45d2f59 commit 4fa7b8e

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@
641641
- name: --vm-sizes
642642
type: string
643643
short-summary: Comma-separated list of sizes. Must use VirtualMachines agent pool type.
644+
- name: --encoded-custom-configuration
645+
type: string
646+
short-summary: Path to JSON file containing custom configuration for the cluster.
644647
examples:
645648
- name: Create a Kubernetes cluster with an existing SSH public key.
646649
text: az aks create -g MyResourceGroup -n MyManagedCluster --ssh-key-value /path/to/publickey

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import copy
88
import datetime
99
import os
10+
import base64
1011
from types import SimpleNamespace
1112
from typing import Any, Dict, List, Optional, Tuple, TypeVar, Union
1213

@@ -2805,6 +2806,24 @@ def get_disable_imds_restriction(self) -> bool:
28052806
"""
28062807
return self.raw_param.get("disable_imds_restriction")
28072808

2809+
def get_encoded_custom_configuration(self) -> bytes:
2810+
"""Obtain the value of encoded_custom_configuration and encode it to base64.
2811+
2812+
:return: str
2813+
"""
2814+
encoded_custom_configuration_file_path = self.raw_param.get("encoded_custom_configuration")
2815+
logger.debug("Custom configuration file path: ", encoded_custom_configuration_file_path)
2816+
if encoded_custom_configuration_file_path:
2817+
if not os.path.isfile(encoded_custom_configuration_file_path):
2818+
raise InvalidArgumentValueError(
2819+
f"{encoded_custom_configuration_file_path} is not valid file, or not accessable."
2820+
)
2821+
with open(encoded_custom_configuration_file_path, "rb") as file:
2822+
file_content = file.read()
2823+
encoded_custom_configuration = base64.b64encode(file_content).decode("utf-8")
2824+
2825+
logger.debug("Encoded custom configuration file content: ", encoded_custom_configuration)
2826+
return encoded_custom_configuration
28082827

28092828
# pylint: disable=too-many-public-methods
28102829
class AKSPreviewManagedClusterCreateDecorator(AKSManagedClusterCreateDecorator):
@@ -3535,6 +3554,19 @@ def set_up_imds_restriction(self, mc: ManagedCluster) -> ManagedCluster:
35353554
mc.network_profile.pod_link_local_access = CONST_IMDS_RESTRICTION_ENABLED
35363555
return mc
35373556

3557+
def set_up_encoded_custom_configuration(self, mc: ManagedCluster) -> ManagedCluster:
3558+
"""Set up custom configuration for the ManagedCluster object.
3559+
3560+
:return: the ManagedCluster object
3561+
"""
3562+
self._ensure_mc(mc)
3563+
3564+
encoded_custom_configuration = self.context.get_encoded_custom_configuration()
3565+
if encoded_custom_configuration:
3566+
mc.encoded_custom_configuration = encoded_custom_configuration
3567+
3568+
return mc
3569+
35383570
# pylint: disable=unused-argument
35393571
def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) -> ManagedCluster:
35403572
"""The overall controller used to construct the default ManagedCluster profile.
@@ -3597,6 +3629,8 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
35973629
mc = self.set_up_static_egress_gateway(mc)
35983630
# set up imds restriction(a property in network profile)
35993631
mc = self.set_up_imds_restriction(mc)
3632+
# set up encoded custom configuration
3633+
mc = self.set_up_encoded_custom_configuration(mc)
36003634

36013635
# validate the azure cli core version
36023636
self.verify_cli_core_version()

src/aks-preview/azext_aks_preview/vendored_sdks/azure_mgmt_preview_aks/v2025_01_02_preview/models/_models_py3.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4165,6 +4165,8 @@ class ManagedCluster(TrackedResource):
41654165
~azure.mgmt.containerservice.v2025_01_02_preview.models.ManagedClusterBootstrapProfile
41664166
:ivar status: Contains read-only information about the Managed Cluster.
41674167
:vartype status: ~azure.mgmt.containerservice.v2025_01_02_preview.models.ManagedClusterStatus
4168+
:ivar encoded_custom_configuration: Encoded custom configuration.
4169+
:vartype encoded_custom_configuration: str
41684170
"""
41694171

41704172
_validation = {
@@ -4266,6 +4268,10 @@ class ManagedCluster(TrackedResource):
42664268
},
42674269
"bootstrap_profile": {"key": "properties.bootstrapProfile", "type": "ManagedClusterBootstrapProfile"},
42684270
"status": {"key": "properties.status", "type": "ManagedClusterStatus"},
4271+
"encoded_custom_configuration": {
4272+
"key": "properties.encodedCustomConfiguration",
4273+
"type": "str",
4274+
},
42694275
}
42704276

42714277
def __init__( # pylint: disable=too-many-locals
@@ -4318,6 +4324,7 @@ def __init__( # pylint: disable=too-many-locals
43184324
node_provisioning_profile: Optional["_models.ManagedClusterNodeProvisioningProfile"] = None,
43194325
bootstrap_profile: Optional["_models.ManagedClusterBootstrapProfile"] = None,
43204326
status: Optional["_models.ManagedClusterStatus"] = None,
4327+
encoded_custom_configuration: Optional[str] = None,
43214328
**kwargs: Any
43224329
) -> None:
43234330
"""
@@ -4472,6 +4479,8 @@ def __init__( # pylint: disable=too-many-locals
44724479
~azure.mgmt.containerservice.v2025_01_02_preview.models.ManagedClusterBootstrapProfile
44734480
:keyword status: Contains read-only information about the Managed Cluster.
44744481
:paramtype status: ~azure.mgmt.containerservice.v2025_01_02_preview.models.ManagedClusterStatus
4482+
:keyword encoded_custom_configuration: Encoded custom configuration.
4483+
:paramtype encoded_custom_configuration: str
44754484
"""
44764485
super().__init__(tags=tags, location=location, **kwargs)
44774486
self.e_tag: Optional[str] = None
@@ -4528,6 +4537,7 @@ def __init__( # pylint: disable=too-many-locals
45284537
self.node_provisioning_profile = node_provisioning_profile
45294538
self.bootstrap_profile = bootstrap_profile
45304539
self.status = status
4540+
self.encoded_custom_configuration = encoded_custom_configuration
45314541

45324542

45334543
class ManagedClusterAADProfile(_serialization.Model):

0 commit comments

Comments
 (0)