Eksctl: Unable to write kubeconfig

Created on 26 Jun 2020  Â·  4Comments  Â·  Source: weaveworks/eksctl

What happened?
I tried to create a cluster using the following command:

eksctl create cluster -f ./eksctl-config-proto-cluster.yaml --kubeconfig=./proto-cluster-kubeconfig.yaml

The cluster was created, but an error was shown indicating that writing the kubeconfig failed:

[!] unable to write kubeconfig , please retry with 'eksctl utils write-kubeconfig -n proto-cluster': unable to read existing kubeconfig file "./proto-cluster-kubeconfig.yaml": error loading config file "./proto-cluster-kubeconfig.yaml": read ./proto-cluster-kubeconfig.yaml: The process cannot access the file because another process has locked a portion of the file.

Executing the suggested command results in the following message:

Error: writing kubeconfig: unable to read existing kubeconfig file "./proto-cluster-kubeconfig.yaml": error loading config file "./proto-cluster-kubeconfig.yaml": read ./proto-cluster-kubeconfig.yaml: The process cannot access the file because another process has locked a portion of the file.

In both cases, an empty file with the given name is created. Retrying it with the command pointing to an already existing empty file results in the same error.
If no file is given, it also fails with the same error for the default kubeconfig path.

What you expected to happen?
The kubeconfig file should be created and filled with the cluster information

How to reproduce it?
Execute eksctl utils write-kubeconfig --cluster=<cluster-name>

Anything else we need to know?
Might be a similar problem like #2270 ?
The problem was observed in Windows 10 1903 across multiple terminals and bashes.

Versions
Please paste in the output of these commands:

$ eksctl version
0.22.0
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"windows/amd64"}

Logs

2020-06-26T14:37:42+02:00 [ℹ]  eksctl version 0.22.0
2020-06-26T14:37:42+02:00 [ℹ]  using region eu-central-1
Error: writing kubeconfig: unable to read existing kubeconfig file "./proto-cluster-kubeconfig.yaml": error loading config file "./proto-cluster-kubeconfig.yaml": read ./proto-cluster-kubeconfig.yaml: The process cannot access the file because another process has locked a portion of the file.
kinbug prioritimportant-soon

Most helpful comment

This is fixed in 0.23.0-rc.1

All 4 comments

Hi,
I am also facing same issue with eksctl 0.22.0
Error is:
error: writing kubeconfig: unable to read existing kubeconfig file..
The process cannot access the file because another process has locked a portion of the file.

Please suggest.

There is a PR open which should fix this issue for windows users.

This is fixed in 0.23.0-rc.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

albertmichaelj picture albertmichaelj  Â·  3Comments

errordeveloper picture errordeveloper  Â·  4Comments

whereisaaron picture whereisaaron  Â·  4Comments

dewittcx picture dewittcx  Â·  3Comments

errordeveloper picture errordeveloper  Â·  4Comments