Azure-cli: az acs kubernetes get-credentials fails in azure-cli-acs 2.0.17

Created on 16 Oct 2017  路  15Comments  路  Source: Azure/azure-cli

Description

Outline the issue here:
Unable to obtain kubectl config in latest version of CLI

Works in older version: pip install azure-cli-acs==2.0.16

Trace:
```ERROR: 'proxycommand'
Traceback (most recent call last):
File "/Users/apopovich/pythonenvs/az/lib/python3.6/site-packages/azure/cli/main.py", line 36, in main
cmd_result = APPLICATION.execute(args)
File "/Users/apopovich/pythonenvs/az/lib/python3.6/site-packages/azure/cli/core/application.py", line 212, in execute
result = expanded_arg.func(params)
File "/Users/apopovich/pythonenvs/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 377, in __call__
return self.handler(args, kwargs)
File "/Users/apopovich/pythonenvs/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 620, in _execute_command
reraise(
sys.exc_info())
File "/Users/apopovich/pythonenvs/az/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/Users/apopovich/pythonenvs/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 602, in _execute_command
result = op(client, **kwargs) if client else op(
kwargs)
File "/Users/apopovich/pythonenvs/az/lib/python3.6/site-packages/azure/cli/command_modules/acs/custom.py", line 814, in k8s_get_credentials
_k8s_get_credentials_internal(name, acs_info, path, ssh_key_file)
File "/Users/apopovich/pythonenvs/az/lib/python3.6/site-packages/azure/cli/command_modules/acs/custom.py", line 836, in _k8s_get_credentials_internal
'.kube/config', path_candidate, key_filename=ssh_key_file)
File "/Users/apopovich/pythonenvs/az/lib/python3.6/site-packages/azure/cli/command_modules/acs/acs_client.py", line 65, in secure_copy
proxy = paramiko.ProxyCommand(host_config['proxycommand'])
KeyError: 'proxycommand'

interestingly in ssh library this key gets removed:
[https://github.com/paramiko/paramiko/blob/6978c7a0b8faa683b119de3a0c096be31ac4fdc9/paramiko/config.py#L137](https://github.com/paramiko/paramiko/blob/6978c7a0b8faa683b119de3a0c096be31ac4fdc9/paramiko/config.py#L137)

---

### Environment summary
Python 3.6.3 virtual environment 


**Install Method:** How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)  
Answer here:
pip install azure-cli==2.0.18

**CLI Version:** What version of the CLI and modules are installed? (Use `az --version`)  
Answer here:

azure-cli (2.0.18)

acr (2.0.13)
acs (2.0.17)
appservice (0.1.18)
backup (1.0.1)
batch (3.1.5)
billing (0.1.5)
cdn (0.0.9)
cloud (2.0.8)
cognitiveservices (0.1.8)
command-modules-nspkg (2.0.1)
component (2.0.7)
configure (2.0.11)
consumption (0.1.5)
container (0.1.11)
core (2.0.18)
cosmosdb (0.1.13)
dla (0.0.12)
dls (0.0.15)
eventgrid (0.1.4)
extension (0.0.4)
feedback (2.0.6)
find (0.2.7)
interactive (0.3.10)
iot (0.1.12)
keyvault (2.0.12)
lab (0.0.11)
monitor (0.0.10)
network (2.0.16)
nspkg (3.0.1)
profile (2.0.14)
rdbms (0.0.7)
redis (0.2.9)
resource (2.0.16)
role (2.0.13)
servicefabric (0.0.4)
sf (1.0.8)
sql (2.0.13)
storage (2.0.17)
vm (2.0.16)

Python location '/Users/user/pythonenvs/az/bin/python'
Extensions directory '/Users/user/.azure/cliextensions'

Python (Darwin) 3.6.3 (default, Oct 4 2017, 06:09:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]

Legal docs and information: aka.ms/AzureCliLegal
```
OS Version: What OS and version are you using?
Answer here:
MacOS Sierra 10.12.6

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here:
zsh

ACS Service Attention bug

Most helpful comment

It looks like this was fixed relatively recently: https://github.com/Azure/azure-cli/commit/5b4a0dbb89ab45b6dd59bde0e87e789a866e5ff9

See #4646 for ways to install the bleeding edge of azure-cli.

All 15 comments

Confirmed for Azure CLI 2.0.19 and ACS version 2.0.17

Also confirmed. Azure CLI 2.0.19 and ACS version 2.0.17

