Open nikimanoledaki opened 2 years ago
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Adding a proposal below to improve visibility with a CLI option
For each eksctl command that supports using a cluster config file, add a new flag --check-config-file
(better naming suggestions are welcome) that will only be available to use when a config file is provided, e.g.
eksctl create cluster --config-file config.yaml --check-config-file
This shall give the user some sort of insights on the config file they have provided, as in which fields are part of which of the following categories: supported and provided, supported but not provided, ignored etc. We can opt to display an amended config file, where we add default values for missing (optional) fields, and color everything accordingly to the category they fall into. Fields that are not supported, or required but missing shall always result in throwing a validation error.
Say the user is using the following config file for creating fargate profiles
...
metadata:
name: my-cluster
region: us-west-2
version: "1.27"
nodeGroups:
- name: my-nodegroup
amiFamily: "amazonlinux2"
desiredCapacity: 2
fargateProfiles:
- name: fp-default
selectors:
# All workloads in the "default" Kubernetes namespace will be
# scheduled onto Fargate:
- namespace: default
# All workloads in the "kube-system" Kubernetes namespace will be
# scheduled onto Fargate:
- namespace: kube-system
Thus, running eksctl create fargateprofile --config-file config.yalm --check-config-file
shall return something like
Where:
Each command that supports using a config file usually has its own dedicated cluster config loader func (e.g. CreateNodegroupLoader). Apart from unmarshaling the config file into cluster config struct, this is usually responsible for some additional validations. We can extend the loader’s functionality to sort the provided fields into their respective categories. To achieve this we need to know in advance which command uses which fields, thus, I suggest creating for each command a new struct type that is a subset of the cluster config, only containing the relevant fields for that command. With the above example in mind, for create fargateprofile
command we shall have:
type CreateFargateProfileClusterConfig struct {
Metadata ClusterMeta
FargateProfiles []*FargateProfile
}
Below is a starting point for creating a custom yaml printer that supports colouring the output https://gist.github.com/TiberiuGC/38053ab5d8bbc252ce139202f02b4e0a
This issues raises a UX question around how to improve the visibility of the config file fields supported by each command.
As mentioned in this comment:
In the CLI, we could improve the validation of unsupported fields by logging any fields that are unsupported and remain unchanged.
In the docs, it would be nice to auto-generate the config file schema that is supported per command.