https://rancher.com/ logo
Title
g

green-restaurant-60209

06/18/2022, 2:26 PM
Hello. I am using Rancher Desktop to drive devcontainer development locally with Moby. To use docker or kubernetes within the container, I have it synchronizing with the desktop's docker and kubernetes. That said Rancher Desktop is clobbering kubeconfig's set context which does not seem right and contrary to docker for mac. I want to be able to execute kubectl commands in my devcontainer to also access my remote cluster. I need Docker to be running for my devcontainer, but want the kubeconfig to be respected so that it will use the kubernetes context that has been set.
To follow on this , it seems this may be more of an issue for dev-containers and Microsoft's copy-kube-config script as instead of obtaining kubeconfig from $KUBECONFIG where this can merge one or more config files to present possible contexts, it seems to be taking the ~/.kube/config only
Despite this, the confusing part is that when $KUBECONFIG is being used to provide possible contexts and the context selected is one other than rancher desktop, Kubernetes Contexts in the menubar app does not display the possible contexts. I believe this is a bug in RD.
I have resolved the issue in the dev container by placing additional configurations in a config-files folder within my ~/.kube folder. Thus, they are also copied into the container. I am then sourcing a script that sets the default context and iterates over the additional config-files to append them to the $KUBECONFIG so they are merged to be able to select one or more contexts.
The last issue remains a Rancher Desktop issue in that on my system if I set a context other than "rancher-desktop", the context in "Kubernetes Contexts" for rancher desktop remains "rancher desktop". I believe this a bug.
p

proud-jewelry-46860

06/20/2022, 5:36 PM
Hi! Yes, we should be showing all contexts (but I'm not sure if we're dealing with multiple files in
$KUBECONFIG
correctly); and we should only be clobbering
current-context
if it's not set, but again that probably doesn't work well with multiple config files.
g

green-restaurant-60209

06/24/2022, 12:27 PM
@proud-jewelry-46860 Thank you for your reply. This can and should be handled by Rancher Desktop in a way that is understood for one or more configurations. The current state of the UI cannot reflect this. While an issue has been filed for this, there needs to be a predictable way of working with RD with multiple kubernetes configurations. That means thinking this out with some best practices with $KUBECONFIG and not making assumptions about the environment RD is being installed on. Reliably configuring clusters for local development is an essential part of the user experience. It is common to need a handle on one or more kubernetes clusters, whether that be those are local or remote.
p

proud-jewelry-46860

06/24/2022, 4:39 PM
Yeah, we need improvements in this area — could you file a feature request issue on GitHub (using this link) so we don't lose it? We may eventually file a thing to duplicate it to, but it's always easier to err on filing more things and dupe later.
g

green-restaurant-60209

06/24/2022, 4:41 PM
@proud-jewelry-46860 Sure