question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az aks get-credentials throws KeyError: 'clusters'

See original GitHub issue

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az aks get-credentials

Errors:

'clusters'
Traceback (most recent call last):
python3.8/site-packages/knack/cli.py, ln 215, in invoke
    cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 654, in execute
    raise ex
cli/core/commands/__init__.py, ln 718, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
cli/core/commands/__init__.py, ln 711, in _run_job
    six.reraise(*sys.exc_info())
lib/python3.8/site-packages/six.py, ln 703, in reraise
    raise value
...
cli/command_modules/acs/custom.py, ln 3204, in _print_or_merge_credentials
    merge_kubernetes_configurations(path, temp_path, overwrite_existing, context_name)
cli/command_modules/acs/custom.py, ln 1184, in merge_kubernetes_configurations
    _handle_merge(existing, addition, 'clusters', replace)
cli/command_modules/acs/custom.py, ln 1120, 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 --resource-group {} --name {}

Expected Behavior

Environment Summary

macOS-10.15.5-x86_64-i386-64bit
Python 3.8.3
Installer: HOMEBREW

azure-cli 2.7.0

Additional Context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
matthchrcommented, Aug 25, 2020

I’m having this issue too:

$ kubectl config view
apiVersion: v1
clusters: null
contexts: null
current-context: ""
kind: Config
preferences: {}
users: null

I believe that this is a bug in the CLI, located here

We assume that the existing config has all of the keys (clusters, contexts, etc). Clearly though, it’s possible that this isn’t the case.

Other tooling (for example kind), handles this just fine - here’s my config after running kind create cluster

$ kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://127.0.0.1:32913
  name: kind-kind
contexts:
- context:
    cluster: kind-kind
    user: kind-kind
  name: kind-kind
current-context: kind-kind
kind: Config
preferences: {}
users:
- name: kind-kind
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

And then again after kind delete cluster

$ kubectl config view
apiVersion: v1
clusters: null
contexts: null
current-context: ""
kind: Config
preferences: {}
users: null

I believe the fix is pretty simple… I’ve sent a PR: #14914

0reactions
msftbot[bot]commented, Feb 20, 2022

Hi, we’re sending this friendly reminder because we haven’t heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don’t hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Kubernetes Error when running "az aks get- ...
When you use the command az aks get-credentials without parameter --admin , it means the CLI command uses the default value: Cluster user....
Read more >
Reset the credentials for a cluster - Azure Kubernetes Service
To update the credentials for the existing service principal, get the service principal ID of your cluster using the az aks show command....
Read more >
kubectl apply release task cannot pull from Azure Container ...
(create a Service Principal for pulling an image, then using the ID and password). Again, this worked locally to update the cluster, but...
Read more >
How To login to azure kubernetes cluster
Run az aks get-credentials to download credentials for the cluster into .kube/config. Run kubectl commands. The first command may trigger ...
Read more >
Azure AKS Cluster Access with Multiple Clusters
Understand how to access multiple Azure Kubernetes AKS Clusters using kubectl. ... Configure AKSDEMO3 & 4 Cluster Access for kubectl az aks get-credentials...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found