I find out a workaround for this issue. Just install the latest az-dev version solved my problem. Here is the steps to workaround this:

  1. Install Python
    choco install python -y
  2. Install pip
    wget https://bootstrap.pypa.io/get-pip.py
    python get-pip.py
  3. Install the latest Azure CLI 2.0 using pip
    pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge

A workaround is also to do it manually:
mkdir $HOME/.kube
scp azureuser@{master-dns-name}:.kube/config $HOME/.kube/config

Downgrading just ACS package after installing full cli also works: pip install azure-cli-acs==2.0.16

It looks like this was fixed relatively recently: https://github.com/Azure/azure-cli/commit/5b4a0dbb89ab45b6dd59bde0e87e789a866e5ff9

See #4646 for ways to install the bleeding edge of azure-cli.

az acs kubernetes get-credentials --resource-group=k8s --name=cluster
'proxycommand'
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/core/application.py", line 212, in execute
    result = expanded_arg.func(params)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 377, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 620, in _execute_command
    reraise(*sys.exc_info())
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 602, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/custom.py", line 814, in k8s_get_credentials
    _k8s_get_credentials_internal(name, acs_info, path, ssh_key_file)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/custom.py", line 835, in _k8s_get_credentials_internal
    '.kube/config', path_candidate, key_filename=ssh_key_file)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/acs_client.py", line 65, in secure_copy
    proxy = paramiko.ProxyCommand(host_config['proxycommand'])
KeyError: 'proxycommand'

same happening with CLI 2.0.19

@troydai it should be fixed now. We can close this.

2.0.20 has been released.

Thanks guys! Just tested un 2.0.20, works great!

I am still hitting this issue on 2.0.20

Error reading SSH protocol banner
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/paramiko/transport.py", line 2000, in _check_banner
    buf = self.packetizer.readline(timeout)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/paramiko/packet.py", line 353, in readline
    buf += self._read_timeout(timeout)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/paramiko/packet.py", line 546, in _read_timeout
    raise socket.timeout()
socket.timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/azure/cli/core/application.py", line 212, in execute
    result = expanded_arg.func(params)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 377, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 620, in _execute_command
    reraise(*sys.exc_info())
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 602, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/custom.py", line 773, in k8s_get_credentials
    _k8s_get_credentials_internal(name, acs_info, path, ssh_key_file)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/custom.py", line 794, in _k8s_get_credentials_internal
    '.kube/config', path_candidate, key_filename=ssh_key_file)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/acs_client.py", line 72, in secure_copy
    ssh.connect(host, username=user, pkey=pkey, sock=proxy)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/paramiko/client.py", line 385, in connect
    t.start_client(timeout=timeout)
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/paramiko/transport.py", line 543, in start_client
    raise e
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/paramiko/transport.py", line 1854, in run
    self._check_banner()
  File "/usr/local/Cellar/azure-cli/2.0.20/libexec/lib/python3.6/site-packages/paramiko/transport.py", line 2005, in _check_banner
    'Error reading SSH protocol banner' + str(e)
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner

@jamoham that's a different issue (socket.timeout). Sounds like your Kubernetes master is unreachable, try to establish a SSH connection using plain OpenSSH to confirm that (ssh [email protected]).

Hello,
I am still getting the below issue:

az aks get-credentials --resource-group xxxxxx-01 --name xxxxxx
'users'
Traceback (most recent call last):
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/knack/cli.py", line 197, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 337, in execute
six.reraise(sys.exc_info())
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 311, in execute
result = cmd(params)
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 170, in __call__
return super(AzCliCommand, self).__call__(
args, kwargs)
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/knack/commands.py", line 109, in __call__
return self.handler(args, *kwargs)
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/azure/cli/core/__init__.py", line 421, in default_command_handler
result = op(
command_args)
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/azure/cli/command_modules/acs/custom.py", line 1482, in aks_get_credentials
_print_or_merge_credentials(path, kubeconfig)
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/azure/cli/command_modules/acs/custom.py", line 1895, in _print_or_merge_credentials
merge_kubernetes_configurations(path, temp_path)
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/azure/cli/command_modules/acs/custom.py", line 1012, in merge_kubernetes_configurations
_handle_merge(existing, addition, 'users')
File "/usr/local/Cellar/azure-cli/2.0.41/libexec/lib/python3.7/site-packages/azure/cli/command_modules/acs/custom.py", line 969, in _handle_merge
if existing[key] is None:
KeyError: 'users'

@sharmagaurav03 this is likely a different issue. Please open an new issue.

Was this page helpful?
0 / 5 - 0 ratings