Repository navigation
[AKS] Support configuring SSH for AKS nodepools #34161
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
Changes from 7 commits
f27d8db
3937693
37f33cb
2ba999e
eb1036d
fe71b9a
8b6bd1d
18f13e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ | |
| from azure.cli.core.profiles import ResourceType | ||
| from azure.cli.core.util import get_file_json, sdk_no_wait, read_file_content | ||
| from knack.log import get_logger | ||
| from knack.prompting import prompt_y_n | ||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
|
|
@@ -1990,6 +1991,18 @@ def get_workload_runtime(self) -> Union[str, None]: | |
| # this parameter does not need validation | ||
| return workload_runtime | ||
|
|
||
| def get_ssh_access(self) -> Union[str, None]: | ||
| """Obtain the value of ssh_access. | ||
| """ | ||
| return self.raw_param.get("ssh_access") | ||
|
|
||
| def get_yes(self) -> bool: | ||
| """Obtain the value of yes. | ||
|
|
||
| :return: bool | ||
| """ | ||
| return self.raw_param.get("yes") | ||
|
|
||
|
|
||
| class AKSAgentPoolAddDecorator: | ||
| def __init__( | ||
|
|
@@ -2328,6 +2341,20 @@ def set_up_agentpool_security_profile(self, agentpool: AgentPool) -> AgentPool: | |
|
|
||
| return agentpool | ||
|
|
||
| def set_up_ssh_access(self, agentpool: AgentPool) -> AgentPool: | ||
| """Set up the SSH access property for the AgentPool object. | ||
|
|
||
| :return: the AgentPool object | ||
| """ | ||
| self._ensure_agentpool(agentpool) | ||
|
|
||
| ssh_access = self.context.get_ssh_access() | ||
| if ssh_access is not None: | ||
| if agentpool.security_profile is None: | ||
| agentpool.security_profile = self.models.AgentPoolSecurityProfile() # pylint: disable=no-member | ||
| agentpool.security_profile.ssh_access = ssh_access | ||
| return agentpool | ||
|
|
||
| def set_up_agentpool_network_profile(self, agentpool: AgentPool) -> AgentPool: | ||
| self._ensure_agentpool(agentpool) | ||
|
|
||
|
|
@@ -2538,6 +2565,8 @@ def construct_agentpool_profile_default(self, bypass_restore_defaults: bool = Fa | |
| agentpool = self.set_up_crg_id(agentpool) | ||
| # set up agentpool security profile | ||
| agentpool = self.set_up_agentpool_security_profile(agentpool) | ||
| # set up agentpool ssh access | ||
| agentpool = self.set_up_ssh_access(agentpool) | ||
| # set up message of the day | ||
| agentpool = self.set_up_motd(agentpool) | ||
| # set up gpu profile | ||
|
|
@@ -2951,6 +2980,31 @@ def update_vtpm(self, agentpool: AgentPool) -> AgentPool: | |
|
|
||
| return agentpool | ||
|
|
||
| def update_ssh_access(self, agentpool: AgentPool) -> AgentPool: | ||
| """Update the SSH access property for the AgentPool object. | ||
|
|
||
| :return: the AgentPool object | ||
| """ | ||
| self._ensure_agentpool(agentpool) | ||
|
|
||
| ssh_access = self.context.get_ssh_access() | ||
| if ssh_access is not None: | ||
| if agentpool.security_profile is None: | ||
| agentpool.security_profile = self.models.AgentPoolSecurityProfile() # pylint: disable=no-member | ||
| current_ssh_access = agentpool.security_profile.ssh_access | ||
| # already set to the same value, directly return | ||
| if current_ssh_access is not None and current_ssh_access.lower() == ssh_access.lower(): | ||
| return agentpool | ||
|
|
||
| msg = ( | ||
| f"You're going to update agentpool {agentpool.name} ssh access to '{ssh_access}' " | ||
| "This change will take effect after you upgrade the nodepool. Proceed?" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Warn that updating SSH access can trigger a reimage This prompt unconditionally says the change takes effect after upgrading the node pool. For Kubernetes 1.37+, changing SSH access can trigger node-pool reimaging as part of this update, rather than waiting for a separate upgrade. A user could therefore approve this expecting a configuration-only change and encounter unexpected node disruption. Please update both this confirmation and the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point, updated code, PTAL, thanks! |
||
| ) | ||
| if not self.context.get_yes() and not prompt_y_n(msg, default="n"): | ||
| raise DecoratorEarlyExitException() | ||
| agentpool.security_profile.ssh_access = ssh_access | ||
| return agentpool | ||
|
|
||
| def update_gpu_profile(self, agentpool: AgentPool) -> AgentPool: | ||
| self._ensure_agentpool(agentpool) | ||
|
|
||
|
|
@@ -3010,6 +3064,8 @@ def update_agentpool_profile_default(self, agentpools: List[AgentPool] = None) - | |
| agentpool = self.update_vtpm(agentpool) | ||
| # update secure boot | ||
| agentpool = self.update_secure_boot(agentpool) | ||
| # update ssh access | ||
| agentpool = self.update_ssh_access(agentpool) | ||
| # update local DNS profile | ||
| agentpool = self.update_localdns_profile(agentpool) | ||
| # update gpu profile | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.