Skip to content

Commit

Permalink
feat: Support shared slb probe (#7435)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilo19 committed Apr 9, 2024
1 parent a50ac71 commit 9448fdb
Show file tree
Hide file tree
Showing 11 changed files with 834 additions and 4 deletions.
6 changes: 6 additions & 0 deletions linter_exclusions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ aks create:
enable_network_observability:
rule_exclusions:
- option_length_too_long
cluster_service_load_balancer_health_probe_mode:
rule_exclusions:
- option_length_too_long
aks update:
parameters:
aad_admin_group_object_ids:
Expand Down Expand Up @@ -204,6 +207,9 @@ aks update:
disable_network_observability:
rule_exclusions:
- option_length_too_long
cluster_service_load_balancer_health_probe_mode:
rule_exclusions:
- option_length_too_long
arcdata dc create:
parameters:
logs_ui_private_key_file:
Expand Down
1 change: 1 addition & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to

Pending
+++++++
* Support cluster service health probe mode by `--cluster-service-load-balancer-health-probe-mode {Shared, Servicenodeport}`

3.0.0b1
+++++++
Expand Down
4 changes: 4 additions & 0 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,7 @@
# Dns zone contributor role
CONST_PRIVATE_DNS_ZONE_CONTRIBUTOR_ROLE = "Private DNS Zone Contributor"
CONST_DNS_ZONE_CONTRIBUTOR_ROLE = "DNS Zone Contributor"

# Cluster service health probe mode
CONST_CLUSTER_SERVICE_HEALTH_PROBE_MODE_SERVICE_NODE_PORT = "Servicenodeport"
CONST_CLUSTER_SERVICE_HEALTH_PROBE_MODE_SHARED = "Shared"
8 changes: 8 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@
type: string
short-summary: Load balancer backend pool type.
long-summary: Load balancer backend pool type, supported values are nodeIP and nodeIPConfiguration.
- name: --cluster-service-load-balancer-health-probe-mode
type: string
short-summary: Set the cluster service health probe mode.
long-summary: Set the cluster service health probe mode. Default is "Servicenodeport".
- name: --nat-gateway-managed-outbound-ip-count
type: int
short-summary: NAT gateway managed outbound IP count.
Expand Down Expand Up @@ -791,6 +795,10 @@
type: string
short-summary: Load balancer backend pool type.
long-summary: Load balancer backend pool type, supported values are nodeIP and nodeIPConfiguration.
- name: --cluster-service-load-balancer-health-probe-mode
type: string
short-summary: Set the cluster service health probe mode.
long-summary: Set the cluster service health probe mode. Default is "Servicenodeport".
- name: --nat-gateway-managed-outbound-ip-count
type: int
short-summary: NAT gateway managed outbound IP count.
Expand Down
17 changes: 15 additions & 2 deletions src/aks-preview/azext_aks_preview/_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def update_load_balancer_profile(
outbound_ports,
idle_timeout,
backend_pool_type,
health_probe_mode,
profile,
models,
):
Expand All @@ -29,8 +30,9 @@ def update_load_balancer_profile(
outbound_ip_prefixes,
outbound_ports,
idle_timeout,
backend_pool_type,
health_probe_mode,
)
or backend_pool_type
):
return profile
if not profile:
Expand All @@ -49,6 +51,7 @@ def update_load_balancer_profile(
outbound_ports,
idle_timeout,
backend_pool_type,
health_probe_mode,
profile,
models,
)
Expand All @@ -62,6 +65,7 @@ def create_load_balancer_profile(
outbound_ports,
idle_timeout,
backend_pool_type,
health_probe_mode,
models,
):
"""parse and build load balancer profile"""
Expand All @@ -73,8 +77,9 @@ def create_load_balancer_profile(
outbound_ip_prefixes,
outbound_ports,
idle_timeout,
backend_pool_type,
health_probe_mode,
)
or backend_pool_type
):
return None
if isinstance(models, SimpleNamespace):
Expand All @@ -92,6 +97,7 @@ def create_load_balancer_profile(
outbound_ports,
idle_timeout,
backend_pool_type,
health_probe_mode,
profile,
models,
)
Expand All @@ -105,6 +111,7 @@ def configure_load_balancer_profile(
outbound_ports,
idle_timeout,
backend_pool_type,
health_probe_mode,
profile,
models,
):
Expand Down Expand Up @@ -178,6 +185,8 @@ def configure_load_balancer_profile(
profile.idle_timeout_in_minutes = idle_timeout
if backend_pool_type:
profile.backend_pool_type = backend_pool_type
if health_probe_mode:
profile.cluster_service_load_balancer_health_probe_mode = health_probe_mode
return profile


Expand All @@ -188,6 +197,8 @@ def is_load_balancer_profile_provided(
ip_prefixes,
outbound_ports,
idle_timeout,
backend_pool_type,
health_probe_mode,
):
return any(
[
Expand All @@ -197,6 +208,8 @@ def is_load_balancer_profile_provided(
ip_prefixes,
outbound_ports is not None,
idle_timeout,
backend_pool_type,
health_probe_mode,
]
)

Expand Down
19 changes: 19 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
CONST_NODE_PROVISIONING_MODE_AUTO,
CONST_SSH_ACCESS_LOCALUSER,
CONST_SSH_ACCESS_DISABLED,
CONST_CLUSTER_SERVICE_HEALTH_PROBE_MODE_SERVICE_NODE_PORT,
CONST_CLUSTER_SERVICE_HEALTH_PROBE_MODE_SHARED,
)
from azext_aks_preview._validators import (
validate_acr,
Expand Down Expand Up @@ -356,6 +358,11 @@
CONST_SSH_ACCESS_DISABLED,
]

health_probe_modes = [
CONST_CLUSTER_SERVICE_HEALTH_PROBE_MODE_SERVICE_NODE_PORT,
CONST_CLUSTER_SERVICE_HEALTH_PROBE_MODE_SHARED,
]


def load_arguments(self, _):
acr_arg_type = CLIArgumentType(metavar="ACR_NAME_OR_RESOURCE_ID")
Expand Down Expand Up @@ -867,6 +874,12 @@ def load_arguments(self, _):
action="store_true"
)

