Skip to content

Commit 938dd6f

Browse files
vrubezhnydatho7561
authored andcommitted
Cannot login if my kube config doesn't exist #3872
Creates a minimalistic Kube config file in `~/.kube/` directory needed for `@kubernetes/client-node` API. The file contents doesn't define any clusters/users/contexts/etc. properties. Fixes: #3872 Signed-off-by: Victor Rubezhny <[email protected]>
1 parent 25931b6 commit 938dd6f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/util/kubeUtils.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,17 @@ export function getKubeConfigFiles(): string[] {
162162
}
163163
return filesThatExist;
164164
}
165-
return [path.join(Platform.getUserHomePath(), '.kube', 'config')];
165+
166+
const defaultKubeConfigFile = path.join(Platform.getUserHomePath(), '.kube', 'config');
167+
if (!fs.existsSync(defaultKubeConfigFile)) {
168+
try {
169+
fs.appendFileSync(defaultKubeConfigFile, 'apiVersion: v1'); // Create Kube Config with minimal content
170+
} catch (err) {
171+
void window.showErrorMessage(`Kubernetes configuration file cannot be created at '${defaultKubeConfigFile}': ${err}`);
172+
}
173+
}
174+
175+
return [defaultKubeConfigFile];
166176
}
167177

168178
/**

0 commit comments

Comments
 (0)