(Migrating over from docker/for-win#4491)
Expected behavior
With a customised KUBECONFIG env-var that lists multiple config files, docker ps should still function when the option "Deploy Docker Stacks to Kubernetes by default" is selected.
Actual behavior
With a customised KUBECONFIG env-var that lists multiple config files, docker ps fails function when the option "Deploy Docker Stacks to Kubernetes by default" is selected, with the following output:
PS C:\Users\paulh> docker ps
unable to resolve docker endpoint: default orchestrator is kubernetes but unable to resolve kubernetes endpoint: Error loading config file "C:\Users\paulh\.kube\config;C:\Users\paulh\.kube\dev.config;C:\Users\paulh\.kube\ci.config;C:\Users\paulh\.kube\k8s-test.config;C:\Users\paulh\.kube\ci2.config;C:\Users\paulh\.kube\project.config;": open C:\Users\paulh\.kube\config;C:\Users\paulh\.kube\dev.config;C:\Users\paulh\.kube\ci.config;C:\Users\paulh\.kube\k8s-test.config;C:\Users\paulh\.kube\ci2.config;C:\Users\paulh\.kube\project.config;: The filename, directory name, or volume label syntax is incorrect.
It's pretty clearly trying to blindly open(${KUBE_CONFIG}), assuming the environment variable points to a single file, not a list of config files.
I couldn't change the setting as the 'Apply & Restart' button wouldn't light up, since the setting is on the Kubernetes tab, and Kubernetes was still starting. So I manually removed the setting from %USERPROFILE%\.docker\config.json, and docker ps was working again.
I also suspect this was blocking the Docker Desktop Kubernetes stack from starting, but it could also have been a coincidence that as soon as I changed the config file, it started up.
Information
- Windows Version: Windows 10 Enterprise 1903 (18362.175)
- Docker Desktop Version: 2.1.0.1 (37199) Stable
Steps to reproduce the behavior
- Install fresh Docker Desktop for Windows
- Enable Kubernetes
- Customise your
KUBECONFIG environment variable to point to extra config files for other Kubernetes stacks you work with
- Confirm
docker ps operates correctly.
- Enable the 'Deploy Docker Stacks to Kubernetes by default' setting, click "Apply & Restart"
- Confirm
docker ps now gives the listed error.
As noted by @mat007 in docker/for-win#4491 (comment), the problem is that in the two places I can see in this code-base that use KUBECONFIG, (func (c *EndpointMeta) kubernetes.ResolveDefault and func context.getKubernetesEndpoint) they both take that value, default it to ~/.kube/config if unset, and pass it to func kubernetes.FromKubeConfig.
This function passes the passed-in filename to clientcmd.NewNonInteractiveDeferredLoadingClientConfig as clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig}, which suppresses the merging behaviour normally employed by kubectl.
I think what we want to do is either use or reimplement a workalike for NewDefaultClientConfigLoadingRules which takes care of multi-file KUBECONFIG, and defaults to ~/.kube/config if not set.
Neither of these code-paths otherwise cares about the filename in question.
(Migrating over from docker/for-win#4491)
Expected behavior
With a customised
KUBECONFIGenv-var that lists multiple config files,docker psshould still function when the option "Deploy Docker Stacks to Kubernetes by default" is selected.Actual behavior
With a customised
KUBECONFIGenv-var that lists multiple config files,docker psfails function when the option "Deploy Docker Stacks to Kubernetes by default" is selected, with the following output:It's pretty clearly trying to blindly
open(${KUBE_CONFIG}), assuming the environment variable points to a single file, not a list of config files.I couldn't change the setting as the 'Apply & Restart' button wouldn't light up, since the setting is on the Kubernetes tab, and Kubernetes was still starting. So I manually removed the setting from
%USERPROFILE%\.docker\config.json, anddocker pswas working again.I also suspect this was blocking the Docker Desktop Kubernetes stack from starting, but it could also have been a coincidence that as soon as I changed the config file, it started up.
Information
Steps to reproduce the behavior
KUBECONFIGenvironment variable to point to extra config files for other Kubernetes stacks you work withdocker psoperates correctly.docker psnow gives the listed error.As noted by @mat007 in docker/for-win#4491 (comment), the problem is that in the two places I can see in this code-base that use
KUBECONFIG, (func (c *EndpointMeta) kubernetes.ResolveDefaultandfunc context.getKubernetesEndpoint) they both take that value, default it to ~/.kube/config if unset, and pass it tofunc kubernetes.FromKubeConfig.This function passes the passed-in filename to
clientcmd.NewNonInteractiveDeferredLoadingClientConfigasclientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig}, which suppresses the merging behaviour normally employed by kubectl.I think what we want to do is either use or reimplement a workalike for
NewDefaultClientConfigLoadingRuleswhich takes care of multi-fileKUBECONFIG, and defaults to ~/.kube/config if not set.Neither of these code-paths otherwise cares about the filename in question.