diff --git a/src/connectedk8s/HISTORY.rst b/src/connectedk8s/HISTORY.rst index cb52dbae41f..0db01336f9c 100644 --- a/src/connectedk8s/HISTORY.rst +++ b/src/connectedk8s/HISTORY.rst @@ -5,7 +5,7 @@ Release History 0.2.8 ++++++ -* Added checks for proxy +* Added checks for proxy and added disable-proxy * Updated config dataplane endpoint to support other clouds 0.2.7 diff --git a/src/connectedk8s/azext_connectedk8s/_constants.py b/src/connectedk8s/azext_connectedk8s/_constants.py index b0d4c1388cc..e1b8bba6980 100644 --- a/src/connectedk8s/azext_connectedk8s/_constants.py +++ b/src/connectedk8s/azext_connectedk8s/_constants.py @@ -50,3 +50,5 @@ Kubeconfig_Failed_To_Load_Fault_Type = "failed-to-load-kubeconfig-file" Proxy_Cert_Path_Does_Not_Exist_Fault_Type = 'proxy-cert-path-does-not-exist-error' Proxy_Cert_Path_Does_Not_Exist_Error = 'Proxy cert path {} does not exist. Please check the path provided' +No_Param_Error = 'No parmeters were specified with update command. Please run az connectedk8s update --help to check parameters available for update' +EnableProxy_Conflict_Error = 'Conflict detected: --disable-proxy can not be set with --https-proxy, --http-proxy, --proxy-skip-range and --proxy-cert at the same time. Please run az connectedk8s update --help for more information about the parameters' diff --git a/src/connectedk8s/azext_connectedk8s/_help.py b/src/connectedk8s/azext_connectedk8s/_help.py index 602ace31de6..d547bf08958 100644 --- a/src/connectedk8s/azext_connectedk8s/_help.py +++ b/src/connectedk8s/azext_connectedk8s/_help.py @@ -33,6 +33,8 @@ examples: - name: Update proxy values for the agents text: az connectedk8s update -g resourceGroupName -n connectedClusterName --proxy-cert /path/to/crt --proxy-https https://proxy-url --proxy-http http://proxy-url --proxy-skip-range excludedIP,excludedCIDR,exampleCIDRfollowed,10.0.0.0/24 + - name: Disable proxy settings for agents + text: az connectedk8s update --disable-proxy """ helps['connectedk8s list'] = """ diff --git a/src/connectedk8s/azext_connectedk8s/_params.py b/src/connectedk8s/azext_connectedk8s/_params.py index cf0c51f3351..414e4da8eff 100644 --- a/src/connectedk8s/azext_connectedk8s/_params.py +++ b/src/connectedk8s/azext_connectedk8s/_params.py @@ -33,6 +33,7 @@ def load_arguments(self, _): c.argument('http_proxy', options_list=['--proxy-http'], help='Http proxy URL to be used.') c.argument('no_proxy', options_list=['--proxy-skip-range'], help='List of URLs/CIDRs for which proxy should not to be used.') c.argument('proxy_cert', options_list=['--proxy-cert'], type=file_type, completer=FilesCompleter(), help='Path to the certificate file for proxy') + c.argument('disable_proxy', options_list=['--disable-proxy'], action='store_true', help='Disables proxy settings for agents') with self.argument_context('connectedk8s list') as c: pass diff --git a/src/connectedk8s/azext_connectedk8s/custom.py b/src/connectedk8s/azext_connectedk8s/custom.py index 28d88977375..5bccb5afcb4 100644 --- a/src/connectedk8s/azext_connectedk8s/custom.py +++ b/src/connectedk8s/azext_connectedk8s/custom.py @@ -623,6 +623,8 @@ def helm_install_release(chart_path, subscription_id, kubernetes_distro, resourc cmd_helm_install.extend(["--set", "global.noProxy={}".format(no_proxy)]) if proxy_cert: cmd_helm_install.extend(["--set-file", "global.proxyCert={}".format(proxy_cert)]) + if https_proxy or http_proxy or no_proxy: + cmd_helm_install.extend(["--set", "global.isProxyEnabled={}".format(True)]) if kube_config: cmd_helm_install.extend(["--kubeconfig", kube_config]) if kube_context: @@ -708,7 +710,7 @@ def update_connectedk8s(cmd, instance, tags=None): def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy="", http_proxy="", no_proxy="", proxy_cert="", - kube_config=None, kube_context=None, no_wait=False): + disable_proxy=False, kube_config=None, kube_context=None, no_wait=False): logger.warning("Ensure that you have the latest helm version installed before proceeding.") logger.warning("This operation might take a while...\n") @@ -736,6 +738,12 @@ def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy="" proxy_cert = proxy_cert.replace('\\', r'\\\\') + if https_proxy == "" and http_proxy == "" and no_proxy == "" and proxy_cert == "" and not disable_proxy: + raise CLIError(consts.No_Param_Error) + + if (https_proxy or http_proxy or no_proxy or proxy_cert) and disable_proxy: + raise CLIError(consts.EnableProxy_Conflict_Error) + # Checking whether optional extra values file has been provided. values_file_provided = False values_file = os.getenv('HELMVALUESPATH') @@ -837,6 +845,10 @@ def update_agents(cmd, client, resource_group_name, cluster_name, https_proxy="" cmd_helm_upgrade.extend(["--set", "global.httpProxy={}".format(http_proxy)]) if no_proxy: cmd_helm_upgrade.extend(["--set", "global.noProxy={}".format(no_proxy)]) + if https_proxy or http_proxy or no_proxy: + cmd_helm_upgrade.extend(["--set", "global.isProxyEnabled={}".format(True)]) + if disable_proxy: + cmd_helm_upgrade.extend(["--set", "global.isProxyEnabled={}".format(False)]) if proxy_cert: cmd_helm_upgrade.extend(["--set-file", "global.proxyCert={}".format(proxy_cert)]) if kube_config: