az aks get-credentials fails on empty or non-existent KUBECONFIG
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
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/aks-pm
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/aks-pm
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: {}
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