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

dapr status -k does not work on Windows with KUBECONFIG set #779

Closed
robvet opened this issue Aug 9, 2021 · 11 comments · Fixed by #834
Closed

dapr status -k does not work on Windows with KUBECONFIG set #779

robvet opened this issue Aug 9, 2021 · 11 comments · Fixed by #834
Assignees
Labels
good first issue Good for newcomers
Milestone

Comments

@robvet
Copy link

robvet commented Aug 9, 2021

Hello Dapr Community...

Trying to initialize a Kubernetes cluster for Dapr on Windows 10:

 dapr init -k

I get the follow error message:

Deploying the Dapr control plane to your cluster...
can't connect to a Kubernetes cluster: multiple
kubeconfigs in KUBECONFIG environment v
ariable -
C:\Users.kube\config

Behavior is consistent across Git Bash, Ubuntu with WSL2, and PowerShell

Any suggestions for troubleshooting/resolution would be appreciated.

Thanks

@robvet
Copy link
Author

robvet commented Aug 9, 2021

My KUBECONFIG environment variables points to ==> C:\Users\robvet.kube\config
I have a single config file in that directory.

@yaron2
Copy link
Member

yaron2 commented Aug 9, 2021

You seem to have multiple contexts though, so the kubectl command that Dapr tries to run can't choose the correct one.

Use kubectl set-context to set the context. See more info here: https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/

@robvet
Copy link
Author

robvet commented Aug 9, 2021

Unfortunately, that's not helping. Through hacking at it, discovered that if I open a command shell in admin mode (either PowerShell or GitBash), the ‘dapr status -k’ command works correctly. But, if open the same command shell without admin mode (either PowerShell or GitBash), the ‘dapr status -k’ command errors with the ‘multiple contexts’ error.

Have not seen the 'Multiple Contexts' error on any direct kubectl command, only on Dapr commands for Kubernetes: Dapr init -k, Dapr status -k

@yaron2
Copy link
Member

yaron2 commented Aug 11, 2021

Moving to the correct repository.

@yaron2 yaron2 transferred this issue from dapr/dapr Aug 11, 2021
@yaron2
Copy link
Member

yaron2 commented Aug 11, 2021

@mukundansundar can you please look at this?

@mukundansundar
Copy link
Collaborator

@yaron2 I will take a look at it today ...

@artursouza artursouza added this to the v1.4 milestone Aug 25, 2021
@robvet
Copy link
Author

robvet commented Sep 3, 2021

Can we possibly get some tracition on this issue? It's beeen a month.

@tanvigour tanvigour modified the milestones: v1.4, v1.5 Sep 7, 2021
@LKI
Copy link
Contributor

LKI commented Sep 10, 2021

Unfortunately, that's not helping. Through hacking at it, discovered that if I open a command shell in admin mode (either PowerShell or GitBash), the ‘dapr status -k’ command works correctly. But, if open the same command shell without admin mode (either PowerShell or GitBash), the ‘dapr status -k’ command errors with the ‘multiple contexts’ error.

Have not seen the 'Multiple Contexts' error on any direct kubectl command, only on Dapr commands for Kubernetes: Dapr init -k, Dapr status -k

Confirmed.

Same error here, and hacked by using sudo (Admin permission).

❯ dapr status -k
multiple kubeconfigs in KUBECONFIG environment variable - C:/Users/LKI/.kube/config

❯ sudo dapr status -k
  NAME                   NAMESPACE  HEALTHY  STATUS   REPLICAS  VERSION  AGE  CREATED
  dapr-operator          dapr       True     Running  1         1.3.0    8m   2021-09-10 11:14.41
  dapr-sidecar-injector  dapr       True     Running  1         1.3.0    8m   2021-09-10 11:14.41
  dapr-sentry            dapr       True     Running  1         1.3.0    8m   2021-09-10 11:14.41
  dapr-dashboard         dapr       True     Running  1         0.7.0    8m   2021-09-10 11:14.41
  dapr-placement-server  dapr       True     Running  1         1.3.0    8m   2021-09-10 11:14.41

@LKI
Copy link
Contributor

LKI commented Sep 14, 2021

Looks like root cause is following code:

kubeConfigEnv := os.Getenv("KUBECONFIG")
delimiterBelongsToPath := strings.Count(*kubeconfig, kubeConfigDelimiter) == 1 && strings.EqualFold(*kubeconfig, kubeConfigEnv)
if len(kubeConfigEnv) != 0 && !delimiterBelongsToPath {
kubeConfigs := strings.Split(kubeConfigEnv, kubeConfigDelimiter)
if len(kubeConfigs) > 1 {
return nil, fmt.Errorf("multiple kubeconfigs in KUBECONFIG environment variable - %s", kubeConfigEnv)
}
kubeconfig = &kubeConfigs[0]
}

KUBECONFIG environment variable under Windows is something like C:\Users\LKI\.kube\config.
But the delimiter is :, so the check will return an error.

@artursouza artursouza changed the title Deploying the Dapr control plane to your cluster... can't connect to a Kubernetes cluster: multiple kubeconfigs in KUBECONFIG environment variable dapr status -k does not work on Windows Oct 28, 2021
@artursouza artursouza added the good first issue Good for newcomers label Oct 28, 2021
@artursouza artursouza changed the title dapr status -k does not work on Windows dapr status -k does not work on Windows with KUBECONFIG set Oct 28, 2021
@mukundansundar mukundansundar modified the milestones: v1.5, v1.6 Nov 5, 2021
@sandeshkg
Copy link

Can i work on this one? I have looked at the kubernetes docs here - https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/ and it says -
"The KUBECONFIG environment variable is a list of paths to configuration files. The list is colon-delimited for Linux and Mac, and semicolon-delimited for Windows"
Currently the kubeConfigDelimiter is set to ":" always. We would need to set the kubeConfigDelimiter based on os.
Please do let me know if my understanding is correct and if i can proceed on same lines.

@mukundansundar mukundansundar removed their assignment Nov 19, 2021
yaron2 added a commit that referenced this issue Dec 22, 2021
- related to #779

Co-authored-by: Mukundan Sundararajan <musundar@microsoft.com>
Co-authored-by: Yaron Schneider <schneider.yaron@live.com>
@yaron2
Copy link
Member

yaron2 commented Dec 22, 2021

Can i work on this one? I have looked at the kubernetes docs here - https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/ and it says - "The KUBECONFIG environment variable is a list of paths to configuration files. The list is colon-delimited for Linux and Mac, and semicolon-delimited for Windows" Currently the kubeConfigDelimiter is set to ":" always. We would need to set the kubeConfigDelimiter based on os. Please do let me know if my understanding is correct and if i can proceed on same lines.

This is now closed via #834, but we'd be very happy to have you work on other things! :)

imneov pushed a commit to imneov/dapr-cli that referenced this issue Mar 18, 2022
- related to dapr#779

Co-authored-by: Mukundan Sundararajan <musundar@microsoft.com>
Co-authored-by: Yaron Schneider <schneider.yaron@live.com>
Signed-off-by: imneov <grantliu@yunify.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants