azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az aks get-credentials fails on empty or non-existent KUBECONFIG

Open sudermanjr opened this issue 6 years ago • 4 comments

Describe the bug

Command Name az aks get-credentials

Errors:

'clusters'
Traceback (most recent call last):
python3.8/site-packages/knack/cli.py, ln 206, in invoke
    cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 608, in execute
    raise ex
cli/core/commands/__init__.py, ln 666, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
cli/core/commands/__init__.py, ln 659, in _run_job
    six.reraise(*sys.exc_info())
...
cli/command_modules/acs/custom.py, ln 1182, in merge_kubernetes_configurations
    _handle_merge(existing, addition, 'clusters', replace)
cli/command_modules/acs/custom.py, ln 1117, in _handle_merge
    if existing[key] is None:
KeyError: 'clusters'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here...
  • az aks get-credentials --overwrite --resource-group {} --name {}

Expected Behavior

Environment Summary

macOS-10.15.2-x86_64-i386-64bit
Python 3.8.1
Shell: bash

azure-cli 2.0.79 *

Also tried with 2.0.80

Additional Context

sudermanjr avatar Jan 16 '20 22:01 sudermanjr

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/aks-pm

ghost avatar Jan 17 '20 06:01 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/aks-pm

ghost avatar Jan 17 '20 06:01 ghost

Workaround: Removing your empty KUBECONFIG file (e.g. rm ~/.kube/config) and re-running the get-credentials command appears to fix things.

My KUBECONFIG was a partial file prior to rm and I got the above error so it's not just fully-empty files:

apiVersion: v1
kind: Config
preferences: {}

jessemillar avatar Mar 25 '20 18:03 jessemillar

Hello! In addition to the workaround, please try again with the latest Azure CLI version. Feel free to reopen an issue if it still doesn't work.

https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest

Jen7714 avatar May 29 '20 16:05 Jen7714