ksail icon indicating copy to clipboard operation
ksail copied to clipboard

Automatically discover clusterName

Open rvangsgaard opened this issue 1 year ago • 5 comments

Description

Try to discover clusterName based on current folder name. Consider validating the discovered name by looking for a corresponding YAML-file.

Example:

  1. CWD=$(current work dir)
  2. Check for file with name $CWD-k3d-config.yaml

rvangsgaard avatar Feb 28 '24 10:02 rvangsgaard

Hmm, really good idea! I thought about this once but I was not able to come up with a good solution, as one could potentially want to initialize multiple clusters in the same folder.

I do not want to enforce ways of working, so do you have a suggestion of how I could handle if there are multiple KSail clusters initialized in the same folder?

devantler avatar Feb 28 '24 13:02 devantler

I do not want to enforce ways of working, so do you have a suggestion of how I could handle if there are multiple KSail clusters initialized in the same folder?

I think a good default behavior is a good thing, and allow the user to override it. In this case:

  1. If the user specifies a cluster name, user it.
  2. If not, look for a config file (cluster) with the same name as the folder.

rvangsgaard avatar Apr 12 '24 07:04 rvangsgaard

If not, look for a config file (cluster) with the same name as the folder.

The problem with this is that there could be:

cluster1-ksail-k3d-config.yaml
cluster2-ksail-k3d-config.yaml
k8s/clusters/cluster1/**
k8s/clusters/cluster2/**

In the same folder, thus I would not know which cluster the user wants to use by default.

My current solution proposal is to await having implemented a ksail native config file with something like this:

ksail-config.yaml
---
clusterName: cluster1
otherOption: dsadsad
anotherOption: dsdsad

There would only be one of these in your current folder, and that file can then be used to control the behavior of the CLI. Flags and arguments would overwrite the config values, and thus it would still be possible to run ksail up cluster2 to setup the other cluster using the default values from the config file.

Would this solve it for you? :-)

devantler avatar Apr 12 '24 08:04 devantler

I do not understand the proposed solution - will the ksail native config file only contain exactly one clusterName or multiple. If you can, please elaborate on the ksail native config file, especially the example.

rvangsgaard avatar Jul 01 '24 09:07 rvangsgaard

It will contain one cluster name.

See it as a per-project configuration. One folder should not contain more than one ksail cluster. In rare cases where there could be more than one ksail cluster in a folder, the configuration will use the cluster name to infer which one to provision when running:

ksail up

devantler avatar Jul 01 '24 09:07 devantler