Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AKS Get-Credentials doesn't handle KUBECONFIG with multiple files #18836

Open
paddycarey opened this issue Jul 13, 2021 · 8 comments
Open

AKS Get-Credentials doesn't handle KUBECONFIG with multiple files #18836

paddycarey opened this issue Jul 13, 2021 · 8 comments
Labels
AKS az aks/acs/openshift Service Attention This issue is responsible by Azure service team.

Comments

@paddycarey
Copy link

Describe the bug

When a user's KUBECONFIG environment variable contains more than one file, then az aks get-credentials... mistakenly treats the value as a single path.

As per the official documentation this colon-delimited format is explicitly supported on Mac and Linux.

This behaviour appears to have been introduced by #18704 and is present in v2.26.0 and above.

e.g.

If my KUBECONFIG looks like so:

KUBECONFIG=/home/me/.kube/config:/home/me/.kube/anotherconfig:/home/me/.kube/yetanotherconfig

Then when I run az aks get-credentials... then it will attempt to write the file to a file at the path /home/me/.kube/config:/home/me/.kube/anotherconfig:/home/me/.kube/yetanotherconfig rather than one of the single files contained within.

To Reproduce

$ KUBECONFIG=/home/me/.kube/config:/home/me/.kube/anotherconfig
$ az aks get-credentials ...
$ cat "/home/me/.kube/config:/home/me/.kube/anotherconfig"

Expected behavior

az aks get-credentials... should write AKS credentials to one of the files contained within KUBECONFIG only, but not sure how it should choose which to use.

Environment summary

Install method: homebrew
Mac Version: 11.4

$ az --version
azure-cli                         2.26.0

core                              2.26.0
telemetry                          1.0.6

Python location '/usr/local/Cellar/azure-cli/2.26.0/libexec/bin/python'
Extensions directory '/Users/paddy/.azure/cliextensions'

Python (Darwin) 3.8.11 (default, Jun 29 2021, 03:08:07)
[Clang 12.0.5 (clang-1205.0.22.9)]

Additional Context

N/A

@ghost ghost added needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Jul 13, 2021
@paddycarey paddycarey changed the title AKE Get-Credentials doesn't handle KUBECONFIG with multiple files AKS Get-Credentials doesn't handle KUBECONFIG with multiple files Jul 13, 2021
@yonzhan yonzhan added the AKS az aks/acs/openshift label Jul 13, 2021
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Jul 13, 2021
@yonzhan yonzhan added Service Attention This issue is responsible by Azure service team. and removed customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jul 13, 2021
@ghost
Copy link

ghost commented Jul 13, 2021

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

Issue Details

Describe the bug

When a user's KUBECONFIG environment variable contains more than one file, then az aks get-credentials... mistakenly treats the value as a single path.

As per the official documentation this colon-delimited format is explicitly supported on Mac and Linux.

This behaviour appears to have been introduced by #18704 and is present in v2.26.0 and above.

e.g.

If my KUBECONFIG looks like so:

KUBECONFIG=/home/me/.kube/config:/home/me/.kube/anotherconfig:/home/me/.kube/yetanotherconfig

Then when I run az aks get-credentials... then it will attempt to write the file to a file at the path /home/me/.kube/config:/home/me/.kube/anotherconfig:/home/me/.kube/yetanotherconfig rather than one of the single files contained within.

To Reproduce

$ KUBECONFIG=/home/me/.kube/config:/home/me/.kube/anotherconfig
$ az aks get-credentials ...
$ cat "/home/me/.kube/config:/home/me/.kube/anotherconfig"

Expected behavior

az aks get-credentials... should write AKS credentials to one of the files contained within KUBECONFIG only, but not sure how it should choose which to use.

Environment summary

Install method: homebrew
Mac Version: 11.4

$ az --version
azure-cli                         2.26.0

core                              2.26.0
telemetry                          1.0.6

Python location '/usr/local/Cellar/azure-cli/2.26.0/libexec/bin/python'
Extensions directory '/Users/paddy/.azure/cliextensions'

Python (Darwin) 3.8.11 (default, Jun 29 2021, 03:08:07)
[Clang 12.0.5 (clang-1205.0.22.9)]

Additional Context

N/A

Author: paddycarey
Assignees: -
Labels:

AKS, Service Attention

Milestone: -

@yonzhan
Copy link
Collaborator

yonzhan commented Jul 13, 2021

route to service team

@Volatus
Copy link
Contributor

Volatus commented Jul 31, 2021

@paddycarey The official docs provide no guidance on how multiple files have to be handled. What's the point of having multiple files on KUBECONFIG anyway?

@Flasheh
Copy link

Flasheh commented Aug 1, 2021

@Volatus The docs state

The KUBECONFIG environment variable holds a list of kubeconfig files. For Linux and Mac, the list is colon-delimited. For Windows, the list is semicolon-delimited.

When working with a bunch of different clusters on multiple projects for example, some people prefer to manage them in different physical config files.

@Volatus
Copy link
Contributor

Volatus commented Aug 2, 2021

@Volatus The docs state

The KUBECONFIG environment variable holds a list of kubeconfig files. For Linux and Mac, the list is colon-delimited. For Windows, the list is semicolon-delimited.

When working with a bunch of different clusters on multiple projects for example, some people prefer to manage them in different physical config files.

I see, I can work on fixing this, it's just that I'm not sure what behavior it should have in terms of deciding which file to use within the $KUBECONFIG.

@Flasheh
Copy link

Flasheh commented Aug 2, 2021

Yeah I see the issue now. There's no real solution without making certain assumptions.

What bothers me is that it now writes to the literal value like /home/me/.kube/config:/home/me/.kube/anotherconfig
I wouldn't mind it defaulting to ~/.kube/config with multiple files in $KUBECONFIG but that's somewhat confusing behaviour.

@Volatus
Copy link
Contributor

Volatus commented Aug 2, 2021

Yeah I see the issue now. There's no real solution without making certain assumptions.

What bothers me is that it now writes to the literal value like /home/me/.kube/config:/home/me/.kube/anotherconfig
I wouldn't mind it defaulting to ~/.kube/config with multiple files in $KUBECONFIG but that's somewhat confusing behaviour.

The reason I introduced the change for checking $KUBECONFIG was due to the fact that previous, azure cli would not write to the appropriate file if you put KUBECONFIG outside of the default location in $HOME/.kube/. Unfortunately this change broke the functionality with having multiple files but I can write up a fix once it's decided on what behavior to use.

@paddycarey
Copy link
Author

Unsure what other tools do, but I noticed that the aws CLI defaults to using the first in the list if set:

By default, the configuration is written to the first file path in the KUBECONFIG environment variable (if it is set) or the default kubeconfig path (.kube/config) in your home directory.

Perhaps similar behaviour would work well here too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AKS az aks/acs/openshift Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants