Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 5558428

Browse files
adilliadilAdil Adilli
andauthored
Add http proxy command to az aks create (Azure#3682)
* add http proxy for create scenario to extensions * change conversion issue * fix test * exclude test * add tag live only * correct live only * remove from exclusions * add recording * record again * check for httpProxy * add correct recording * add correct recording * chnage file extension to from yml to yaml * raise CLI error if file does not exist * check for file existence instead of a dict Co-authored-by: Adil Adilli <[email protected]>
1 parent 1d72a08 commit 5558428

File tree

7 files changed

+665
-0
lines changed

7 files changed

+665
-0
lines changed

src/aks-preview/HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
0.5.25
7+
+++++
8+
* Add support for http proxy
9+
610
0.5.24
711
+++++
812
* * Add "--aks-custom-headers" for "az aks nodepool upgrade"

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@
317317
- name: --linux-os-config
318318
type: string
319319
short-summary: OS configurations for Linux agent nodes.
320+
- name: --http-proxy-config
321+
type: string
322+
short-summary: Http Proxy configuration for this cluster.
320323
- name: --enable-pod-identity
321324
type: bool
322325
short-summary: (PREVIEW) Enable pod identity addon.

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def load_arguments(self, _):
121121
c.argument('auto_upgrade_channel', arg_type=get_enum_type([CONST_RAPID_UPGRADE_CHANNEL, CONST_STABLE_UPGRADE_CHANNEL, CONST_PATCH_UPGRADE_CHANNEL, CONST_NODE_IMAGE_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL]))
122122
c.argument('kubelet_config', type=str)
123123
c.argument('linux_os_config', type=str)
124+
c.argument('http_proxy_config', options_list=['--http-proxy-config'], type=str)
124125
c.argument('enable_pod_identity', action='store_true')
125126
c.argument('appgw_name', options_list=['--appgw-name'], arg_group='Application Gateway')
126127
c.argument('appgw_subnet_prefix', options_list=['--appgw-subnet-prefix'], arg_group='Application Gateway', deprecate_info=c.deprecate(redirect='--appgw-subnet-cidr', hide=True))

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
ManagedClusterAutoUpgradeProfile,
7878
KubeletConfig,
7979
LinuxOSConfig,
80+
ManagedClusterHTTPProxyConfig,
8081
SysctlConfig,
8182
ManagedClusterPodIdentityProfile,
8283
ManagedClusterPodIdentity,
@@ -1028,6 +1029,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
10281029
enable_sgxquotehelper=False,
10291030
kubelet_config=None,
10301031
linux_os_config=None,
1032+
http_proxy_config=None,
10311033
assign_identity=None,
10321034
auto_upgrade_channel=None,
10331035
enable_pod_identity=False,
@@ -1440,6 +1442,9 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
14401442
"--fqdn-subdomain should only be used for private cluster with custom private dns zone")
14411443
mc.fqdn_subdomain = fqdn_subdomain
14421444

1445+
if http_proxy_config:
1446+
mc.http_proxy_config = _get_http_proxy_config(http_proxy_config)
1447+
14431448
if uptime_sla:
14441449
mc.sku = ManagedClusterSKU(
14451450
name="Basic",
@@ -4072,6 +4077,8 @@ def _is_msi_cluster(managed_cluster):
40724077

40734078

40744079
def _get_kubelet_config(file_path):
4080+
if not os.path.isfile(file_path):
4081+
raise CLIError("{} is not valid file, or not accessable.".format(file_path))
40754082
kubelet_config = get_file_json(file_path)
40764083
if not isinstance(kubelet_config, dict):
40774084
raise CLIError(
@@ -4100,6 +4107,8 @@ def _get_kubelet_config(file_path):
41004107

41014108

41024109
def _get_linux_os_config(file_path):
4110+
if not os.path.isfile(file_path):
4111+
raise CLIError("{} is not valid file, or not accessable.".format(file_path))
41034112
os_config = get_file_json(file_path)
41044113
if not isinstance(os_config, dict):
41054114
raise CLIError(
@@ -4171,6 +4180,22 @@ def _get_linux_os_config(file_path):
41714180
return config_object
41724181

41734182

4183+
def _get_http_proxy_config(file_path):
4184+
if not os.path.isfile(file_path):
4185+
raise CLIError("{} is not valid file, or not accessable.".format(file_path))
4186+
hp_config = get_file_json(file_path)
4187+
if not isinstance(hp_config, dict):
4188+
raise CLIError(
4189+
"Error reading Http Proxy Config at {}. Please see https://aka.ms/HttpProxyConfig for correct format.".format(file_path))
4190+
config_object = ManagedClusterHTTPProxyConfig()
4191+
config_object.http_proxy = hp_config.get("httpProxy", None)
4192+
config_object.https_proxy = hp_config.get("httpsProxy", None)
4193+
config_object.no_proxy = hp_config.get("noProxy", None)
4194+
config_object.trusted_ca = hp_config.get("trustedCa", None)
4195+
4196+
return config_object
4197+
4198+
41744199
def _is_pod_identity_addon_enabled(instance):
41754200
if not instance:
41764201
return False
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"httpProxy": "http://myproxy.server.com:8080/",
3+
"httpsProxy": "https://myproxy.server.com:8080/",
4+
"noProxy": [
5+
"localhost",
6+
"127.0.0.1"
7+
],
8+
"trustedCa": "G9yR2xrQ29NRjNURHg4cm1wOURCaUIvCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0="
9+
}

0 commit comments

Comments
 (0)