c.argument(
"cluster_service_load_balancer_health_probe_mode",
is_preview=True,
arg_type=get_enum_type(health_probe_modes),
)

with self.argument_context("aks update") as c:
# managed cluster paramerters
c.argument("disable_local_accounts", action="store_true")
Expand Down Expand Up @@ -1246,6 +1259,12 @@ def load_arguments(self, _):
# In update scenario, use emtpy str as default.
c.argument('ssh_access', arg_type=get_enum_type(ssh_accesses), is_preview=True)

c.argument(
"cluster_service_load_balancer_health_probe_mode",
is_preview=True,
arg_type=get_enum_type(health_probe_modes),
)

with self.argument_context("aks upgrade") as c:
c.argument("kubernetes_version", completer=get_k8s_upgrades_completion_list)
c.argument(
Expand Down
2 changes: 2 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ def aks_create(
# trusted launch
enable_secure_boot=False,
enable_vtpm=False,
cluster_service_load_balancer_health_probe_mode=None,
):
# DO NOT MOVE: get all the original parameters and save them as a dictionary
raw_parameters = locals()
Expand Down Expand Up @@ -826,6 +827,7 @@ def aks_update(
azure_container_storage_nodepools=None,
node_provisioning_mode=None,
ssh_access=None,
cluster_service_load_balancer_health_probe_mode=None,
):
# DO NOT MOVE: get all the original parameters and save them as a dictionary
raw_parameters = locals()
Expand Down
20 changes: 18 additions & 2 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,20 @@ def get_load_balancer_backend_pool_type(self) -> str:
# this parameter does not need validation
return load_balancer_backend_pool_type

def get_cluster_service_load_balancer_health_probe_mode(self) -> Union[str, None]:
"""Obtain the value of cluster_service_load_balancer_health_probe_mode.
:return: string
"""
# read the original value passed by the command
cluster_service_health_probe_mode = self.raw_param.get(
"cluster_service_load_balancer_health_probe_mode"
)

# this parameter does not need dynamic completion
# this parameter does not need validation
return cluster_service_health_probe_mode

def get_nrg_lockdown_restriction_level(self) -> Union[str, None]:
"""Obtain the value of nrg_lockdown_restriction_level.
:return: string or None
Expand Down Expand Up @@ -2715,7 +2729,8 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
# recreate the load balancer profile if load_balancer_managed_outbound_ipv6_count is not None
if (
self.context.get_load_balancer_managed_outbound_ipv6_count() is not None or
self.context.get_load_balancer_backend_pool_type() is not None
self.context.get_load_balancer_backend_pool_type() is not None or
self.context.get_cluster_service_load_balancer_health_probe_mode() is not None
):
network_profile.load_balancer_profile = create_load_balancer_profile(
self.context.get_load_balancer_managed_outbound_ip_count(),
Expand All @@ -2725,6 +2740,7 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
self.context.get_load_balancer_outbound_ports(),
self.context.get_load_balancer_idle_timeout(),
self.context.get_load_balancer_backend_pool_type(),
self.context.get_cluster_service_load_balancer_health_probe_mode(),
models=self.models.load_balancer_models,
)

Expand Down Expand Up @@ -2754,7 +2770,6 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
network_profile.monitoring = self.models.NetworkMonitoring( # pylint: disable=no-member
enabled=network_observability
)

return mc

def set_up_api_server_access_profile(self, mc: ManagedCluster) -> ManagedCluster:
Expand Down Expand Up @@ -3896,6 +3911,7 @@ def update_load_balancer_profile(self, mc: ManagedCluster) -> ManagedCluster:
outbound_ports=self.context.get_load_balancer_outbound_ports(),
idle_timeout=self.context.get_load_balancer_idle_timeout(),
backend_pool_type=self.context.get_load_balancer_backend_pool_type(),
health_probe_mode=self.context.get_cluster_service_load_balancer_health_probe_mode(),
profile=mc.network_profile.load_balancer_profile,
models=self.models.load_balancer_models,
)
Expand Down
Loading

0 comments on commit 9448fdb

Please sign in to comment.