argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.76k stars 5.42k forks source link

kube-context CLI arg is ignored #12883

Open shamil opened 1 year ago

shamil commented 1 year ago

Checklist:

Describe the bug

I want to override current-context by using the --kube-context flag. But seems like argocd cli ignores it.

To Reproduce

The following command fails:

argocd --kube-context not-current-context --core app list

also even when I login with --core

atgocd login --core
argocd --kube-context not-current-context app list

I get the follwoing error

FATA[0000] invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

When I change the current-context, everything works

kubectl config use-context not-current-context

Expected behavior

argocd cli should not ignore the --kube-context cli arg and properly override current-context

Version

argocd: v2.6.5+60104ac
  BuildDate: 2023-03-14T14:42:25Z
  GitCommit: 60104aca6faec73d10d57cb38245d47f4fb3146b
  GitTreeState: clean
  GoVersion: go1.18.10
  Compiler: gc
  Platform: linux/amd64
mrsimo commented 1 year ago

This would be really useful for us. We have a bunch of documentation with a scattering of # point your kubectl context to the right cluster comments, and it'd be so much easier to have --kube-context work as expected.

I don't know if this flag is intended for a different purpose, but having it be a global flag does make me expect it to work as described by the issue.

Big 👍🏻 !!

prateekkhera92 commented 4 months ago

+1 for this bug fix. We have lots of clusters and scripts to manage them. This flag will ensure that scripts (using argocd cli) runs on correct clusters